diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index da2018f..fc37f46 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,7 +41,6 @@ jobs: - run: rustup component add clippy - uses: Swatinem/rust-cache@v2 - run: cargo test --workspace - - run: cargo test --workspace proof - run: cargo clippy --workspace --all-targets -- -D warnings benchmark-smoke: @@ -59,11 +58,18 @@ jobs: - run: uv run --locked ./bench.py --rounds 1 --treatments off --timeout-sec 120 --report .reports.ci.jsonl egglog/tests/integer_math.egg codspeed: + name: codspeed (${{ matrix.mode }}) permissions: contents: read id-token: write runs-on: ubuntu-latest timeout-minutes: 20 + strategy: + fail-fast: false + matrix: + mode: + - simulation + - memory steps: - run: echo "CARGO_INCREMENTAL=0" >> "$GITHUB_ENV" - uses: actions/checkout@v4 @@ -71,10 +77,10 @@ jobs: persist-credentials: false - uses: taiki-e/install-action@v2 with: - tool: cargo-codspeed@4.0.1 + tool: cargo-codspeed@5.0.1 - uses: Swatinem/rust-cache@v2 - - run: cargo codspeed build -p egglog-experimental --bench files + - run: cargo codspeed build --measurement-mode ${{ matrix.mode }} -p egglog-experimental --bench files - uses: CodSpeedHQ/action@v4 with: - run: cargo codspeed run files - mode: simulation + run: cargo codspeed run --measurement-mode ${{ matrix.mode }} files + mode: ${{ matrix.mode }} diff --git a/AGENTS.md b/AGENTS.md index b379fe3..d47bfbe 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -17,11 +17,10 @@ session's `xhigh` reasoning effort instead. ## Tests -Use this order for normal changes: +Use this order for normal full validation: ```bash cargo test --workspace -cargo test --workspace proof cargo clippy --workspace --all-targets -- -D warnings uv lock --check uv run --locked ruff format --check bench.py test_bench.py @@ -30,31 +29,41 @@ uv run --locked mypy bench.py test_bench.py uv run --locked pytest -q ``` -For benchmark-runner changes, also smoke the CLI with a temporary report: +For proof-focused changes, the filtered proof test is useful while iterating or +when you want a focused proof rerun: ```bash -uv run --locked ./bench.py --rounds 1 --treatments off --report .reports.smoke.jsonl \ - egglog/tests/integer_math.egg +cargo test --workspace --test files proof_unit +cargo test --workspace --test files proof_integration ``` -For agent-readable benchmark smoke output, pipe report rows from stdout and keep -runner status and build diagnostics on stderr: +`proof_unit` runs small explicit `(prove ...)` fixtures under `tests/proofs` +and snapshots their proof-mode output. +`proof_integration` runs curated larger proof-testing cases that stay in their +normal test locations, treating checks as proves and snapshotting generated +proofs. Both are name-filtered subsets of `cargo test --workspace`, so do not +run them after a full workspace test unless you want a focused proof rerun. + +For benchmark-runner changes, smoke the public CLI entrypoint with a temporary, +machine-readable report. Use stdout report mode so the run does not read or +append to the default benchmark cache; runner status and build diagnostics stay +on stderr. ```bash -uv run --locked ./bench.py --rounds 1 --treatments off --report - \ +./bench.py --rounds 1 --treatments off --report - \ egglog/tests/integer_math.egg > /tmp/egglog-encoding-bench-smoke.jsonl ``` ## Benchmarking - Use `./bench.py` as the public benchmark entrypoint. -- Do not pass egglog's `--save-report` during timed benchmark collection; it - changes the measured work. - Keep `.reports.jsonl` append-only and ignored by git. - Use `--report -` when report rows should be streamed to stdout instead of appended to a cache file. - Runner status output always goes to stderr, including Rich progress and summary tables. +- Benchmark inputs should not contain executable `(prove ...)` commands; use + `(check ...)` in benchmark fixtures and cover proof extraction in proof tests. - Benchmark files are resolved relative to the command invocation directory, not relative to comparison targets. - Cache reuse is decided by binary SHA-256, file SHA-256, treatment, and diff --git a/Cargo.lock b/Cargo.lock index f572464..f66efe3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -626,6 +626,7 @@ dependencies = [ "egglog-ast", "egglog-reports", "glob", + "insta", "lazy_static", "libtest-mimic", "log", diff --git a/README.md b/README.md index 5db466d..45caad9 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,8 @@ The development loop is: cargo test --workspace # Run proof-focused tests while iterating. -cargo test --workspace proof +cargo test --workspace --test files proof_unit +cargo test --workspace --test files proof_integration # Run lint checks across the workspace. cargo clippy --workspace --all-targets @@ -35,6 +36,18 @@ The root workspace includes both `egglog` and `egglog-experimental`. `egglog-experimental` depends on the workspace `egglog` crate, which keeps proof changes and downstream experimental behavior in the same reviewable unit. +Proof-specific file tests use two filter prefixes: + +- `proof_unit`: small explicit `(prove ...)` fixtures under `tests/proofs`, + with proof-mode output saved as snapshots. +- `proof_integration`: curated larger proof-testing cases that stay in their + normal test locations, such as math-style workloads and the eggcc fixture. + Checks are treated as prove commands and the generated proofs are saved as + snapshots. + +Both filters are subsets of the full workspace test run. Use them for fast proof +iteration and reserve `cargo test --workspace` for the final compatibility gate. + ## Benchmarking The public benchmark entrypoint is an executable Python script: @@ -120,10 +133,12 @@ If no files are provided, the default target benchmark suite is: - `egglog/tests/web-demo/rw-analysis.egg` - `egglog/tests/integer_math.egg` - `egglog/tests/web-demo/resolution.egg` +- `egglog-experimental/tests/fixtures/eggcc-2mm-pass1-merge-old.egg` -These four files are proof-compatible representative examples under the current +These five files are proof-compatible representative examples under the current `egglog-experimental` CLI and run under the default `off`, `term`, and `proofs` -treatment matrix. +treatment matrix. The eggcc fixture is the heavy container/proof benchmark in +the default suite. Relative file paths are resolved relative to the directory where `./bench.py` was invoked, not relative to each target checkout. The same file contents are used for every target, and `file.sha256` records the exact benchmark input. @@ -513,17 +528,18 @@ Each benchmark report row records the binary hash used for that observation. ## CI -CI runs on pull requests, manual dispatch, and pushes to `main`. It runs four -jobs: +CI runs on pull requests, manual dispatch, and pushes to `main`. It runs these +job groups: - `python`: `uv lock --check`, ruff formatting, ruff linting, mypy, and pytest. - `rust`: workspace tests, proof-focused tests, and clippy. - `benchmark-smoke`: a one-round `./bench.py` run on `egglog/tests/integer_math.egg`. - `codspeed`: an in-process, proofs-only `egglog-experimental` benchmark - harness over a smaller representative file set. CodSpeed tracks proof-mode - movement without invoking `./bench.py`; the CLI benchmark report remains the - source for the full off/term/proofs comparison. + harness over a smaller representative file set, run through CodSpeed in both + simulation and memory modes. CodSpeed tracks proof-mode movement without + invoking `./bench.py`; the CLI benchmark report remains the source for the + full off/term/proofs comparison. Python checks are run as separate commands: diff --git a/bench.py b/bench.py index 2a938aa..a441d3f 100755 --- a/bench.py +++ b/bench.py @@ -50,6 +50,7 @@ "egglog/tests/web-demo/rw-analysis.egg", "egglog/tests/integer_math.egg", "egglog/tests/web-demo/resolution.egg", + "egglog-experimental/tests/fixtures/eggcc-2mm-pass1-merge-old.egg", ) TARGET_SPEED_CAPTION = ( "Ratio is target / baseline. Values below 1x are faster; above 1x are slower. Intervals are 95% CIs." @@ -434,6 +435,25 @@ def resolve_files(raw_files: Sequence[str], invocation_cwd: Path) -> tuple[FileS return tuple(files) +def file_contains_executable_prove_command(path: Path) -> bool: + for line in path.read_text(encoding="utf-8").splitlines(): + stripped = line.lstrip() + if stripped.startswith(";"): + continue + if re.match(r"\(prove(?:\s|\))", stripped): + return True + return False + + +def validate_spec(spec: BenchmarkSpec) -> None: + for file_spec in spec.files: + if file_contains_executable_prove_command(file_spec.absolute_path): + raise ValueError( + f"{file_spec.display_path} contains an explicit prove command; " + "benchmark files should use check so proof extraction is not included in timed runs" + ) + + def resolve_report_destination(raw_report: str, invocation_cwd: Path) -> ReportDestination: if raw_report == "-": return ReportDestination(path=None, stream=sys.stdout) @@ -1779,6 +1799,7 @@ def main(argv: Sequence[str] | None = None) -> int: rounds=args.rounds, timeout_sec=args.timeout_sec, ) + validate_spec(spec) target_specs = args.target if args.target is not None else ["."] target_requests = tuple(parse_target(raw) for raw in target_specs) rows = load_report(report_destination) diff --git a/egglog-experimental/Cargo.toml b/egglog-experimental/Cargo.toml index bff575a..739105f 100644 --- a/egglog-experimental/Cargo.toml +++ b/egglog-experimental/Cargo.toml @@ -32,4 +32,5 @@ log = "0.4" [dev-dependencies] divan = { workspace = true } glob = "0.3.1" +insta = "1.40" libtest-mimic = "0.8.1" diff --git a/egglog-experimental/src/container_primitives.rs b/egglog-experimental/src/container_primitives.rs new file mode 100644 index 0000000..c2bb8dc --- /dev/null +++ b/egglog-experimental/src/container_primitives.rs @@ -0,0 +1,392 @@ +use crate::either::{EitherContainer, EitherData}; +use crate::maybe::{MaybeContainer, maybe_sorts}; +use egglog::ast::{Literal, Span}; +use egglog::constraint::{self, Constraint, TypeConstraint}; +use egglog::sort::PairContainer; +use egglog::{ + ArcSort, Atom, AtomTerm, Core, EGraph, Primitive, PurePrim, PureState, Term, TermDag, TermId, + TypeInfo, Value, +}; +use std::any::TypeId; +use std::sync::Arc; + +type TypeConstraints = Vec>>; +type ConstraintChoice = Vec>>; + +pub fn add_container_primitives(egraph: &mut EGraph) { + egraph.add_pure_primitive( + PairMinBySecondI64, + Some(Arc::new(validate_pair_min_by_second_i64)), + ); + egraph.add_pure_primitive( + MaybeEitherI64BoolMin, + Some(Arc::new(validate_maybe_either_i64_bool_min)), + ); + egraph.add_pure_primitive( + MaybeEitherI64BoolMax, + Some(Arc::new(validate_maybe_either_i64_bool_max)), + ); +} + +fn arity_mismatch( + name: &str, + span: &Span, + arguments: &[AtomTerm], + expected: usize, +) -> TypeConstraints { + vec![constraint::impossible( + constraint::ImpossibleConstraint::ArityMismatch { + atom: Atom { + span: span.clone(), + head: name.to_owned(), + args: arguments.to_vec(), + }, + expected, + }, + )] +} + +fn choose(choices: Vec) -> TypeConstraints { + match choices.len() { + 0 => vec![constraint::xor(vec![])], + 1 => choices.into_iter().next().unwrap(), + _ => vec![constraint::xor( + choices.into_iter().map(constraint::and).collect(), + )], + } +} + +fn assign_all(arguments: &[AtomTerm], sorts: &[ArcSort]) -> ConstraintChoice { + arguments + .iter() + .cloned() + .zip(sorts.iter().cloned()) + .map(|(argument, sort)| constraint::assign(argument, sort)) + .collect() +} + +#[derive(Clone)] +struct PairMinBySecondI64; + +impl Primitive for PairMinBySecondI64 { + fn name(&self) -> &str { + "pair-min-by-second-i64" + } + + fn get_type_constraints(&self, span: &Span) -> Box { + Box::new(PairI64SameSortTypeConstraint { + name: self.name().to_owned(), + span: span.clone(), + }) + } +} + +impl PurePrim for PairMinBySecondI64 { + fn apply<'a, 'db>(&self, state: PureState<'a, 'db>, args: &[Value]) -> Option { + let old = state + .container_values() + .get_val::(args[0])? + .clone(); + let new = state + .container_values() + .get_val::(args[1])? + .clone(); + let old_cost = state.base_values().unwrap::(old.second); + let new_cost = state.base_values().unwrap::(new.second); + + if old_cost <= new_cost { + Some(args[0]) + } else { + Some(args[1]) + } + } +} + +struct PairI64SameSortTypeConstraint { + name: String, + span: Span, +} + +impl TypeConstraint for PairI64SameSortTypeConstraint { + fn get(&self, arguments: &[AtomTerm], typeinfo: &TypeInfo) -> TypeConstraints { + if arguments.len() != 3 { + return arity_mismatch(&self.name, &self.span, arguments, 3); + } + + let choices = pair_i64_sorts(typeinfo) + .into_iter() + .map(|sort| assign_all(arguments, &[sort.clone(), sort.clone(), sort])) + .collect(); + choose(choices) + } +} + +#[derive(Clone)] +struct MaybeEitherI64BoolMin; + +impl Primitive for MaybeEitherI64BoolMin { + fn name(&self) -> &str { + "maybe-either-i64-bool-min" + } + + fn get_type_constraints(&self, span: &Span) -> Box { + Box::new(BoundSameSortTypeConstraint { + name: self.name().to_owned(), + span: span.clone(), + }) + } +} + +impl PurePrim for MaybeEitherI64BoolMin { + fn apply<'a, 'db>(&self, state: PureState<'a, 'db>, args: &[Value]) -> Option { + bound_merge(state, args, BoundMergeKind::Min) + } +} + +#[derive(Clone)] +struct MaybeEitherI64BoolMax; + +impl Primitive for MaybeEitherI64BoolMax { + fn name(&self) -> &str { + "maybe-either-i64-bool-max" + } + + fn get_type_constraints(&self, span: &Span) -> Box { + Box::new(BoundSameSortTypeConstraint { + name: self.name().to_owned(), + span: span.clone(), + }) + } +} + +impl PurePrim for MaybeEitherI64BoolMax { + fn apply<'a, 'db>(&self, state: PureState<'a, 'db>, args: &[Value]) -> Option { + bound_merge(state, args, BoundMergeKind::Max) + } +} + +struct BoundSameSortTypeConstraint { + name: String, + span: Span, +} + +impl TypeConstraint for BoundSameSortTypeConstraint { + fn get(&self, arguments: &[AtomTerm], typeinfo: &TypeInfo) -> TypeConstraints { + if arguments.len() != 3 { + return arity_mismatch(&self.name, &self.span, arguments, 3); + } + + let choices = bound_sorts(typeinfo) + .into_iter() + .map(|sort| assign_all(arguments, &[sort.clone(), sort.clone(), sort])) + .collect(); + choose(choices) + } +} + +#[derive(Clone, Copy)] +enum BoundMergeKind { + Min, + Max, +} + +impl BoundMergeKind { + fn keep_i64_old(self, old: i64, new: i64) -> bool { + match self { + BoundMergeKind::Min => old <= new, + BoundMergeKind::Max => old >= new, + } + } + + fn keep_bool_old(self, old: bool, new: bool) -> bool { + match self { + BoundMergeKind::Min => !old || new, + BoundMergeKind::Max => old || !new, + } + } +} + +fn bound_merge<'a, 'db>( + state: PureState<'a, 'db>, + args: &[Value], + kind: BoundMergeKind, +) -> Option { + let old = state + .container_values() + .get_val::(args[0])? + .clone(); + let new = state + .container_values() + .get_val::(args[1])? + .clone(); + + let (Some(old_value), Some(new_value)) = (old.data, new.data) else { + return match (old.data, new.data) { + (None, _) => Some(args[0]), + (_, None) => Some(args[1]), + _ => unreachable!(), + }; + }; + + let old = state + .container_values() + .get_val::(old_value)? + .clone(); + let new = state + .container_values() + .get_val::(new_value)? + .clone(); + + match (old.data, new.data) { + (EitherData::Left(old_int), EitherData::Left(new_int)) => { + let old_int = state.base_values().unwrap::(old_int); + let new_int = state.base_values().unwrap::(new_int); + let keep_old = kind.keep_i64_old(old_int, new_int); + Some(if keep_old { args[0] } else { args[1] }) + } + (EitherData::Right(old_bool), EitherData::Right(new_bool)) => { + let old_bool = state.base_values().unwrap::(old_bool); + let new_bool = state.base_values().unwrap::(new_bool); + let keep_old = kind.keep_bool_old(old_bool, new_bool); + Some(if keep_old { args[0] } else { args[1] }) + } + _ => None, + } +} + +fn pair_i64_sorts(type_info: &TypeInfo) -> Vec { + type_info.get_arcsorts_by(|sort| { + if sort.value_type() != Some(TypeId::of::()) { + return false; + } + let inner_sorts = sort.inner_sorts(); + inner_sorts + .get(1) + .is_some_and(|second| second.name() == "i64") + }) +} + +fn bound_sorts(type_info: &TypeInfo) -> Vec { + maybe_sorts(type_info) + .into_iter() + .filter_map(|(sort, element)| { + if element.value_type() != Some(TypeId::of::()) { + return None; + } + let inner_sorts = element.inner_sorts(); + let [left, right] = inner_sorts.as_slice() else { + return None; + }; + (left.name() == "i64" && right.name() == "bool").then_some(sort) + }) + .collect() +} + +fn validate_pair_min_by_second_i64(termdag: &mut TermDag, args: &[TermId]) -> Option { + let [old, new] = args else { + return None; + }; + let old_cost = pair_second_i64(termdag, *old)?; + let new_cost = pair_second_i64(termdag, *new)?; + Some(if old_cost <= new_cost { *old } else { *new }) +} + +fn pair_second_i64(termdag: &TermDag, term: TermId) -> Option { + match termdag.get(term) { + Term::App(head, children) if head == "pair" && children.len() == 2 => { + match termdag.get(children[1]) { + Term::Lit(Literal::Int(value)) => Some(*value), + _ => None, + } + } + _ => None, + } +} + +fn validate_maybe_either_i64_bool_min(termdag: &mut TermDag, args: &[TermId]) -> Option { + validate_maybe_either_i64_bool_merge(termdag, args, BoundMergeKind::Min) +} + +fn validate_maybe_either_i64_bool_max(termdag: &mut TermDag, args: &[TermId]) -> Option { + validate_maybe_either_i64_bool_merge(termdag, args, BoundMergeKind::Max) +} + +fn validate_maybe_either_i64_bool_merge( + termdag: &mut TermDag, + args: &[TermId], + kind: BoundMergeKind, +) -> Option { + let [old, new] = args else { + return None; + }; + match (bound_term(termdag, *old)?, bound_term(termdag, *new)?) { + (BoundTerm::Dead, _) => Some(*old), + (_, BoundTerm::Dead) => Some(*new), + (BoundTerm::Int(old_int), BoundTerm::Int(new_int)) => { + let keep_old = kind.keep_i64_old(old_int, new_int); + Some(if keep_old { *old } else { *new }) + } + (BoundTerm::Bool(old_bool), BoundTerm::Bool(new_bool)) => { + let keep_old = kind.keep_bool_old(old_bool, new_bool); + Some(if keep_old { *old } else { *new }) + } + _ => None, + } +} + +enum BoundTerm { + Dead, + Int(i64), + Bool(bool), +} + +fn bound_term(termdag: &TermDag, term: TermId) -> Option { + match termdag.get(term) { + Term::App(head, children) if head == "maybe-none" && children.is_empty() => { + Some(BoundTerm::Dead) + } + _ => { + if let Some(value) = bound_int_term(termdag, term) { + match termdag.get(value) { + Term::Lit(Literal::Int(value)) => Some(BoundTerm::Int(*value)), + _ => None, + } + } else if let Some(value) = bound_bool_term(termdag, term) { + match termdag.get(value) { + Term::Lit(Literal::Bool(value)) => Some(BoundTerm::Bool(*value)), + _ => None, + } + } else { + None + } + } + } +} + +fn bound_int_term(termdag: &TermDag, term: TermId) -> Option { + match termdag.get(term) { + Term::App(head, children) if head == "maybe-some" && children.len() == 1 => { + match termdag.get(children[0]) { + Term::App(head, children) if head == "either-left" && children.len() == 1 => { + Some(children[0]) + } + _ => None, + } + } + _ => None, + } +} + +fn bound_bool_term(termdag: &TermDag, term: TermId) -> Option { + match termdag.get(term) { + Term::App(head, children) if head == "maybe-some" && children.len() == 1 => { + match termdag.get(children[0]) { + Term::App(head, children) if head == "either-right" && children.len() == 1 => { + Some(children[0]) + } + _ => None, + } + } + _ => None, + } +} diff --git a/egglog-experimental/src/either.rs b/egglog-experimental/src/either.rs new file mode 100644 index 0000000..d782897 --- /dev/null +++ b/egglog-experimental/src/either.rs @@ -0,0 +1,257 @@ +use egglog::ast::Expr; +use egglog::prelude::ContainerSort; +use egglog::sort::{ContainerValues, Presort, ValueRebuilder}; +use egglog::{ + ArcSort, ContainerValue, EGraph, TermDag, TermId, TypeError, TypeInfo, Value, + add_primitive_with_validator, +}; +use std::any::TypeId; + +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +pub enum EitherData { + Left(Value), + Right(Value), +} + +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +pub struct EitherContainer { + pub do_rebuild_left: bool, + pub do_rebuild_right: bool, + pub data: EitherData, +} + +impl ContainerValue for EitherContainer { + fn rebuild_contents(&mut self, rebuilder: &dyn ValueRebuilder) -> bool { + match &mut self.data { + EitherData::Left(value) if self.do_rebuild_left => { + let old = *value; + let new = rebuilder.rebuild_val(old); + *value = new; + old != new + } + EitherData::Right(value) if self.do_rebuild_right => { + let old = *value; + let new = rebuilder.rebuild_val(old); + *value = new; + old != new + } + _ => false, + } + } + + fn iter(&self) -> impl Iterator + '_ { + match self.data { + EitherData::Left(value) | EitherData::Right(value) => Some(value).into_iter(), + } + } +} + +#[derive(Clone, Debug)] +pub struct EitherSort { + name: String, + left: ArcSort, + right: ArcSort, +} + +impl EitherSort { + pub fn left(&self) -> ArcSort { + self.left.clone() + } + + pub fn right(&self) -> ArcSort { + self.right.clone() + } +} + +impl Presort for EitherSort { + fn presort_name() -> &'static str { + "Either" + } + + fn reserved_primitives() -> Vec<&'static str> { + vec![ + "either-left", + "either-right", + "either-unwrap-left", + "either-unwrap-right", + ] + } + + fn make_sort( + typeinfo: &mut TypeInfo, + name: String, + args: &[Expr], + ) -> Result { + if let [Expr::Var(left_span, left), Expr::Var(right_span, right)] = args { + let left = typeinfo + .get_sort_by_name(left) + .ok_or(TypeError::UndefinedSort(left.clone(), left_span.clone()))?; + let right = typeinfo + .get_sort_by_name(right) + .ok_or(TypeError::UndefinedSort(right.clone(), right_span.clone()))?; + + Ok(Self { + name, + left: left.clone(), + right: right.clone(), + } + .to_arcsort()) + } else { + panic!("Either sort requires exactly two arguments") + } + } +} + +impl ContainerSort for EitherSort { + type Container = EitherContainer; + + fn name(&self) -> &str { + &self.name + } + + fn is_eq_container_sort(&self) -> bool { + self.left.is_eq_sort() + || self.right.is_eq_sort() + || self.left.is_eq_container_sort() + || self.right.is_eq_container_sort() + } + + fn inner_sorts(&self) -> Vec { + vec![self.left.clone(), self.right.clone()] + } + + fn inner_values( + &self, + container_values: &ContainerValues, + value: Value, + ) -> Vec<(ArcSort, Value)> { + let either = container_values + .get_val::(value) + .unwrap() + .clone(); + match either.data { + EitherData::Left(value) => vec![(self.left.clone(), value)], + EitherData::Right(value) => vec![(self.right.clone(), value)], + } + } + + fn register_primitives(&self, eg: &mut EGraph) { + let arc = self.clone().to_arcsort(); + + add_primitive_with_validator!( + eg, + "either-left" = {self.clone(): EitherSort} |left: # (self.left())| -> @EitherContainer (arc) { + EitherContainer { + do_rebuild_left: self.ctx.left.is_eq_sort() || self.ctx.left.is_eq_container_sort(), + do_rebuild_right: self.ctx.right.is_eq_sort() || self.ctx.right.is_eq_container_sort(), + data: EitherData::Left(left), + } + }, + |termdag: &mut TermDag, args: &[TermId]| -> Option { + if args.len() == 1 { + Some(termdag.app("either-left".into(), args.to_vec())) + } else { + None + } + } + ); + + add_primitive_with_validator!( + eg, + "either-right" = {self.clone(): EitherSort} |right: # (self.right())| -> @EitherContainer (arc) { + EitherContainer { + do_rebuild_left: self.ctx.left.is_eq_sort() || self.ctx.left.is_eq_container_sort(), + do_rebuild_right: self.ctx.right.is_eq_sort() || self.ctx.right.is_eq_container_sort(), + data: EitherData::Right(right), + } + }, + |termdag: &mut TermDag, args: &[TermId]| -> Option { + if args.len() == 1 { + Some(termdag.app("either-right".into(), args.to_vec())) + } else { + None + } + } + ); + + add_primitive_with_validator!( + eg, + "either-unwrap-left" = |xs: @EitherContainer (arc)| -?> # (self.left()) { + match xs.data { + EitherData::Left(value) => Some(value), + EitherData::Right(_) => None, + } + }, + |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [either] = args else { + return None; + }; + match termdag.get(*either) { + Term::App(head, children) if head == "either-left" && children.len() == 1 => { + Some(children[0]) + } + _ => None, + } + } + ); + + add_primitive_with_validator!( + eg, + "either-unwrap-right" = |xs: @EitherContainer (arc)| -?> # (self.right()) { + match xs.data { + EitherData::Left(_) => None, + EitherData::Right(value) => Some(value), + } + }, + |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [either] = args else { + return None; + }; + match termdag.get(*either) { + Term::App(head, children) if head == "either-right" && children.len() == 1 => { + Some(children[0]) + } + _ => None, + } + } + ); + } + + fn reconstruct_termdag( + &self, + container_values: &ContainerValues, + value: Value, + termdag: &mut TermDag, + element_terms: Vec, + ) -> TermId { + assert_eq!(element_terms.len(), 1); + let either = container_values.get_val::(value).unwrap(); + let head = match either.data { + EitherData::Left(_) => "either-left", + EitherData::Right(_) => "either-right", + }; + termdag.app(head.into(), element_terms) + } + + fn serialized_name(&self, container_values: &ContainerValues, value: Value) -> String { + let either = container_values.get_val::(value).unwrap(); + match either.data { + EitherData::Left(_) => "either-left".to_owned(), + EitherData::Right(_) => "either-right".to_owned(), + } + } +} + +pub fn either_sorts(type_info: &TypeInfo) -> Vec<(ArcSort, ArcSort, ArcSort)> { + type_info + .get_arcsorts_by(|sort| sort.value_type() == Some(TypeId::of::())) + .into_iter() + .filter_map(|sort| { + let inner_sorts = sort.inner_sorts(); + let [left, right] = inner_sorts.as_slice() else { + return None; + }; + Some((sort, left.clone(), right.clone())) + }) + .collect() +} diff --git a/egglog-experimental/src/lib.rs b/egglog-experimental/src/lib.rs index 1dba91e..0bc6cde 100644 --- a/egglog-experimental/src/lib.rs +++ b/egglog-experimental/src/lib.rs @@ -52,7 +52,13 @@ pub use size::*; mod primitive; mod table_stats; pub use table_stats::*; +mod maybe; mod table_rows; +pub use maybe::*; +mod either; +pub use either::*; +mod container_primitives; +pub use container_primitives::*; // Sugar modules using parse-time macros mod sugar; @@ -62,24 +68,32 @@ mod keep_best; pub use keep_best::KeepBestCommand; pub fn new_experimental_egraph() -> EGraph { + new_experimental_egraph_with_options(true) +} + +pub fn new_experimental_egraph_for_proofs() -> EGraph { + new_experimental_egraph_with_options(false) +} + +fn new_experimental_egraph_with_options(extended_run_schedule: bool) -> EGraph { let mut egraph = EGraph::default(); - add_experimental_extensions(&mut egraph); + add_experimental_extensions(&mut egraph, extended_run_schedule); egraph } pub fn new_experimental_egraph_with_term_encoding() -> EGraph { - let mut egraph = EGraph::new_with_term_encoding(); - add_experimental_extensions(&mut egraph); - egraph + new_experimental_egraph_for_proofs().with_term_encoding_enabled() } pub fn new_experimental_egraph_with_proofs() -> EGraph { - let mut egraph = EGraph::new_with_proofs(); - add_experimental_extensions(&mut egraph); - egraph + new_experimental_egraph_for_proofs().with_proofs_enabled() +} + +pub fn new_experimental_egraph_with_proof_testing() -> EGraph { + new_experimental_egraph_with_proofs().with_proof_testing() } -fn add_experimental_extensions(egraph: &mut EGraph) { +fn add_experimental_extensions(egraph: &mut EGraph, extended_run_schedule: bool) { // Set up the parser with experimental parse-time macros egraph.parser = experimental_parser(); @@ -89,6 +103,15 @@ fn add_experimental_extensions(egraph: &mut EGraph) { // Support for set cost add_set_cost(egraph); egraph.add_read_primitive(GetSizePrimitive, None); + egraph + .type_info() + .add_presort::(span!()) + .unwrap(); + egraph + .type_info() + .add_presort::(span!()) + .unwrap(); + add_container_primitives(egraph); // unstable-fresh! macro egraph @@ -96,9 +119,11 @@ fn add_experimental_extensions(egraph: &mut EGraph) { .register(Arc::new(fresh_macro::FreshMacro::new())); // scheduler support - egraph - .add_command("run-schedule".into(), Arc::new(RunExtendedSchedule)) - .unwrap(); + if extended_run_schedule { + egraph + .add_command("run-schedule".into(), Arc::new(RunExtendedSchedule)) + .unwrap(); + } egraph .add_command("let-scheduler".into(), Arc::new(LetSchedulerCommand)) .unwrap(); diff --git a/egglog-experimental/src/main.rs b/egglog-experimental/src/main.rs index 39da1ac..9839e7b 100644 --- a/egglog-experimental/src/main.rs +++ b/egglog-experimental/src/main.rs @@ -1,3 +1,14 @@ fn main() { - egglog::cli(egglog_experimental::new_experimental_egraph()) + let proof_mode = std::env::args().any(|arg| { + matches!( + arg.as_str(), + "--proofs" | "--proof-testing" | "--term-encoding" + ) + }); + let egraph = if proof_mode { + egglog_experimental::new_experimental_egraph_for_proofs() + } else { + egglog_experimental::new_experimental_egraph() + }; + egglog::cli(egraph) } diff --git a/egglog-experimental/src/maybe.rs b/egglog-experimental/src/maybe.rs new file mode 100644 index 0000000..e3a9b6c --- /dev/null +++ b/egglog-experimental/src/maybe.rs @@ -0,0 +1,274 @@ +use egglog::ast::{Expr, Literal}; +use egglog::prelude::ContainerSort; +use egglog::sort::{ContainerValues, F, Presort, ValueRebuilder}; +use egglog::{ + ArcSort, ContainerValue, EGraph, Term, TermDag, TermId, TypeError, TypeInfo, Value, + add_primitive_with_validator, +}; +use std::any::TypeId; + +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +pub struct MaybeContainer { + pub do_rebuild: bool, + pub data: Option, +} + +impl ContainerValue for MaybeContainer { + fn rebuild_contents(&mut self, rebuilder: &dyn ValueRebuilder) -> bool { + if self.do_rebuild { + if let Some(old) = self.data { + let new = rebuilder.rebuild_val(old); + self.data = Some(new); + old != new + } else { + false + } + } else { + false + } + } + + fn iter(&self) -> impl Iterator + '_ { + self.data.iter().copied() + } +} + +#[derive(Clone, Debug)] +pub struct MaybeSort { + name: String, + element: ArcSort, +} + +impl MaybeSort { + pub fn element(&self) -> ArcSort { + self.element.clone() + } +} + +impl Presort for MaybeSort { + fn presort_name() -> &'static str { + "Maybe" + } + + fn reserved_primitives() -> Vec<&'static str> { + vec![ + "maybe-none", + "maybe-some", + "maybe-unwrap", + "maybe-unwrap-or", + "maybe-f64-merge-with-tol", + ] + } + + fn make_sort( + typeinfo: &mut TypeInfo, + name: String, + args: &[Expr], + ) -> Result { + if let [Expr::Var(span, element)] = args { + let element = typeinfo + .get_sort_by_name(element) + .ok_or(TypeError::UndefinedSort(element.clone(), span.clone()))?; + + Ok(Self { + name, + element: element.clone(), + } + .to_arcsort()) + } else { + panic!("Maybe sort requires exactly one argument") + } + } +} + +impl ContainerSort for MaybeSort { + type Container = MaybeContainer; + + fn name(&self) -> &str { + &self.name + } + + fn is_eq_container_sort(&self) -> bool { + self.element.is_eq_sort() || self.element.is_eq_container_sort() + } + + fn inner_sorts(&self) -> Vec { + vec![self.element.clone()] + } + + fn inner_values( + &self, + container_values: &ContainerValues, + value: Value, + ) -> Vec<(ArcSort, Value)> { + let val = container_values + .get_val::(value) + .unwrap() + .clone(); + val.data + .iter() + .map(|v| (self.element.clone(), *v)) + .collect() + } + + fn register_primitives(&self, eg: &mut EGraph) { + let arc = self.clone().to_arcsort(); + + add_primitive_with_validator!( + eg, + "maybe-none" = {self.clone(): MaybeSort} || -> @MaybeContainer (arc) { MaybeContainer { + do_rebuild: self.ctx.is_eq_container_sort(), + data: None, + } }, + |termdag: &mut TermDag, args: &[TermId]| -> Option { + if args.is_empty() { + Some(termdag.app("maybe-none".into(), vec![])) + } else { + None + } + } + ); + + add_primitive_with_validator!( + eg, + "maybe-some" = {self.clone(): MaybeSort} |x: # (self.element())| -> @MaybeContainer (arc) { MaybeContainer { + do_rebuild: self.ctx.is_eq_container_sort(), + data: Some(x), + } }, + |termdag: &mut TermDag, args: &[TermId]| -> Option { + if args.len() == 1 { + Some(termdag.app("maybe-some".into(), args.to_vec())) + } else { + None + } + } + ); + + add_primitive_with_validator!( + eg, + "maybe-unwrap" = |xs: @MaybeContainer (arc)| -?> # (self.element()) { xs.data }, + |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [maybe] = args else { + return None; + }; + match termdag.get(*maybe) { + Term::App(head, children) if head == "maybe-some" && children.len() == 1 => { + Some(children[0]) + } + _ => None, + } + } + ); + + add_primitive_with_validator!( + eg, + "maybe-unwrap-or" = |xs: @MaybeContainer (arc), default: # (self.element())| -> # (self.element()) { + xs.data.unwrap_or(default) + }, + |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [maybe, default] = args else { + return None; + }; + match termdag.get(*maybe) { + Term::App(head, children) if head == "maybe-some" && children.len() == 1 => { + Some(children[0]) + } + Term::App(head, children) if head == "maybe-none" && children.is_empty() => { + Some(*default) + } + _ => None, + } + } + ); + + if self.element().name() == "f64" { + add_primitive_with_validator!( + eg, + "maybe-f64-merge-with-tol" = |old: @MaybeContainer (arc), new: @MaybeContainer (arc), tol: F| -?> @MaybeContainer (arc) {{ + match (old.data, new.data) { + (None, _) | (_, None) => Some(MaybeContainer { data: None, ..old }), + (Some(old_value), Some(new_value)) => { + let old_f = state.base_values().unwrap::(old_value).0.0; + let new_f = state.base_values().unwrap::(new_value).0.0; + maybe_f64_values_merge_with_tol(old_f, new_f, tol.0.0).then_some(old) + } + } + }}, + validate_maybe_f64_merge_with_tol + ); + } + } + + fn reconstruct_termdag( + &self, + _container_values: &ContainerValues, + _value: Value, + termdag: &mut TermDag, + element_terms: Vec, + ) -> TermId { + match element_terms.as_slice() { + [] => termdag.app("maybe-none".into(), vec![]), + [value] => termdag.app("maybe-some".into(), vec![*value]), + _ => panic!("Maybe sort expected at most one element"), + } + } + + fn serialized_name(&self, container_values: &ContainerValues, value: Value) -> String { + let maybe = container_values.get_val::(value).unwrap(); + if maybe.data.is_some() { + "maybe-some".to_owned() + } else { + "maybe-none".to_owned() + } + } +} + +pub fn maybe_sorts(type_info: &TypeInfo) -> Vec<(ArcSort, ArcSort)> { + type_info + .get_arcsorts_by(|sort| sort.value_type() == Some(TypeId::of::())) + .into_iter() + .filter_map(|sort| { + let inner_sorts = sort.inner_sorts(); + let [element] = inner_sorts.as_slice() else { + return None; + }; + Some((sort, element.clone())) + }) + .collect() +} + +fn validate_maybe_f64_merge_with_tol(termdag: &mut TermDag, args: &[TermId]) -> Option { + let [old, new, tol] = args else { + return None; + }; + match (maybe_f64(termdag, *old)?, maybe_f64(termdag, *new)?) { + (None, _) | (_, None) => Some(termdag.app("maybe-none".into(), vec![])), + (Some(old_f), Some(new_f)) => { + let Term::Lit(Literal::Float(tolerance)) = termdag.get(*tol) else { + return None; + }; + maybe_f64_values_merge_with_tol(old_f, new_f, tolerance.0).then_some(*old) + } + } +} + +fn maybe_f64_values_merge_with_tol(old_f: f64, new_f: f64, tolerance: f64) -> bool { + let tolerance = tolerance.abs(); + old_f == new_f + || (old_f == 0.0 && new_f == -0.0) + || (old_f == -0.0 && new_f == 0.0) + || (old_f - new_f).abs() <= tolerance +} + +fn maybe_f64(termdag: &TermDag, term: TermId) -> Option> { + match termdag.get(term) { + Term::App(head, children) if head == "maybe-none" && children.is_empty() => Some(None), + Term::App(head, children) if head == "maybe-some" && children.len() == 1 => { + match termdag.get(children[0]) { + Term::Lit(Literal::Float(value)) => Some(Some(value.0)), + _ => None, + } + } + _ => None, + } +} diff --git a/egglog-experimental/src/set_cost.rs b/egglog-experimental/src/set_cost.rs index 20f3e5a..8b472c0 100644 --- a/egglog-experimental/src/set_cost.rs +++ b/egglog-experimental/src/set_cost.rs @@ -1,6 +1,6 @@ use crate::Error; use egglog::{ - CommandOutput, EGraph, TermDag, TermId, UserDefinedCommand, + CommandOutput, EGraph, Enode, RawValues, Read, TermDag, TermId, UserDefinedCommand, ast::*, extract::{CostModel, DefaultCost, Extractor, TreeAdditiveCostModel}, span, @@ -196,13 +196,12 @@ impl CostModel for DynamicCostModel { &self, egraph: &EGraph, func: &egglog::Function, - row: &egglog::Enode<'_>, + enode: &Enode<'_>, ) -> DefaultCost { let name = get_cost_table_name(func.name()); - let key = row.children; if egraph.get_function(&name).is_some() { egraph - .read(|state| egglog::Read::lookup(&state, &name, egglog::RawValues(key.to_vec()))) + .read(|state| state.lookup(&name, RawValues(enode.children.to_vec()))) .ok() .flatten() .map(|c| { @@ -210,9 +209,9 @@ impl CostModel for DynamicCostModel { assert!(cost >= 0); cost as DefaultCost }) - .unwrap_or_else(|| TreeAdditiveCostModel {}.enode_cost(egraph, func, row)) + .unwrap_or_else(|| TreeAdditiveCostModel {}.enode_cost(egraph, func, enode)) } else { - TreeAdditiveCostModel {}.enode_cost(egraph, func, row) + TreeAdditiveCostModel {}.enode_cost(egraph, func, enode) } } } diff --git a/egglog-experimental/tests/eggcc_2mm_proof.rs b/egglog-experimental/tests/eggcc_2mm_proof.rs new file mode 100644 index 0000000..fd4ab57 --- /dev/null +++ b/egglog-experimental/tests/eggcc_2mm_proof.rs @@ -0,0 +1,81 @@ +use std::path::Path; +use std::process::Command; + +fn read_fixture(fixture_name: &str) -> (std::path::PathBuf, String) { + let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR")); + let fixture = manifest_dir.join("tests/fixtures").join(fixture_name); + let program = std::fs::read_to_string(&fixture).expect("read eggcc 2mm fixture"); + (fixture, program) +} + +fn run_fixture_with_proofs(fixture_name: &str) -> String { + let (fixture, program) = read_fixture(fixture_name); + let output = Command::new(env!("CARGO_BIN_EXE_egglog-experimental")) + .arg("--proofs") + .arg(&fixture) + .output() + .expect("run egglog-experimental --proofs on eggcc 2mm fixture"); + + assert!( + output.status.success(), + "egglog-experimental --proofs failed with status {:?}\nstdout:\n{}\nstderr:\n{}", + output.status.code(), + String::from_utf8_lossy(&output.stdout), + String::from_utf8_lossy(&output.stderr) + ); + + program +} + +#[test] +fn eggcc_2mm_full_export_uses_container_helpers() { + let (_fixture, program) = read_fixture("eggcc-2mm-pass1-merge-old.egg"); + + let non_comment_program = program + .lines() + .filter(|line| !line.trim_start().starts_with(';')) + .collect::>() + .join("\n"); + + for required in [ + "pair-min-by-second-i64", + "maybe-either-i64-bool-min", + "maybe-either-i64-bool-max", + "maybe-some", + "either-left", + "either-right", + "either-unwrap-left", + "either-unwrap-right", + "(check (FunctionHasType \"main\"", + ] { + assert!( + non_comment_program.contains(required), + "fixture should exercise {required}" + ); + } + + for required in [ + "https://github.com/egraphs-good/eggcc/pull/796", + "https://github.com/egraphs-good/egglog-experimental/pull/56", + ] { + assert!( + program.contains(required), + "fixture should document {required}" + ); + } + + assert!( + !non_comment_program.contains(":no-merge"), + "full eggcc export should not use :no-merge declarations" + ); + assert!( + program.contains(":merge old"), + "full eggcc export should pin former no-merge functions to :merge old" + ); +} + +#[test] +#[ignore = "full eggcc proof canary is too slow for default debug-profile CI"] +fn eggcc_2mm_full_export_runs_with_proofs() { + run_fixture_with_proofs("eggcc-2mm-pass1-merge-old.egg"); +} diff --git a/egglog-experimental/tests/files.rs b/egglog-experimental/tests/files.rs index 1b8fb9d..7bd359f 100644 --- a/egglog-experimental/tests/files.rs +++ b/egglog-experimental/tests/files.rs @@ -1,26 +1,57 @@ -use std::path::PathBuf; +use std::{ + collections::HashSet, + path::{Path, PathBuf}, +}; use egglog::ast::sanitize_internal_names; use egglog_experimental::*; use libtest_mimic::Trial; +const PROOF_INTEGRATION_FILES: &[&str] = &["tests/fixtures/eggcc-2mm-pass1-merge-old.egg"]; + #[derive(Clone)] struct Run { path: PathBuf, desugar: bool, + proofs: bool, + proof_testing: bool, } impl Run { + fn requires_proofs(&self) -> bool { + self.path.parent().unwrap().ends_with("proofs") + } + + fn is_proof_mode_trial(&self) -> bool { + self.proofs || self.proof_testing + } + + fn is_curated_proof_integration(&self) -> bool { + PROOF_INTEGRATION_FILES + .iter() + .any(|file| self.path.ends_with(file)) + } + + fn proof_filter_prefix(&self) -> Option<&'static str> { + if self.requires_proofs() && self.is_proof_mode_trial() { + Some("proof_unit") + } else if self.is_curated_proof_integration() && self.proof_testing { + Some("proof_integration") + } else { + None + } + } + fn run(&self) { let program = std::fs::read_to_string(&self.path) .unwrap_or_else(|err| panic!("Couldn't read {:?}: {:?}", self.path, err)); - if !self.desugar { + let result = if !self.desugar { self.test_program( self.path.to_str().map(String::from), &program, "Top level error", - ); + ) } else { let mut egraph = new_experimental_egraph(); let resolved = egraph @@ -36,12 +67,41 @@ impl Run { None, &desugared_str, "ERROR after parse, to_string, and parse again.", - ); + ) + }; + + if self.is_proof_mode_trial() { + match result { + Ok(outputs) => { + let snapshot = CommandOutput::snapshot_proofs_only(&outputs); + if !snapshot.is_empty() { + insta::assert_snapshot!(self.snapshot_name(), snapshot); + } + } + Err(err_msg) => { + panic!("proof fixture failed: {err_msg}"); + } + } } } - fn test_program(&self, filename: Option, program: &str, message: &str) { - let mut egraph = new_experimental_egraph(); + fn egraph(&self) -> EGraph { + if self.proof_testing { + new_experimental_egraph_with_proof_testing() + } else if self.proofs { + new_experimental_egraph_with_proofs() + } else { + new_experimental_egraph() + } + } + + fn test_program( + &self, + filename: Option, + program: &str, + message: &str, + ) -> Result, String> { + let mut egraph = self.egraph(); match egraph.parse_and_run_program(filename, program) { Ok(outputs) => { if self.should_fail() { @@ -54,8 +114,10 @@ impl Run { .join("\n") ); } else { - for output in outputs { - print!(" {}", output); + if !self.is_proof_mode_trial() { + for output in &outputs { + print!(" {output}"); + } } // Test graphviz dot generation let mut serialized = egraph @@ -70,14 +132,17 @@ impl Run { serialized.split_classes(|id, _| egraph.from_node_id(id).is_primitive()); serialized.inline_leaves(); serialized.to_dot(); + + Ok(outputs) } } Err(err) => { if !self.should_fail() { panic!("{}: {err}", message) } + Err(err.to_string()) } - }; + } } fn into_trial(self) -> Trial { @@ -92,18 +157,34 @@ impl Run { struct Wrapper<'a>(&'a Run); impl std::fmt::Display for Wrapper<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + if let Some(prefix) = self.0.proof_filter_prefix() { + write!(f, "{prefix}/")?; + } let stem = self.0.path.file_stem().unwrap(); let stem_str = stem.to_string_lossy().replace(['.', '-', ' '], "_"); write!(f, "{stem_str}")?; if self.0.desugar { write!(f, "_resugar")?; } + if self.0.proofs { + write!(f, "_proofs")?; + } + if self.0.proof_testing { + write!(f, "_proof_testing")?; + } Ok(()) } } Wrapper(self) } + fn snapshot_name(&self) -> String { + let prefix = self.proof_filter_prefix().unwrap_or("proof"); + let stem = self.path.file_stem().unwrap(); + let stem_str = stem.to_string_lossy().replace(['.', '-', ' '], "_"); + format!("{prefix}_{stem_str}") + } + fn should_fail(&self) -> bool { self.path.to_string_lossy().contains("fail-typecheck") } @@ -115,14 +196,30 @@ fn generate_tests(glob: &str) -> Vec { let skipped_files = ["math-backoff.egg"]; for entry in glob::glob(glob).unwrap() { + let path = entry.unwrap(); + if path + .components() + .any(|component| component.as_os_str() == "fixtures") + { + continue; + } + let run = Run { - path: entry.unwrap().clone(), + path: path.clone(), desugar: false, + proofs: false, + proof_testing: false, }; if skipped_files.iter().any(|file| run.path.ends_with(file)) { continue; } - // let should_fail = run.should_fail(); + if run.requires_proofs() { + push_trial(Run { + proofs: true, + ..run.clone() + }); + continue; + } push_trial(run.clone()); @@ -135,11 +232,27 @@ fn generate_tests(glob: &str) -> Vec { // } } + for file in PROOF_INTEGRATION_FILES { + push_trial(Run { + path: Path::new(file).into(), + desugar: false, + proofs: false, + proof_testing: true, + }); + } + trials } fn main() { let args = libtest_mimic::Arguments::from_args(); let tests = generate_tests("tests/**/*.egg"); + let mut names = HashSet::new(); + for test in &tests { + let name = test.name().to_string(); + if !names.insert(name.clone()) { + panic!("Duplicate test name: {name}"); + } + } libtest_mimic::run(&args, tests).exit(); } diff --git a/egglog-experimental/tests/fixtures/eggcc-2mm-pass1-merge-old.egg b/egglog-experimental/tests/fixtures/eggcc-2mm-pass1-merge-old.egg new file mode 100644 index 0000000..3e914af --- /dev/null +++ b/egglog-experimental/tests/fixtures/eggcc-2mm-pass1-merge-old.egg @@ -0,0 +1,4511 @@ +; Generated from the 2mm pass-1 eggcc export built while preparing +; egraphs-good/eggcc#796 (https://github.com/egraphs-good/eggcc/pull/796). +; The fixture was checked into egraphs-good/egglog-experimental#56 +; (https://github.com/egraphs-good/egglog-experimental/pull/56) with former +; :no-merge functions represented as :merge old for proof-mode compatibility. + +; Prologue +(datatype Expr) +(datatype ListExpr (Cons Expr ListExpr) (Nil)) +(sort TypeList) +(datatype BaseType (IntT) (BoolT) (FloatT) (PointerT BaseType) (StateT)) +(datatype Type (Base BaseType) (TupleT TypeList)) +(constructor TmpType () Type) +(constructor TNil () TypeList) +(constructor TCons (BaseType TypeList) TypeList) +(datatype Assumption (InFunc String) (InLoop Expr Expr) (InSwitch i64 Expr Expr) (InIf bool Expr Expr)) +(constructor Arg (Type Assumption) Expr) +(datatype Constant (Int i64) (Bool bool) (Float f64)) +(constructor Const (Constant Type Assumption) Expr) +(constructor Empty (Type Assumption) Expr) +(datatype TernaryOp (Write) (Select)) +(datatype BinaryOp (Bitand) (Add) (Sub) (Div) (Mul) (LessThan) (GreaterThan) (LessEq) (GreaterEq) (Eq) (Smin) (Smax) (Shl) (Shr) (FAdd) (FSub) (FDiv) (FMul) (FLessThan) (FGreaterThan) (FLessEq) (FGreaterEq) (FEq) (Fmin) (Fmax) (And) (Or) (Load) (PtrAdd) (Print) (Free)) +(datatype UnaryOp (Neg) (Abs) (Not)) +(constructor Top (TernaryOp Expr Expr Expr) Expr) +(constructor Bop (BinaryOp Expr Expr) Expr) +(constructor Uop (UnaryOp Expr) Expr) +(constructor Get (Expr i64) Expr) +(constructor Alloc (i64 Expr Expr BaseType) Expr) +(constructor Call (String Expr) Expr) +(constructor Single (Expr) Expr) +(constructor Concat (Expr Expr) Expr) +(constructor Switch (Expr Expr ListExpr) Expr) +(constructor If (Expr Expr Expr Expr) Expr) +(constructor DoWhile (Expr Expr) Expr) +(sort ProgramType) +(constructor Program (Expr ListExpr) ProgramType) +(constructor Function (String Type Type Expr) Expr) +(relation FunctionHasType (String Type Type)) +(ruleset always-run) +(ruleset is-resolved) +(ruleset error-checking) +(ruleset memory) +(ruleset memory-helpers) +(ruleset smem) +(relation bop->string (BinaryOp String)) +(relation uop->string (UnaryOp String)) +(relation top->string (TernaryOp String)) +(bop->string (Add) "Add") +(bop->string (Sub) "Sub") +(bop->string (Div) "Div") +(bop->string (Mul) "Mul") +(bop->string (LessThan) "LessThan") +(bop->string (GreaterThan) "GreaterThan") +(bop->string (LessEq) "LessEq") +(bop->string (GreaterEq) "GreaterEq") +(bop->string (Eq) "Eq") +(bop->string (FAdd) "FAdd") +(bop->string (FSub) "FSub") +(bop->string (FDiv) "FDiv") +(bop->string (FMul) "FMul") +(bop->string (FLessThan) "FLessThan") +(bop->string (FGreaterThan) "FGreaterThan") +(bop->string (FLessEq) "FLessEq") +(bop->string (FGreaterEq) "FGreaterEq") +(bop->string (FEq) "FEq") +(bop->string (And) "And") +(bop->string (Or) "Or") +(bop->string (Load) "Load") +(bop->string (PtrAdd) "PtrAdd") +(bop->string (Print) "Print") +(bop->string (Free) "Free") +(relation DebugExpr (Expr)) +(datatype Term) +(datatype ListTerm (TermCons Term ListTerm) (TermNil)) +(constructor TermArg () Term) +(constructor TermConst (Constant) Term) +(constructor TermEmpty () Term) +(constructor TermTop (TernaryOp Term Term Term) Term) +(constructor TermBop (BinaryOp Term Term) Term) +(constructor TermUop (UnaryOp Term) Term) +(constructor TermGet (Term i64) Term) +(constructor TermAlloc (i64 Term Term BaseType) Term) +(constructor TermCall (String Term) Term) +(constructor TermSingle (Term) Term) +(constructor TermConcat (Term Term) Term) +(function LoopNumItersGuess (Expr Expr) i64 :merge (max 1 (min old new))) +(relation LoopIsFinite (Expr Expr)) +(relation RELIESONCONTEXT ()) +(let DUMMYCTX (InFunc "DUMMY")) +(ruleset never) +(ruleset type-analysis) +(ruleset type-helpers) +(constructor TLConcat (TypeList TypeList) TypeList :unextractable) +(rewrite (TLConcat (TNil) r) r :ruleset type-helpers) +(rewrite (TLConcat (TCons hd tl) r) (TCons hd (TLConcat tl r)) :ruleset type-helpers) +(function TypeList-length (TypeList) i64 :merge old) +(constructor TypeList-ith (TypeList i64) BaseType :unextractable) +(rule () ((set (TypeList-length (TNil)) 0)) :ruleset type-helpers) +(rule ((= lst (TCons hd tl)) (= len (TypeList-length tl))) ((set (TypeList-length lst) (+ 1 len))) :ruleset type-helpers) +(rewrite (TypeList-ith (TCons hd tl) 0) hd :ruleset type-helpers) +(rewrite (TypeList-ith (TCons hd tl) i) (TypeList-ith tl (- i 1)) :when ((> i 0)) :ruleset type-helpers) +(rule ((TypeList-ith list i) (= (TypeList-length list) n) (>= i n)) ((panic "TypeList-ith out of bounds")) :ruleset type-helpers) +(relation HasType (Expr Type)) +(relation ExpectType (Expr Type String)) +(rule ((ExpectType e expected msg) (HasType e actual) (!= expected actual)) ((panic "type mismatch- check RUST_LOG=info for expressions that mismatched")) :ruleset error-checking) +(rule ((= (Const c1 ty1 ctx1) (Const c2 ty2 ctx2)) (= ctx1 (InFunc name)) (!= c1 c2)) ((panic "Unsoundness detected: const values differ at top level")) :ruleset error-checking) +(relation HasArgType (Expr Type)) +(rule ((HasArgType (Arg t1 ctx) t2) (!= t1 t2)) ((panic "arg type mismatch")) :ruleset error-checking) +(rule ((= lhs (Function name in out body)) (HasArgType body ty) (HasArgType body ty2) (!= ty ty2)) ((panic "arg type mismatch in function")) :ruleset error-checking) +(rule ((= lhs (Uop _ e)) (HasArgType e ty)) ((HasArgType lhs ty)) :ruleset type-analysis) +(rule ((= lhs (Bop _ a b)) (HasArgType a ty)) ((HasArgType lhs ty)) :ruleset type-analysis) +(rule ((= lhs (Bop _ a b)) (HasArgType b ty)) ((HasArgType lhs ty)) :ruleset type-analysis) +(rule ((= lhs (Top _ a b c)) (HasArgType a ty)) ((HasArgType lhs ty)) :ruleset type-analysis) +(rule ((= lhs (Top _ a b c)) (HasArgType b ty)) ((HasArgType lhs ty)) :ruleset type-analysis) +(rule ((= lhs (Top _ a b c)) (HasArgType c ty)) ((HasArgType lhs ty)) :ruleset type-analysis) +(rule ((= lhs (Get e _)) (HasArgType e ty)) ((HasArgType lhs ty)) :ruleset type-analysis) +(rule ((= lhs (Alloc _id e state _)) (HasArgType e ty)) ((HasArgType lhs ty)) :ruleset type-analysis) +(rule ((= lhs (Call _ e)) (HasArgType e ty)) ((HasArgType lhs ty)) :ruleset type-analysis) +(rule ((= lhs (Single e)) (HasArgType e ty)) ((HasArgType lhs ty)) :ruleset type-analysis) +(rule ((= lhs (Concat e1 e2)) (HasArgType e1 ty)) ((HasArgType lhs ty)) :ruleset type-analysis) +(rule ((= lhs (Concat e1 e2)) (HasArgType e2 ty)) ((HasArgType lhs ty)) :ruleset type-analysis) +(rule ((= lhs (Switch pred inputs (Cons branch rest))) (HasArgType pred ty)) ((HasArgType lhs ty)) :ruleset type-analysis) +(rule ((= lhs (Switch pred inputs (Cons branch rest))) (HasArgType branch ty) (HasType inputs ty2) (!= ty ty2)) ((panic "switch branches then branch has incorrect input type")) :ruleset error-checking) +(rule ((= lhs (Switch pred inputs (Cons branch rest)))) ((Switch pred inputs rest)) :ruleset type-analysis) +(rule ((= lhs (If c i t e)) (HasArgType c ty)) ((HasArgType lhs ty)) :ruleset type-analysis) +(rule ((= lhs (If c i t e)) (HasType i ty) (HasArgType t ty2) (!= ty ty2)) ((panic "if branches then branch has incorrect input type")) :ruleset error-checking) +(rule ((= lhs (If c i t e)) (HasType i ty) (HasArgType e ty2) (!= ty ty2)) ((panic "if branches else branch has incorrect input type")) :ruleset error-checking) +(rule ((= lhs (DoWhile ins body)) (HasArgType ins ty)) ((HasArgType lhs ty)) :ruleset type-analysis) +(rule ((= lhs (Const (Int i) ty ctx))) ((HasType lhs (Base (IntT))) (HasArgType lhs ty)) :ruleset type-analysis) +(rule ((= lhs (Const (Bool b) ty ctx))) ((HasType lhs (Base (BoolT))) (HasArgType lhs ty)) :ruleset type-analysis) +(rule ((= lhs (Const (Float b) ty ctx))) ((HasType lhs (Base (FloatT))) (HasArgType lhs ty)) :ruleset type-analysis) +(rule ((= lhs (Empty ty ctx))) ((HasType lhs (TupleT (TNil))) (HasArgType lhs ty)) :ruleset type-analysis) +(rule ((= lhs (Uop (Not) e)) (HasType e (Base (BoolT)))) ((HasType lhs (Base (BoolT)))) :ruleset type-analysis) +(rule ((= lhs (Uop (Not) e))) ((ExpectType e (Base (BoolT)) "(Not)")) :ruleset type-analysis) +(rule ((= lhs (Uop (Neg) e)) (HasType e (Base (IntT)))) ((HasType lhs (Base (IntT)))) :ruleset type-analysis) +(rule ((= lhs (Uop (Neg) e))) ((ExpectType e (Base (IntT)) "(Neg)")) :ruleset type-analysis) +(rule ((= lhs (Uop (Abs) e)) (HasType e (Base (IntT)))) ((HasType lhs (Base (IntT)))) :ruleset type-analysis) +(rule ((= lhs (Uop (Abs) e))) ((ExpectType e (Base (IntT)) "(Abs)")) :ruleset type-analysis) +(rule ((= lhs (Bop (Print) e state)) (HasType e _ty)) ((HasType lhs (Base (StateT)))) :ruleset type-analysis) +(rule ((= lhs (Bop (Print) e state)) (HasType e (TupleT ty))) ((panic "Don't print a tuple")) :ruleset error-checking) +(rule ((= lhs (Bop (Free) e s)) (HasType e (Base (PointerT _ty)))) ((HasType lhs (Base (StateT)))) :ruleset type-analysis) +(rule ((= lhs (Bop (Free) e s)) (HasType e (Base (IntT)))) ((panic "Free expected pointer, received integer")) :ruleset error-checking) +(rule ((= lhs (Bop (Free) e s)) (HasType e (TupleT _ty))) ((panic "Free expected pointer, received tuple")) :ruleset error-checking) +(rule ((= lhs (Bop (Load) e state)) (HasType e (Base (PointerT ty)))) ((HasType lhs (TupleT (TCons ty (TCons (StateT) (TNil)))))) :ruleset type-analysis) +(rule ((= lhs (Bop (Load) e state)) (HasType e ty) (= ty (Base (IntT)))) ((panic "(Load) expected pointer, received int")) :ruleset error-checking) +(rule ((= lhs (Bop (Load) e state)) (HasType e ty) (= ty (TupleT x))) ((panic "(Load) expected pointer, received tuple")) :ruleset error-checking) +(rule ((= lhs (Top (Select) pred v1 v2))) ((ExpectType pred (Base (BoolT)) "(Select)")) :ruleset type-analysis) +(rule ((= lhs (Top (Select) pred v1 v2)) (HasType v1 ty) (HasType v2 ty)) ((HasType lhs ty)) :ruleset type-analysis) +(rule ((= lhs (Top (Select) pred v1 v2)) (HasType v1 ty1) (HasType v2 ty2) (!= ty1 ty2)) ((panic "(Select) branches had different types")) :ruleset error-checking) +(relation bop-of-type (BinaryOp Type)) +(bop-of-type (Bitand) (Base (IntT))) +(bop-of-type (Add) (Base (IntT))) +(bop-of-type (Sub) (Base (IntT))) +(bop-of-type (Div) (Base (IntT))) +(bop-of-type (Mul) (Base (IntT))) +(bop-of-type (Smax) (Base (IntT))) +(bop-of-type (Smin) (Base (IntT))) +(bop-of-type (FAdd) (Base (FloatT))) +(bop-of-type (FSub) (Base (FloatT))) +(bop-of-type (FDiv) (Base (FloatT))) +(bop-of-type (FMul) (Base (FloatT))) +(bop-of-type (Fmax) (Base (FloatT))) +(bop-of-type (Fmin) (Base (FloatT))) +(rule ((= lhs (Bop op e1 e2)) (bop-of-type op ty) (HasType e1 ty) (HasType e2 ty)) ((HasType lhs ty)) :ruleset type-analysis) +(rule ((= lhs (Bop op e1 e2)) (bop-of-type op ty) (bop->string op op-str)) ((ExpectType e1 ty op-str) (ExpectType e2 ty op-str)) :ruleset type-analysis) +(relation bpred-of-type (BinaryOp Type)) +(bpred-of-type (FLessThan) (Base (FloatT))) +(bpred-of-type (FLessEq) (Base (FloatT))) +(bpred-of-type (FGreaterThan) (Base (FloatT))) +(bpred-of-type (FGreaterEq) (Base (FloatT))) +(bpred-of-type (FEq) (Base (FloatT))) +(bpred-of-type (LessThan) (Base (IntT))) +(bpred-of-type (LessEq) (Base (IntT))) +(bpred-of-type (GreaterThan) (Base (IntT))) +(bpred-of-type (GreaterEq) (Base (IntT))) +(bpred-of-type (Eq) (Base (IntT))) +(bpred-of-type (And) (Base (BoolT))) +(bpred-of-type (Or) (Base (BoolT))) +(rule ((= lhs (Bop pred e1 e2)) (bpred-of-type pred ty) (HasType e1 ty) (HasType e2 ty)) ((HasType lhs (Base (BoolT)))) :ruleset type-analysis) +(rule ((= lhs (Bop pred e1 e2)) (bpred-of-type pred ty) (bop->string pred pred-str)) ((ExpectType e1 ty pred-str) (ExpectType e2 ty pred-str)) :ruleset type-analysis) +(rule ((= lhs (Top (Write) ptr val state)) (HasType ptr (Base (PointerT ty))) (HasType val (Base ty))) ((HasType lhs (Base (StateT)))) :ruleset type-analysis) +(rule ((= lhs (Top (Write) ptr val state)) (HasType ptr (Base (PointerT ty)))) ((ExpectType val (Base ty) "(Write)")) :ruleset type-analysis) +(rule ((= lhs (Bop (PtrAdd) ptr n)) (HasType ptr (Base (PointerT ty))) (HasType n (Base (IntT)))) ((HasType lhs (Base (PointerT ty)))) :ruleset type-analysis) +(rule ((= lhs (Alloc _id amt state ty))) ((ExpectType amt (Base (IntT)) "(Alloc)")) :ruleset type-analysis) +(rule ((= lhs (Alloc _id amt state ty)) (HasType amt (Base (IntT)))) ((HasType lhs (TupleT (TCons ty (TCons (StateT) (TNil)))))) :ruleset type-analysis) +(rule ((= lhs (Get e i)) (HasType e (TupleT tylist))) ((HasType lhs (Base (TypeList-ith tylist i)))) :ruleset type-analysis) +(rule ((HasType (Get expr i) (TupleT tl)) (= (TypeList-length tl) len) (>= i len)) ((panic "index out of bounds")) :ruleset error-checking) +(rule ((HasType (Get expr i) (TupleT tl)) (= (TypeList-length tl) len) (< i 0)) ((panic "negative index")) :ruleset error-checking) +(rule ((= lhs (Single e)) (HasType e (TupleT tylist))) ((panic "don't nest tuples")) :ruleset error-checking) +(rule ((= lhs (Single e)) (HasType e (Base basety))) ((HasType lhs (TupleT (TCons basety (TNil))))) :ruleset type-analysis) +(rule ((= lhs (Concat e1 e2)) (HasType e1 (TupleT tylist1)) (HasType e2 (TupleT tylist2))) ((HasType lhs (TupleT (TLConcat tylist1 tylist2)))) :ruleset type-analysis) +(rule ((= lhs (If pred inputs then else))) ((ExpectType pred (Base (BoolT)) "If predicate must be boolean")) :ruleset type-analysis) +(rule ((= lhs (If pred inputs then else)) (HasType pred (Base (BoolT))) (HasType then ty) (HasType else ty)) ((HasType lhs ty)) :ruleset type-analysis) +(rule ((= lhs (If pred inputs then else)) (HasType pred (Base (BoolT))) (HasType then tya) (HasType else tyb) (!= tya tyb)) ((panic "if branches had different types")) :ruleset error-checking) +(rule ((= lhs (Switch pred inputs branches))) ((ExpectType pred (Base (IntT)) "Switch predicate must be integer")) :ruleset type-analysis) +(rule ((= lhs (Switch pred inputs (Cons branch (Nil)))) (HasType pred (Base (IntT))) (HasType branch ty)) ((HasType lhs ty)) :ruleset type-analysis) +(rule ((Switch pred inputs (Cons branch rest))) ((Switch pred inputs rest)) :ruleset type-analysis) +(rule ((= lhs (Switch pred inputs (Cons branch rest))) (HasType pred (Base (IntT))) (HasType branch ty) (HasType (Switch pred inputs rest) ty)) ((HasType lhs ty)) :ruleset type-analysis) +(rule ((= lhs (Switch pred inputs (Cons branch rest))) (HasType pred (Base (IntT))) (HasType branch tya) (HasType (Switch pred inputs rest) tyb) (!= tya tyb)) ((panic "switch branches had different types")) :ruleset error-checking) +(rule ((Arg ty ctx)) ((HasType (Arg ty ctx) ty) (HasArgType (Arg ty ctx) ty)) :ruleset type-analysis) +(rule ((= lhs (DoWhile inp pred-body)) (HasType inp (Base ty))) ((panic "loop input must be tuple")) :ruleset error-checking) +(rule ((= lhs (DoWhile inp pred-body)) (HasType inp (Base (PointerT ty)))) ((panic "loop input must be tuple")) :ruleset error-checking) +(rule ((= lhs (DoWhile inp pred-body)) (HasType pred-body (Base ty))) ((panic "loop pred-body must be tuple")) :ruleset error-checking) +(rule ((= lhs (DoWhile inp pred-body)) (HasType pred-body (Base (PointerT ty)))) ((panic "loop pred-body must be tuple")) :ruleset error-checking) +(rule ((= lhs (DoWhile inp pred-body)) (HasType inp (TupleT tylist))) ((HasArgType pred-body (TupleT tylist))) :ruleset type-analysis) +(rule ((= lhs (DoWhile inp pred-body))) ((ExpectType (Get pred-body 0) (Base (BoolT)) "loop pred must be bool")) :ruleset type-analysis) +(rule ((= lhs (DoWhile inp pred-body)) (HasType inp (TupleT tylist)) (HasType pred-body (TupleT (TCons (BoolT) tylist)))) ((HasType lhs (TupleT tylist))) :ruleset type-analysis) +(rule ((= lhs (DoWhile inp pred-body)) (HasType inp (TupleT in-tys)) (HasType pred-body (TupleT (TCons (BoolT) out-tys))) (!= in-tys out-tys)) ((panic "input types and output types don't match")) :ruleset error-checking) +(rule ((= lhs (Function name in-ty out-ty body))) ((HasArgType body in-ty) (ExpectType body out-ty "Function body had wrong type")) :ruleset type-analysis) +(rule ((= lhs (Call name arg)) (FunctionHasType name in-ty out-ty)) ((ExpectType arg in-ty "function called with wrong arg type")) :ruleset type-analysis) +(rule ((= lhs (Call name arg)) (FunctionHasType name in-ty out-ty) (HasType arg in-ty)) ((HasType lhs out-ty)) :ruleset type-analysis) +(relation PureBaseType (BaseType)) +(relation PureType (Type)) +(relation PureTypeList (TypeList)) +(PureBaseType (IntT)) +(PureBaseType (BoolT)) +(rule ((Base ty) (PureBaseType ty)) ((PureType (Base ty))) :ruleset type-analysis) +(rule ((TupleT tylist) (PureTypeList tylist)) ((PureType (TupleT tylist))) :ruleset type-analysis) +(rule ((TNil)) ((PureTypeList (TNil))) :ruleset type-analysis) +(rule ((TCons hd tl) (PureBaseType hd) (PureTypeList tl)) ((PureTypeList (TCons hd tl))) :ruleset type-analysis) +(function ListExpr-length (ListExpr) i64 :merge old) +(constructor ListExpr-ith (ListExpr i64) Expr :unextractable) +(constructor ListExpr-suffix (ListExpr i64) ListExpr :unextractable) +(constructor Append (ListExpr Expr) ListExpr :unextractable) +(rule ((Switch pred inputs branch)) ((union (ListExpr-suffix branch 0) branch)) :ruleset always-run) +(rule ((= (ListExpr-suffix top n) (Cons hd tl))) ((union (ListExpr-ith top n) hd) (union (ListExpr-suffix top (+ n 1)) tl)) :ruleset always-run) +(rule ((= (ListExpr-suffix list n) (Nil))) ((set (ListExpr-length list) n)) :ruleset always-run) +(rewrite (Append (Cons a b) e) (Cons a (Append b e)) :ruleset always-run) +(rewrite (Append (Nil) e) (Cons e (Nil)) :ruleset always-run) +(function tuple-length (Expr) i64 :merge old) +(rule ((HasType expr (TupleT tl)) (= len (TypeList-length tl))) ((set (tuple-length expr) len)) :ruleset always-run) +(relation leading-Expr (Expr)) +(relation leading-Expr-list (ListExpr)) +(rule ((= e (DoWhile inputs pred_out))) ((leading-Expr e) (leading-Expr inputs) (leading-Expr pred_out)) :ruleset always-run) +(rule ((= e (If cond inputs thn els))) ((leading-Expr e) (leading-Expr inputs) (leading-Expr thn) (leading-Expr els)) :ruleset always-run) +(rule ((= e (Switch pred inputs branch))) ((leading-Expr e) (leading-Expr-list branch) (leading-Expr inputs)) :ruleset always-run) +(rule ((leading-Expr-list (Cons hd tl))) ((leading-Expr hd) (leading-Expr-list tl)) :ruleset always-run) +(rule ((= e (Arg t a))) ((leading-Expr e)) :ruleset always-run) +(rule ((Single expr)) ((union (Get (Single expr) 0) expr)) :ruleset always-run) +(rule ((leading-Expr tuple) (> (tuple-length tuple) 0)) ((Get tuple 0)) :ruleset always-run) +(rule ((leading-Expr tuple) (= len (tuple-length tuple)) (= ith (Get tuple i)) (< (+ i 1) len)) ((Get tuple (+ 1 i))) :ruleset always-run) +(relation Add-Gets (Expr Expr i64)) +(rule ((Get x i)) ((Add-Gets x x 0)) :ruleset always-run) +(rule ((Add-Gets orig (Concat left right) n) (= len (tuple-length left))) ((Add-Gets orig left n) (Add-Gets orig right (+ n len))) :ruleset always-run) +(rule ((Add-Gets orig (Single e) n)) ((union (Get orig n) e)) :ruleset always-run) +(relation Not-Just-Concat (Expr)) +(relation Add-All-Gets (Expr Expr i64 i64)) +(rule ((Add-Gets orig something n) (Not-Just-Concat something)) ((Add-All-Gets orig something n 0)) :ruleset always-run) +(rule ((Add-All-Gets orig something offset pos) (< pos (tuple-length something))) ((union (Get orig (+ offset pos)) (Get something pos)) (Add-All-Gets orig something offset (+ pos 1))) :ruleset always-run) +(rule ((= lhs (Arg a b))) ((Not-Just-Concat lhs)) :ruleset always-run) +(rule ((= lhs (Top a b c d))) ((Not-Just-Concat lhs)) :ruleset always-run) +(rule ((= lhs (Bop a b c))) ((Not-Just-Concat lhs)) :ruleset always-run) +(rule ((= lhs (Call a b))) ((Not-Just-Concat lhs)) :ruleset always-run) +(rule ((= lhs (Uop a b))) ((Not-Just-Concat lhs)) :ruleset always-run) +(rule ((= lhs (Switch a b c))) ((Not-Just-Concat lhs)) :ruleset always-run) +(rule ((= lhs (If a b c d))) ((Not-Just-Concat lhs)) :ruleset always-run) +(rule ((= lhs (DoWhile a b))) ((Not-Just-Concat lhs)) :ruleset always-run) +(ruleset subsume-after-helpers) +(relation ToSubsumeIf (Expr Expr Expr Expr)) +(rule ((ToSubsumeIf a b c d) (If a b c d)) ((subsume (If a b c d))) :ruleset subsume-after-helpers) +(ruleset add-to-debug-expr) +(ruleset terms) +(ruleset terms-helpers) +(ruleset terms-helpers-helpers) +(sort TermAndCost (Pair Term i64)) +(function ExtractedExpr (Expr) TermAndCost :merge (pair-min-by-second-i64 old new)) +(relation PotentialExtractedExpr (Expr TermAndCost)) +(constructor NoTerm () Term) +(rule ((PotentialExtractedExpr expr termandcost)) ((set (ExtractedExpr expr) (pair (NoTerm) 10000000000000000))) :ruleset terms-helpers) +(rule ((PotentialExtractedExpr expr termandcost) (< (pair-second termandcost) (pair-second (ExtractedExpr expr)))) ((set (ExtractedExpr expr) termandcost)) :ruleset terms-helpers) +(rule ((PotentialExtractedExpr expr termandcost) (< (pair-second termandcost) 0)) ((panic "Negative cost")) :ruleset terms-helpers) +(rule ((= lhs (Const c ty ass))) ((PotentialExtractedExpr lhs (pair (TermConst c) 1))) :ruleset terms) +(rule ((= lhs (Arg ty ass))) ((PotentialExtractedExpr lhs (pair (TermArg) 1))) :ruleset terms) +(rule ((= lhs (Bop o e1 e2)) (= tc1 (ExtractedExpr e1)) (= t1 (pair-first tc1)) (= c1 (pair-second tc1)) (= tc2 (ExtractedExpr e2)) (= t2 (pair-first tc2)) (= c2 (pair-second tc2))) ((PotentialExtractedExpr lhs (pair (TermBop o t1 t2) (+ 1 (+ c1 c2))))) :ruleset terms) +(rule ((= lhs (Top o e1 e2 e3)) (= tc1 (ExtractedExpr e1)) (= t1 (pair-first tc1)) (= c1 (pair-second tc1)) (= tc2 (ExtractedExpr e2)) (= t2 (pair-first tc2)) (= c2 (pair-second tc2)) (= tc3 (ExtractedExpr e3)) (= t3 (pair-first tc3)) (= c3 (pair-second tc3))) ((PotentialExtractedExpr lhs (pair (TermTop o t1 t2 t3) (+ (+ 1 c1) (+ c2 c3))))) :ruleset terms) +(rule ((= lhs (Uop o e1)) (= tc1 (ExtractedExpr e1)) (= t1 (pair-first tc1)) (= c1 (pair-second tc1))) ((PotentialExtractedExpr lhs (pair (TermUop o t1) (+ 1 c1)))) :ruleset terms) +(rule ((= lhs (Get tup i)) (= tc1 (ExtractedExpr tup)) (= t1 (pair-first tc1)) (= c1 (pair-second tc1))) ((PotentialExtractedExpr lhs (pair (TermGet t1 i) c1))) :ruleset terms) +(rule ((= lhs (Single e1)) (= tc1 (ExtractedExpr e1)) (= t1 (pair-first tc1)) (= c1 (pair-second tc1))) ((PotentialExtractedExpr lhs (pair (TermSingle t1) c1))) :ruleset terms) +(rule ((= lhs (Concat e1 e2)) (= tc1 (ExtractedExpr e1)) (= t1 (pair-first tc1)) (= c1 (pair-second tc1)) (= tc2 (ExtractedExpr e2)) (= t2 (pair-first tc2)) (= c2 (pair-second tc2))) ((PotentialExtractedExpr lhs (pair (TermConcat t1 t2) (+ c1 c2)))) :ruleset terms) +(sort Node) +(constructor IfNode (Expr Expr Expr Expr Expr) Node) +(relation ExprIsValid (Expr)) +(relation ListExprIsValid (ListExpr)) +(rule ((ExprIsValid (Function _name _tyin _tyout _out))) ((ExprIsValid _out)) :ruleset always-run) +(rule ((ExprIsValid (Top _op _x _y _z))) ((ExprIsValid _x) (ExprIsValid _y) (ExprIsValid _z)) :ruleset always-run) +(rule ((ExprIsValid (Bop _op _x _y))) ((ExprIsValid _x) (ExprIsValid _y)) :ruleset always-run) +(rule ((ExprIsValid (Uop _op _x))) ((ExprIsValid _x)) :ruleset always-run) +(rule ((ExprIsValid (Get _tup _i))) ((ExprIsValid _tup)) :ruleset always-run) +(rule ((ExprIsValid (Concat _x _y))) ((ExprIsValid _x) (ExprIsValid _y)) :ruleset always-run) +(rule ((ExprIsValid (Single _x))) ((ExprIsValid _x)) :ruleset always-run) +(rule ((ExprIsValid (Switch _pred _inputs _branches))) ((ExprIsValid _pred) (ExprIsValid _inputs) (ListExprIsValid _branches)) :ruleset always-run) +(rule ((ExprIsValid (If _pred _input _then _else))) ((ExprIsValid _pred) (ExprIsValid _input) (ExprIsValid _then) (ExprIsValid _else)) :ruleset always-run) +(rule ((ExprIsValid (DoWhile _in _pred-and-output))) ((ExprIsValid _in) (ExprIsValid _pred-and-output)) :ruleset always-run) +(rule ((ExprIsValid (Call _func _arg))) ((ExprIsValid _arg)) :ruleset always-run) +(rule ((ListExprIsValid (Cons _hd _tl))) ((ExprIsValid _hd) (ListExprIsValid _tl)) :ruleset always-run) +(rule ((ExprIsValid (Alloc _id _e _state _ty))) ((ExprIsValid _e) (ExprIsValid _state)) :ruleset always-run) +(relation ExprIsResolved (Expr)) +(relation ListExprIsResolved (ListExpr)) +(rule ((= lhs (Function _name _tyin _tyout _out)) (ExprIsResolved _out)) ((ExprIsResolved lhs)) :ruleset is-resolved) +(rule ((= lhs (Const _n _ty _ctx))) ((ExprIsResolved lhs)) :ruleset is-resolved) +(rule ((= lhs (Top _op _x _y _z)) (ExprIsResolved _x) (ExprIsResolved _y) (ExprIsResolved _z)) ((ExprIsResolved lhs)) :ruleset is-resolved) +(rule ((= lhs (Bop _op _x _y)) (ExprIsResolved _x) (ExprIsResolved _y)) ((ExprIsResolved lhs)) :ruleset is-resolved) +(rule ((= lhs (Uop _op _x)) (ExprIsResolved _x)) ((ExprIsResolved lhs)) :ruleset is-resolved) +(rule ((= lhs (Get _tup _i)) (ExprIsResolved _tup)) ((ExprIsResolved lhs)) :ruleset is-resolved) +(rule ((= lhs (Concat _x _y)) (ExprIsResolved _x) (ExprIsResolved _y)) ((ExprIsResolved lhs)) :ruleset is-resolved) +(rule ((= lhs (Single _x)) (ExprIsResolved _x)) ((ExprIsResolved lhs)) :ruleset is-resolved) +(rule ((= lhs (Switch _pred _inputs _branches)) (ExprIsResolved _pred) (ExprIsResolved _inputs) (ListExprIsResolved _branches)) ((ExprIsResolved lhs)) :ruleset is-resolved) +(rule ((= lhs (If _pred _input _then _else)) (ExprIsResolved _pred) (ExprIsResolved _input) (ExprIsResolved _then) (ExprIsResolved _else)) ((ExprIsResolved lhs)) :ruleset is-resolved) +(rule ((= lhs (DoWhile _in _pred-and-output)) (ExprIsResolved _in) (ExprIsResolved _pred-and-output)) ((ExprIsResolved lhs)) :ruleset is-resolved) +(rule ((= lhs (Arg _ty _ctx))) ((ExprIsResolved lhs)) :ruleset is-resolved) +(rule ((= lhs (Call _func _arg)) (ExprIsResolved _arg)) ((ExprIsResolved lhs)) :ruleset is-resolved) +(rule ((= lhs (Empty _ty _ctx))) ((ExprIsResolved lhs)) :ruleset is-resolved) +(rule ((= lhs (Cons _hd _tl)) (ExprIsResolved _hd) (ListExprIsResolved _tl)) ((ListExprIsResolved lhs)) :ruleset is-resolved) +(rule ((= lhs (Nil))) ((ListExprIsResolved lhs)) :ruleset is-resolved) +(rule ((= lhs (Alloc _id _e _state _ty)) (ExprIsResolved _e) (ExprIsResolved _state)) ((ExprIsResolved lhs)) :ruleset is-resolved) +(relation BodyContainsExpr (Expr Expr)) +(relation BodyContainsListExpr (Expr ListExpr)) +(rule ((Function _name _tyin _tyout _out)) ((BodyContainsExpr _out _out)) :ruleset always-run) +(rule ((If _pred _input _then _else)) ((BodyContainsExpr _then _then) (BodyContainsExpr _else _else)) :ruleset always-run) +(rule ((DoWhile _in _pred-and-output)) ((BodyContainsExpr _pred-and-output _pred-and-output)) :ruleset always-run) +(rule ((BodyContainsExpr body (Top _op _x _y _z))) ((BodyContainsExpr body _x) (BodyContainsExpr body _y) (BodyContainsExpr body _z)) :ruleset always-run) +(rule ((BodyContainsExpr body (Bop _op _x _y))) ((BodyContainsExpr body _x) (BodyContainsExpr body _y)) :ruleset always-run) +(rule ((BodyContainsExpr body (Uop _op _x))) ((BodyContainsExpr body _x)) :ruleset always-run) +(rule ((BodyContainsExpr body (Get _tup _i))) ((BodyContainsExpr body _tup)) :ruleset always-run) +(rule ((BodyContainsExpr body (Concat _x _y))) ((BodyContainsExpr body _x) (BodyContainsExpr body _y)) :ruleset always-run) +(rule ((BodyContainsExpr body (Single _x))) ((BodyContainsExpr body _x)) :ruleset always-run) +(rule ((BodyContainsExpr body (Switch _pred _inputs _branches))) ((BodyContainsExpr body _pred) (BodyContainsExpr body _inputs)) :ruleset always-run) +(rule ((BodyContainsExpr body (If _pred _input _then _else))) ((BodyContainsExpr body _pred) (BodyContainsExpr body _input)) :ruleset always-run) +(rule ((BodyContainsExpr body (DoWhile _in _pred-and-output))) ((BodyContainsExpr body _in)) :ruleset always-run) +(rule ((BodyContainsExpr body (Call _func _arg))) ((BodyContainsExpr body _arg)) :ruleset always-run) +(rule ((BodyContainsListExpr body (Cons _hd _tl))) ((BodyContainsExpr body _hd)) :ruleset always-run) +(rule ((BodyContainsExpr body (Alloc _id _e _state _ty))) ((BodyContainsExpr body _e) (BodyContainsExpr body _state)) :ruleset always-run) +(relation ExprIsPure (Expr)) +(relation ListExprIsPure (ListExpr)) +(relation BinaryOpIsPure (BinaryOp)) +(relation UnaryOpIsPure (UnaryOp)) +(relation TernaryOpIsPure (TernaryOp)) +(TernaryOpIsPure (Select)) +(BinaryOpIsPure (Add)) +(BinaryOpIsPure (Sub)) +(BinaryOpIsPure (Mul)) +(BinaryOpIsPure (Div)) +(BinaryOpIsPure (Eq)) +(BinaryOpIsPure (LessThan)) +(BinaryOpIsPure (GreaterThan)) +(BinaryOpIsPure (LessEq)) +(BinaryOpIsPure (GreaterEq)) +(BinaryOpIsPure (Smax)) +(BinaryOpIsPure (Smin)) +(BinaryOpIsPure (Shl)) +(BinaryOpIsPure (Shr)) +(BinaryOpIsPure (FAdd)) +(BinaryOpIsPure (FSub)) +(BinaryOpIsPure (FMul)) +(BinaryOpIsPure (FDiv)) +(BinaryOpIsPure (FEq)) +(BinaryOpIsPure (FLessThan)) +(BinaryOpIsPure (FGreaterThan)) +(BinaryOpIsPure (FLessEq)) +(BinaryOpIsPure (FGreaterEq)) +(BinaryOpIsPure (Fmax)) +(BinaryOpIsPure (Fmin)) +(BinaryOpIsPure (And)) +(BinaryOpIsPure (Or)) +(BinaryOpIsPure (PtrAdd)) +(BinaryOpIsPure (Bitand)) +(UnaryOpIsPure (Not)) +(UnaryOpIsPure (Abs)) +(UnaryOpIsPure (Neg)) +(rule ((Function _name _tyin _tyout _out) (ExprIsPure _out)) ((ExprIsPure (Function _name _tyin _tyout _out))) :ruleset always-run) +(rule ((Const _n _ty _ctx)) ((ExprIsPure (Const _n _ty _ctx))) :ruleset always-run) +(rule ((Top _op _x _y _z) (TernaryOpIsPure _op) (ExprIsPure _x) (ExprIsPure _y) (ExprIsPure _z)) ((ExprIsPure (Top _op _x _y _z))) :ruleset always-run) +(rule ((Bop _op _x _y) (BinaryOpIsPure _op) (ExprIsPure _x) (ExprIsPure _y)) ((ExprIsPure (Bop _op _x _y))) :ruleset always-run) +(rule ((Uop _op _x) (UnaryOpIsPure _op) (ExprIsPure _x)) ((ExprIsPure (Uop _op _x))) :ruleset always-run) +(rule ((Get _tup _i) (ExprIsPure _tup)) ((ExprIsPure (Get _tup _i))) :ruleset always-run) +(rule ((= lhs (Get (Arg (TupleT tylist) _ctx) i)) (!= (TypeList-ith tylist i) (StateT))) ((ExprIsPure lhs)) :ruleset always-run) +(rule ((Concat _x _y) (ExprIsPure _x) (ExprIsPure _y)) ((ExprIsPure (Concat _x _y))) :ruleset always-run) +(rule ((Single _x) (ExprIsPure _x)) ((ExprIsPure (Single _x))) :ruleset always-run) +(rule ((Switch _pred _inputs _branches) (ExprIsPure _pred) (ExprIsPure _inputs) (ListExprIsPure _branches)) ((ExprIsPure (Switch _pred _inputs _branches))) :ruleset always-run) +(rule ((If _pred _input _then _else) (ExprIsPure _pred) (ExprIsPure _input) (ExprIsPure _then) (ExprIsPure _else)) ((ExprIsPure (If _pred _input _then _else))) :ruleset always-run) +(rule ((DoWhile _in _pred-and-output) (ExprIsPure _in) (ExprIsPure _pred-and-output)) ((ExprIsPure (DoWhile _in _pred-and-output))) :ruleset always-run) +(rule ((Call _f _arg) (ExprIsPure _arg) (ExprIsPure (Function _f inty outty out))) ((ExprIsPure (Call _f _arg))) :ruleset always-run) +(rule ((Empty _ty _ctx)) ((ExprIsPure (Empty _ty _ctx))) :ruleset always-run) +(rule ((Cons _hd _tl) (ExprIsPure _hd) (ListExprIsPure _tl)) ((ListExprIsPure (Cons _hd _tl))) :ruleset always-run) +(rule ((Nil)) ((ListExprIsPure (Nil))) :ruleset always-run) +(ruleset context) +(constructor AddContext (Assumption Expr) Expr :unextractable) +(constructor AddContextList (Assumption ListExpr) ListExpr :unextractable) +(rule ((= lhs (AddContext ctx inner)) (= inner (AddContext ctx expr))) ((union lhs inner)) :ruleset context) +(rule ((= lhs (AddContext ctx (Arg ty oldctx)))) ((union lhs (Arg ty ctx))) :ruleset context) +(rule ((= lhs (AddContext ctx (Const c ty oldctx)))) ((union lhs (Const c ty ctx))) :ruleset context) +(rule ((= lhs (AddContext ctx (Empty ty oldctx)))) ((union lhs (Empty ty ctx))) :ruleset context) +(rewrite (AddContext ctx (Top op c1 c2 c3)) (Top op (AddContext ctx c1) (AddContext ctx c2) (AddContext ctx c3)) :ruleset context) +(rewrite (AddContext ctx (Bop op c1 c2)) (Bop op (AddContext ctx c1) (AddContext ctx c2)) :ruleset context) +(rewrite (AddContext ctx (Uop op c1)) (Uop op (AddContext ctx c1)) :ruleset context) +(rewrite (AddContext ctx (Get c1 index)) (Get (AddContext ctx c1) index) :ruleset context) +(rewrite (AddContext ctx (Alloc id c1 state ty)) (Alloc id (AddContext ctx c1) (AddContext ctx state) ty) :ruleset context) +(rewrite (AddContext ctx (Call name c1)) (Call name (AddContext ctx c1)) :ruleset context) +(rewrite (AddContext ctx (Single c1)) (Single (AddContext ctx c1)) :ruleset context) +(rewrite (AddContext ctx (Concat c1 c2)) (Concat (AddContext ctx c1) (AddContext ctx c2)) :ruleset context) +(rewrite (AddContextList ctx (Nil)) (Nil) :ruleset context) +(rewrite (AddContextList ctx (Cons c1 rest)) (Cons (AddContext ctx c1) (AddContextList ctx rest)) :ruleset context) +(rewrite (AddContext ctx (Switch pred inputs branches)) (Switch (AddContext ctx pred) (AddContext ctx inputs) branches) :ruleset context) +(rule ((= lhs (AddContext ctx (If pred inputs c1 c2)))) ((union lhs (If (AddContext ctx pred) (AddContext ctx inputs) c1 c2))) :ruleset context) +(rule ((= lhs (AddContext ctx (DoWhile inputs outputs)))) ((union lhs (DoWhile (AddContext ctx inputs) outputs))) :ruleset context) +(ruleset term-subst) +(constructor TermSubst (Assumption Expr Term) Expr :unextractable) +(rule ((= lhs (TermSubst ctx e1 term)) (HasArgType e1 ty)) ((HasArgType lhs ty)) :ruleset term-subst) +(rule ((= lhs (TermSubst ctx e (TermArg)))) ((union lhs (AddContext ctx e))) :ruleset term-subst) +(rule ((= lhs (TermSubst ctx e (TermConst c))) (HasArgType e newty)) ((union lhs (Const c newty ctx))) :ruleset term-subst) +(rule ((= lhs (TermSubst ctx e (TermEmpty))) (HasArgType e newty)) ((union lhs (Empty newty ctx))) :ruleset term-subst) +(rule ((= lhs (TermSubst ctx e (TermTop op t1 t2 t3)))) ((union lhs (Top op (TermSubst ctx e t1) (TermSubst ctx e t2) (TermSubst ctx e t3)))) :ruleset term-subst) +(rule ((= lhs (TermSubst ctx e (TermBop op t1 t2)))) ((union lhs (Bop op (TermSubst ctx e t1) (TermSubst ctx e t2)))) :ruleset term-subst) +(rule ((= lhs (TermSubst ctx e (TermUop op t1)))) ((union lhs (Uop op (TermSubst ctx e t1)))) :ruleset term-subst) +(rule ((= lhs (TermSubst ctx e (TermGet t idx)))) ((union lhs (Get (TermSubst ctx e t) idx))) :ruleset term-subst) +(rule ((= lhs (TermSubst ctx e (TermAlloc id t1 t2 ty)))) ((union lhs (Alloc id (TermSubst ctx e t1) (TermSubst ctx e t2) ty))) :ruleset term-subst) +(rule ((= lhs (TermSubst ctx e (TermCall name t)))) ((union lhs (Call name (TermSubst ctx e t)))) :ruleset term-subst) +(rule ((= lhs (TermSubst ctx e (TermSingle t)))) ((union lhs (Single (TermSubst ctx e t)))) :ruleset term-subst) +(rule ((= lhs (TermSubst ctx e (TermConcat t1 t2)))) ((union lhs (Concat (TermSubst ctx e t1) (TermSubst ctx e t2)))) :ruleset term-subst) +(relation ContextOf (Expr Assumption)) +(rule ((Arg ty ctx)) ((ContextOf (Arg ty ctx) ctx)) :ruleset always-run) +(rule ((Const c ty ctx)) ((ContextOf (Const c ty ctx) ctx)) :ruleset always-run) +(rule ((Empty ty ctx)) ((ContextOf (Empty ty ctx) ctx)) :ruleset always-run) +(rule ((ContextOf x ctx1) (ContextOf x ctx2) (!= ctx1 ctx2)) ((panic "Equivalent expressions have nonequivalent context, breaking the single context invariant.")) :ruleset error-checking) +(rule ((Top op x y z) (ContextOf x ctx)) ((ContextOf (Top op x y z) ctx)) :ruleset always-run) +(rule ((Top op x y z) (ContextOf y ctx)) ((ContextOf (Top op x y z) ctx)) :ruleset always-run) +(rule ((Top op x y z) (ContextOf z ctx)) ((ContextOf (Top op x y z) ctx)) :ruleset always-run) +(rule ((Bop op x y) (ContextOf x ctx)) ((ContextOf (Bop op x y) ctx)) :ruleset always-run) +(rule ((Bop op x y) (ContextOf y ctx)) ((ContextOf (Bop op x y) ctx)) :ruleset always-run) +(rule ((Uop op x) (ContextOf x ctx)) ((ContextOf (Uop op x) ctx)) :ruleset always-run) +(rule ((Get tup i) (ContextOf tup ctx)) ((ContextOf (Get tup i) ctx)) :ruleset always-run) +(rule ((Concat x y) (ContextOf x ctx)) ((ContextOf (Concat x y) ctx)) :ruleset always-run) +(rule ((Concat x y) (ContextOf y ctx)) ((ContextOf (Concat x y) ctx)) :ruleset always-run) +(rule ((Single x) (ContextOf x ctx)) ((ContextOf (Single x) ctx)) :ruleset always-run) +(rule ((Switch pred inputs branches) (ContextOf pred ctx)) ((ContextOf (Switch pred inputs branches) ctx)) :ruleset always-run) +(rule ((If pred inputs then else) (ContextOf pred ctx)) ((ContextOf (If pred inputs then else) ctx)) :ruleset always-run) +(rule ((If pred inputs then else) (ContextOf inputs ctx)) ((ContextOf (If pred inputs then else) ctx)) :ruleset always-run) +(rule ((DoWhile in pred-and-output) (ContextOf in ctx)) ((ContextOf (DoWhile in pred-and-output) ctx)) :ruleset always-run) +(rule ((Call func arg) (ContextOf arg ctx)) ((ContextOf (Call func arg) ctx)) :ruleset always-run) +(rule ((Alloc amt e state ty) (ContextOf e ctx)) ((ContextOf (Alloc amt e state ty) ctx)) :ruleset always-run) +(rule ((Alloc amt e state ty) (ContextOf state ctx)) ((ContextOf (Alloc amt e state ty) ctx)) :ruleset always-run) +(ruleset subst) +(ruleset apply-subst-unions) +(constructor Subst (Assumption Expr Expr) Expr :unextractable) +(constructor IfSubst (Expr Expr) Expr) +(rule ((= lhs (IfSubst to in)) (HasArgType to ty) (ContextOf to ctx)) ((union lhs (If (Const (Bool true) ty ctx) to in in))) :ruleset subst) +(constructor DelayedSubstUnion (Expr Expr) Expr :unextractable) +(rule ((= lhs (Subst assum to in)) (HasArgType to ty)) ((HasArgType lhs ty)) :ruleset subst) +(rule ((Subst assum to in) (HasArgType in ty) (HasType to ty2) (!= ty ty2) (!= ty (TmpType)) (!= ty2 (TmpType))) ((panic "Substitution type mismatch! Argument type must match type of substituted term")) :ruleset subst) +(rule ((= lhs (Subst assum to e)) (= e (Arg _ty _oldctx))) ((DelayedSubstUnion lhs (AddContext assum to)) (subsume (Subst assum to e))) :ruleset subst) +(rule ((= lhs (Subst assum to e)) (= e (Const c _ty _oldctx)) (HasArgType to newty)) ((DelayedSubstUnion lhs (Const c newty assum)) (subsume (Subst assum to e))) :ruleset subst) +(rule ((= lhs (Subst assum to e)) (= e (Empty _ty _oldctx)) (HasArgType to newty)) ((DelayedSubstUnion lhs (Empty newty assum)) (subsume (Subst assum to e))) :ruleset subst) +(rule ((= e (Top op c1 c2 c3)) (= lhs (Subst assum to e)) (ExprIsResolved e) (ExprIsResolved to)) ((DelayedSubstUnion lhs (Top op (Subst assum to c1) (Subst assum to c2) (Subst assum to c3))) (subsume (Subst assum to e))) :ruleset subst) +(rule ((= e (Bop op c1 c2)) (= lhs (Subst assum to e)) (ExprIsResolved e) (ExprIsResolved to)) ((DelayedSubstUnion lhs (Bop op (Subst assum to c1) (Subst assum to c2))) (subsume (Subst assum to e))) :ruleset subst) +(rule ((= e (Uop op c1)) (= lhs (Subst assum to e)) (ExprIsResolved e) (ExprIsResolved to)) ((DelayedSubstUnion lhs (Uop op (Subst assum to c1))) (subsume (Subst assum to e))) :ruleset subst) +(rule ((= e (Get c1 index)) (= lhs (Subst assum to e)) (ExprIsResolved e) (ExprIsResolved to)) ((DelayedSubstUnion lhs (Get (Subst assum to c1) index)) (subsume (Subst assum to e))) :ruleset subst) +(rule ((= e (Alloc id c1 c2 ty)) (= lhs (Subst assum to e)) (ExprIsResolved e) (ExprIsResolved to)) ((DelayedSubstUnion lhs (Alloc id (Subst assum to c1) (Subst assum to c2) ty)) (subsume (Subst assum to e))) :ruleset subst) +(rule ((= e (Call name c1)) (= lhs (Subst assum to e)) (ExprIsResolved e) (ExprIsResolved to)) ((DelayedSubstUnion lhs (Call name (Subst assum to c1))) (subsume (Subst assum to e))) :ruleset subst) +(rule ((= e (Single c1)) (= lhs (Subst assum to e)) (ExprIsResolved e) (ExprIsResolved to)) ((DelayedSubstUnion lhs (Single (Subst assum to c1))) (subsume (Subst assum to e))) :ruleset subst) +(rule ((= e (Concat c1 c2)) (= lhs (Subst assum to e)) (ExprIsResolved e) (ExprIsResolved to)) ((DelayedSubstUnion lhs (Concat (Subst assum to c1) (Subst assum to c2))) (subsume (Subst assum to e))) :ruleset subst) +(rule ((= lhs (Subst assum to inner)) (= inner (Switch pred inputs c1)) (ExprIsResolved inner)) ((DelayedSubstUnion lhs (Switch (Subst assum to pred) (Subst assum to inputs) c1)) (subsume (Subst assum to inner))) :ruleset subst) +(rule ((= lhs (Subst assum to inner)) (= inner (If pred inputs c1 c2)) (ExprIsResolved inner)) ((DelayedSubstUnion lhs (If (Subst assum to pred) (Subst assum to inputs) c1 c2)) (subsume (Subst assum to inner))) :ruleset subst) +(rule ((= e (DoWhile in out)) (= lhs (Subst assum to e)) (ExprIsResolved e) (ExprIsResolved to)) ((DelayedSubstUnion lhs (DoWhile (Subst assum to in) out)) (subsume (Subst assum to e))) :ruleset subst) +(rewrite (Subst assum to (Function name inty outty body)) (Function name inty outty (Subst assum to body)) :when ((ExprIsResolved body)) :ruleset subst) +(rule ((DelayedSubstUnion lhs rhs)) ((union lhs rhs)) :ruleset apply-subst-unions) +(ruleset canon) +(rewrite (Bop (Add) x y) (Bop (Add) y x) :ruleset canon) +(rewrite (Bop (Mul) x y) (Bop (Mul) y x) :ruleset canon) +(rewrite (Bop (Eq) x y) (Bop (Eq) y x) :ruleset canon) +(rewrite (Bop (And) x y) (Bop (And) y x) :ruleset canon) +(rewrite (Bop (Or) x y) (Bop (Or) y x) :ruleset canon) +(rewrite (Bop (GreaterThan) x y) (Bop (LessThan) y x) :ruleset canon) +(rule ((= lhs (Bop (GreaterEq) x y)) (HasArgType x ty) (ContextOf lhs ctx)) ((union lhs (Bop (LessThan) y (Bop (Add) x (Const (Int 1) ty ctx)))) (union lhs (Bop (LessThan) (Bop (Sub) y (Const (Int 1) ty ctx)) x))) :ruleset canon) +(rule ((= lhs (Bop (LessEq) x y)) (HasArgType y ty) (ContextOf lhs ctx)) ((union lhs (Bop (LessThan) x (Bop (Add) y (Const (Int 1) ty ctx)))) (union lhs (Bop (LessThan) (Bop (Sub) x (Const (Int 1) ty ctx)) y))) :ruleset canon) +(rewrite (Concat (Concat a b) c) (Concat a (Concat b c)) :ruleset always-run) +(rewrite (Concat (Empty ty ctx) x) x :ruleset always-run) +(rewrite (Concat x (Empty ty ctx)) x :ruleset always-run) +(constructor SubTuple (Expr i64 i64) Expr :unextractable) +(rewrite (SubTuple expr x 0) (Empty ty ctx) :when ((HasArgType expr ty) (ContextOf expr ctx)) :ruleset always-run) +(rewrite (SubTuple expr x 1) (Single (Get expr x)) :ruleset always-run) +(rewrite (SubTuple expr a b) (Concat (Single (Get expr a)) (SubTuple expr (+ a 1) (- b 1))) :when ((> b 1)) :ruleset always-run) +(rule ((= lhs (DoWhile inputs body)) (= size (tuple-length lhs))) ((union lhs (SubTuple lhs 0 size))) :ruleset always-run) +(rule ((= lhs (If pred inputs thn els)) (= size (tuple-length lhs))) ((union lhs (SubTuple lhs 0 size))) :ruleset always-run) +(rule ((= lhs (Switch pred inputs bodies)) (= size (tuple-length lhs))) ((union lhs (SubTuple lhs 0 size))) :ruleset always-run) +(rule ((= lhs (Arg ty ctx)) (= size (tuple-length lhs))) ((union lhs (SubTuple lhs 0 size))) :ruleset always-run) +(rule ((Get expr i)) ((union (Single (Get expr i)) (SubTuple expr i 1))) :ruleset always-run) +(rewrite (Concat (SubTuple expr a b) (SubTuple expr (+ a b) c)) (SubTuple expr a (+ b c)) :ruleset always-run) +(rewrite (SubTuple expr 0 len) expr :when ((= len (tuple-length expr))) :ruleset always-run) +(constructor TupleRemoveAt (Expr i64) Expr :unextractable) +(rewrite (TupleRemoveAt tuple idx) (Concat (SubTuple tuple 0 idx) (SubTuple tuple (+ idx 1) (- len (+ idx 1)))) :when ((= len (tuple-length tuple))) :ruleset always-run) +(rule ((TupleRemoveAt tuple idx) (= len (tuple-length tuple)) (>= idx len)) ((panic "Index out of bounds for TupleRemoveAt")) :ruleset always-run) +(constructor TypeListRemoveAt (TypeList i64) TypeList :unextractable) +(rule ((TypeListRemoveAt (TNil) _idx)) ((panic "Index out of bounds for TypeListRemoveAt.")) :ruleset type-helpers) +(rewrite (TypeListRemoveAt (TCons x xs) 0) xs :ruleset type-helpers) +(rewrite (TypeListRemoveAt (TCons x xs) idx) (TCons x (TypeListRemoveAt xs (- idx 1))) :when ((> idx 0)) :ruleset type-helpers) +(function Expr-size (Expr) i64 :merge (min old new)) +(function ListExpr-size (ListExpr) i64 :merge (min old new)) +(rule ((= expr (Function name tyin tyout out)) (= sum (Expr-size out))) ((set (Expr-size expr) (+ sum 1))) :ruleset always-run) +(rule ((= expr (Const n ty assum))) ((set (Expr-size expr) 1)) :ruleset always-run) +(rule ((= expr (Top op x y z)) (= sum (+ (Expr-size z) (+ (Expr-size y) (Expr-size x))))) ((set (Expr-size expr) (+ sum 1))) :ruleset always-run) +(rule ((= expr (Bop op x y)) (= sum (+ (Expr-size y) (Expr-size x)))) ((set (Expr-size expr) (+ sum 1))) :ruleset always-run) +(rule ((= expr (Uop op x)) (= sum (Expr-size x))) ((set (Expr-size expr) (+ sum 1))) :ruleset always-run) +(rule ((= expr (Get tup i)) (= sum (Expr-size tup))) ((set (Expr-size expr) sum)) :ruleset always-run) +(rule ((= expr (Concat x y)) (= sum (+ (Expr-size y) (Expr-size x)))) ((set (Expr-size expr) sum)) :ruleset always-run) +(rule ((= expr (Single x)) (= sum (Expr-size x))) ((set (Expr-size expr) sum)) :ruleset always-run) +(rule ((= expr (Switch pred inputs branches)) (= sum (+ (Expr-size inputs) (+ (ListExpr-size branches) (Expr-size pred))))) ((set (Expr-size expr) (+ sum 1))) :ruleset always-run) +(rule ((= expr (If pred inputs then else)) (= sum (+ (Expr-size inputs) (+ (Expr-size else) (+ (Expr-size then) (Expr-size pred)))))) ((set (Expr-size expr) (+ sum 1))) :ruleset always-run) +(rule ((= expr (DoWhile in pred-and-output)) (= sum (+ (Expr-size pred-and-output) (Expr-size in)))) ((set (Expr-size expr) (+ sum 1))) :ruleset always-run) +(rule ((= expr (Arg ty assum))) ((set (Expr-size expr) 1)) :ruleset always-run) +(rule ((= expr (Call func arg)) (= sum (Expr-size arg))) ((set (Expr-size expr) (+ sum 1))) :ruleset always-run) +(rule ((Empty ty assum)) ((set (Expr-size (Empty ty assum)) 0)) :ruleset always-run) +(rule ((= expr (Cons hd tl)) (= sum (+ (ListExpr-size tl) (Expr-size hd)))) ((set (ListExpr-size expr) sum)) :ruleset always-run) +(rule ((Nil)) ((set (ListExpr-size (Nil)) 0)) :ruleset always-run) +(rule ((= expr (Alloc id e state ty)) (= sum (Expr-size e))) ((set (Expr-size expr) (+ sum 1))) :ruleset always-run) +(ruleset drop) +(ruleset apply-drop-unions) +(ruleset cleanup-drop) +(constructor DropAt (Assumption i64 Expr) Expr :unextractable) +(constructor DelayedDropUnion (Expr Expr) Expr :unextractable) +(constructor DropAtInternal (Type Assumption i64 Expr) Expr :unextractable) +(rule ((= lhs (DropAt ctx idx in)) (HasArgType in (TupleT oldty))) ((let newty (TupleT (TypeListRemoveAt oldty idx))) (union lhs (DropAtInternal newty ctx idx in))) :ruleset drop) +(rule ((= lhs (DropAtInternal newty newctx idx (Const c oldty oldctx)))) ((DelayedDropUnion lhs (Const c newty newctx))) :ruleset drop) +(rule ((= lhs (DropAtInternal newty newctx idx (Empty oldty oldctx)))) ((DelayedDropUnion lhs (Empty newty newctx))) :ruleset drop) +(rule ((= lhs (DropAtInternal newty newctx idx (Get (Arg oldty oldctx) i))) (< i idx)) ((DelayedDropUnion lhs (Get (Arg newty newctx) i))) :ruleset drop) +(rule ((= lhs (DropAtInternal newty newctx idx (Get (Arg oldty oldctx) i))) (> i idx)) ((DelayedDropUnion lhs (Get (Arg newty newctx) (- i 1)))) :ruleset drop) +(rule ((= lhs (DropAtInternal newty newctx idx (Top op c1 c2 c3))) (ExprIsResolved (Top op c1 c2 c3))) ((DelayedDropUnion lhs (Top op (DropAtInternal newty newctx idx c1) (DropAtInternal newty newctx idx c2) (DropAtInternal newty newctx idx c3)))) :ruleset drop) +(rule ((= lhs (DropAtInternal newty newctx idx (Bop op c1 c2))) (ExprIsResolved (Bop op c1 c2))) ((DelayedDropUnion lhs (Bop op (DropAtInternal newty newctx idx c1) (DropAtInternal newty newctx idx c2)))) :ruleset drop) +(rule ((= lhs (DropAtInternal newty newctx idx (Uop op c1))) (ExprIsResolved (Uop op c1))) ((DelayedDropUnion lhs (Uop op (DropAtInternal newty newctx idx c1)))) :ruleset drop) +(rule ((= lhs (DropAtInternal newty newctx idx (Get c1 index))) (ExprIsResolved (Get c1 index))) ((DelayedDropUnion lhs (Get (DropAtInternal newty newctx idx c1) index))) :ruleset drop) +(rule ((= lhs (DropAtInternal newty newctx idx (Alloc id c1 c2 ty))) (ExprIsResolved (Alloc id c1 c2 ty))) ((DelayedDropUnion lhs (Alloc id (DropAtInternal newty newctx idx c1) (DropAtInternal newty newctx idx c2) ty))) :ruleset drop) +(rule ((= lhs (DropAtInternal newty newctx idx (Call name c1))) (ExprIsResolved (Call name c1))) ((DelayedDropUnion lhs (Call name (DropAtInternal newty newctx idx c1)))) :ruleset drop) +(rule ((= lhs (DropAtInternal newty newctx idx (Single c1))) (ExprIsResolved (Single c1))) ((DelayedDropUnion lhs (Single (DropAtInternal newty newctx idx c1)))) :ruleset drop) +(rule ((= lhs (DropAtInternal newty newctx idx (Concat c1 c2))) (ExprIsResolved (Concat c1 c2))) ((DelayedDropUnion lhs (Concat (DropAtInternal newty newctx idx c1) (DropAtInternal newty newctx idx c2)))) :ruleset drop) +(rule ((= lhs (DropAtInternal newty newctx idx (Switch pred inputs c1))) (ExprIsResolved (Switch pred inputs c1))) ((DelayedDropUnion lhs (Switch (DropAtInternal newty newctx idx pred) (DropAtInternal newty newctx idx inputs) c1))) :ruleset drop) +(rule ((= lhs (DropAtInternal newty newctx idx (If pred inputs c1 c2))) (ExprIsResolved (If pred inputs c1 c2))) ((DelayedDropUnion lhs (If (DropAtInternal newty newctx idx pred) (DropAtInternal newty newctx idx inputs) c1 c2))) :ruleset drop) +(rule ((= lhs (DropAtInternal newty newctx idx (DoWhile in out))) (ExprIsResolved (DoWhile in out))) ((DelayedDropUnion lhs (DoWhile (DropAtInternal newty newctx idx in) out))) :ruleset drop) +(rewrite (DropAtInternal newty newctx idx (Function name inty outty body)) (Function name inty outty (DropAtInternal newty newctx idx body)) :when ((ExprIsResolved body)) :ruleset drop) +(rule ((DelayedDropUnion lhs rhs)) ((union lhs rhs)) :ruleset apply-drop-unions) +(rule ((ExprIsResolved (DropAt newctx idx in))) ((subsume (DropAt newctx idx in))) :ruleset cleanup-drop) +(rule ((ExprIsResolved (DropAtInternal newty newctx idx in))) ((subsume (DropAtInternal newty newctx idx in))) :ruleset cleanup-drop) +(rule ((DelayedDropUnion lhs rhs)) ((subsume (DelayedDropUnion lhs rhs))) :ruleset cleanup-drop) +(ruleset interval-analysis) +(ruleset interval-rewrite) +(sort IntOrBool (Either i64 bool)) +(sort Bound (Maybe IntOrBool)) +(function lo-bound (Expr) Bound :merge (maybe-either-i64-bool-max old new)) +(function hi-bound (Expr) Bound :merge (maybe-either-i64-bool-min old new)) +(rule ((= lo (either-unwrap-left (maybe-unwrap (lo-bound expr)))) (= hi (either-unwrap-left (maybe-unwrap (hi-bound expr)))) (> lo hi)) ((set (lo-bound expr) (maybe-none)) (set (hi-bound expr) (maybe-none))) :ruleset interval-analysis) +(rule ((= true (either-unwrap-right (maybe-unwrap (lo-bound expr)))) (= false (either-unwrap-right (maybe-unwrap (hi-bound expr))))) ((set (lo-bound expr) (maybe-none)) (set (hi-bound expr) (maybe-none))) :ruleset interval-analysis) +(rule ((= lhs (Const (Int x) ty ctx))) ((set (lo-bound lhs) (maybe-some (either-left x))) (set (hi-bound lhs) (maybe-some (either-left x)))) :ruleset interval-analysis) +(rule ((= lhs (Const (Bool x) ty ctx))) ((set (lo-bound lhs) (maybe-some (either-right x))) (set (hi-bound lhs) (maybe-some (either-right x)))) :ruleset interval-analysis) +(rule ((= x (either-unwrap-left (maybe-unwrap (lo-bound expr)))) (= x (either-unwrap-left (maybe-unwrap (hi-bound expr)))) (HasArgType expr ty) (ContextOf expr ctx)) ((union expr (Const (Int x) ty ctx))) :ruleset interval-analysis) +(rule ((= x (either-unwrap-right (maybe-unwrap (lo-bound expr)))) (= x (either-unwrap-right (maybe-unwrap (hi-bound expr)))) (HasArgType expr ty) (ContextOf expr ctx)) ((union expr (Const (Bool x) ty ctx))) :ruleset interval-analysis) +(rule ((= true (either-unwrap-right (maybe-unwrap (lo-bound expr)))) (HasArgType expr ty) (ContextOf expr ctx)) ((union expr (Const (Bool true) ty ctx))) :ruleset interval-analysis) +(rule ((= false (either-unwrap-right (maybe-unwrap (hi-bound expr)))) (HasArgType expr ty) (ContextOf expr ctx)) ((union expr (Const (Bool false) ty ctx))) :ruleset interval-analysis) +(rule ((= lhs (Bop (Add) a b)) (= la (either-unwrap-left (maybe-unwrap (lo-bound a)))) (= lb (either-unwrap-left (maybe-unwrap (lo-bound b))))) ((set (lo-bound lhs) (maybe-some (either-left (+ la lb))))) :ruleset interval-analysis) +(rule ((= lhs (Bop (Add) a b)) (= ha (either-unwrap-left (maybe-unwrap (hi-bound a)))) (= hb (either-unwrap-left (maybe-unwrap (hi-bound b))))) ((set (hi-bound lhs) (maybe-some (either-left (+ ha hb))))) :ruleset interval-analysis) +(rule ((= lhs (Bop (Sub) a b)) (= la (either-unwrap-left (maybe-unwrap (lo-bound a)))) (= hb (either-unwrap-left (maybe-unwrap (hi-bound b))))) ((set (lo-bound lhs) (maybe-some (either-left (- la hb))))) :ruleset interval-analysis) +(rule ((= lhs (Bop (Sub) a b)) (= ha (either-unwrap-left (maybe-unwrap (hi-bound a)))) (= lb (either-unwrap-left (maybe-unwrap (lo-bound b))))) ((set (hi-bound lhs) (maybe-some (either-left (- ha lb))))) :ruleset interval-analysis) +(rule ((= lhs (Bop (Mul) a b)) (= x (either-unwrap-left (maybe-unwrap (lo-bound a)))) (= x (either-unwrap-left (maybe-unwrap (hi-bound a)))) (= y (either-unwrap-left (maybe-unwrap (lo-bound b)))) (= y (either-unwrap-left (maybe-unwrap (hi-bound b))))) ((set (lo-bound lhs) (maybe-some (either-left (* x y)))) (set (hi-bound lhs) (maybe-some (either-left (* x y))))) :ruleset interval-analysis) +(rule ((= lhs (Bop (Mul) x y)) (= hi-x (either-unwrap-left (maybe-unwrap (hi-bound x)))) (= hi-y (either-unwrap-left (maybe-unwrap (hi-bound y)))) (< hi-x 0) (< hi-y 0)) ((set (lo-bound lhs) (maybe-some (either-left 1)))) :ruleset interval-analysis) +(rule ((= lhs (Bop (Mul) x y)) (= hi-x (either-unwrap-left (maybe-unwrap (hi-bound x)))) (= lo-y (either-unwrap-left (maybe-unwrap (lo-bound y)))) (< hi-x 0) (> lo-y 0)) ((set (hi-bound lhs) (maybe-some (either-left -1)))) :ruleset interval-analysis) +(rule ((= lhs (Bop (Mul) x y)) (= lo-x (either-unwrap-left (maybe-unwrap (lo-bound x)))) (= lo-y (either-unwrap-left (maybe-unwrap (lo-bound y)))) (> lo-x 0) (> lo-y 0)) ((set (lo-bound lhs) (maybe-some (either-left 1)))) :ruleset interval-analysis) +(rule ((= lhs (Bop (Mul) x y)) (= hi-x (either-unwrap-left (maybe-unwrap (hi-bound x)))) (= hi-y (either-unwrap-left (maybe-unwrap (hi-bound y)))) (<= hi-x 0) (<= hi-y 0)) ((set (lo-bound lhs) (maybe-some (either-left 0)))) :ruleset interval-analysis) +(rule ((= lhs (Bop (Mul) x y)) (= hi-x (either-unwrap-left (maybe-unwrap (hi-bound x)))) (= lo-y (either-unwrap-left (maybe-unwrap (lo-bound y)))) (<= hi-x 0) (>= lo-y 0)) ((set (hi-bound lhs) (maybe-some (either-left 0)))) :ruleset interval-analysis) +(rule ((= lhs (Bop (Mul) x y)) (= lo-x (either-unwrap-left (maybe-unwrap (lo-bound x)))) (= lo-y (either-unwrap-left (maybe-unwrap (lo-bound y)))) (>= lo-x 0) (>= lo-y 0)) ((set (lo-bound lhs) (maybe-some (either-left 0)))) :ruleset interval-analysis) +(rule ((= lhs (Bop (LessThan) a b)) (= ha (either-unwrap-left (maybe-unwrap (hi-bound a)))) (= lb (either-unwrap-left (maybe-unwrap (lo-bound b))))) ((set (lo-bound lhs) (maybe-some (either-right (bool-< ha lb))))) :ruleset interval-analysis) +(rule ((= lhs (Bop (LessThan) a b)) (= la (either-unwrap-left (maybe-unwrap (lo-bound a)))) (= hb (either-unwrap-left (maybe-unwrap (hi-bound b))))) ((set (hi-bound lhs) (maybe-some (either-right (bool-< la hb))))) :ruleset interval-analysis) +(rule ((= lhs (Uop (Abs) x)) (= lx (either-unwrap-left (maybe-unwrap (lo-bound x)))) (>= lx 0)) ((union lhs x)) :ruleset interval-rewrite) +(rule ((= lhs (Uop (Abs) x)) (= hx (either-unwrap-left (maybe-unwrap (hi-bound x)))) (<= hx 0) (HasArgType lhs ty) (ContextOf lhs ctx)) ((union lhs (Bop (Sub) (Const (Int 0) ty ctx) x))) :ruleset interval-rewrite) +(rule ((= lhs (If cond inputs thn els)) (ContextOf lhs if_ctx) (= true (either-unwrap-right (maybe-unwrap (lo-bound cond))))) ((union lhs (Subst if_ctx inputs thn))) :ruleset interval-rewrite) +(rule ((= lhs (If cond inputs thn els)) (ContextOf lhs if_ctx) (= false (either-unwrap-right (maybe-unwrap (hi-bound cond))))) ((union lhs (Subst if_ctx inputs els))) :ruleset interval-rewrite) +(rule ((= lhs (If cond inputs thn els)) (= lo-thn (lo-bound thn)) (= lo-els (lo-bound els))) ((set (lo-bound lhs) (maybe-either-i64-bool-min lo-thn lo-els))) :ruleset interval-analysis) +(rule ((= lhs (If cond inputs thn els)) (= hi-thn (hi-bound thn)) (= hi-els (hi-bound els))) ((set (hi-bound lhs) (maybe-either-i64-bool-max hi-thn hi-els))) :ruleset interval-analysis) +(rule ((= lhs (If pred inputs thn els)) (= lo-thn (lo-bound (Get thn i))) (= lo-els (lo-bound (Get els i)))) ((set (lo-bound (Get lhs i)) (maybe-either-i64-bool-min lo-thn lo-els))) :ruleset interval-analysis) +(rule ((= lhs (If cond inputs thn els)) (= hi-thn (hi-bound (Get thn i))) (= hi-els (hi-bound (Get els i)))) ((set (hi-bound (Get lhs i)) (maybe-either-i64-bool-max hi-thn hi-els))) :ruleset interval-analysis) +(rule ((= pred (Bop (LessThan) expr value)) (= if_e (If pred inputs then else)) (= expr (Get inputs i)) (= v (either-unwrap-left (maybe-unwrap (hi-bound value)))) (= ctx (Arg ty (InIf true pred inputs))) (HasType inputs ty)) ((panic "context should not be present")) :ruleset interval-analysis) +(rule ((= pred (Bop (LessThan) expr value)) (= if_e (If pred inputs then else)) (= expr (Get inputs i)) (= v (either-unwrap-left (maybe-unwrap (lo-bound value)))) (= ctx (Arg ty (InIf false pred inputs))) (HasType inputs ty)) ((panic "context should not be present")) :ruleset interval-analysis) +(rule ((= pred (Bop (LessThan) value expr)) (= if_e (If pred inputs then else)) (= expr (Get inputs i)) (= v (either-unwrap-left (maybe-unwrap (lo-bound value)))) (= ctx (Arg ty (InIf true pred inputs))) (HasType inputs ty)) ((panic "context should not be present")) :ruleset interval-analysis) +(rule ((= pred (Bop (LessThan) value expr)) (= if_e (If pred inputs then else)) (= expr (Get inputs i)) (= v (either-unwrap-left (maybe-unwrap (hi-bound value)))) (= ctx (Arg ty (InIf false pred inputs))) (HasType inputs ty)) ((panic "context should not be present")) :ruleset interval-analysis) +(rule ((= if (If pred inputs then_ else_)) (= ctx (Arg ty (InIf b pred inputs))) (HasType inputs ty) (= lo (lo-bound (Get inputs i)))) ((panic "context should not be present")) :ruleset interval-analysis) +(rule ((= if (If pred inputs then_ else_)) (= ctx (Arg ty (InIf b pred inputs))) (HasType inputs ty) (= hi (hi-bound (Get inputs i)))) ((panic "context should not be present")) :ruleset interval-analysis) +(rule ((= pred (Bop (Eq) expr val)) (= if_e (If pred inputs thn els)) (= expr (Get inputs i)) (= ctx (Arg ty (InIf true pred inputs))) (HasType inputs ty) (= lo (either-unwrap-left (maybe-unwrap (lo-bound val))))) ((panic "context should not be present")) :ruleset interval-analysis) +(rule ((= pred (Bop (Eq) expr val)) (= if_e (If pred inputs thn els)) (= expr (Get inputs i)) (= ctx (Arg ty (InIf true pred inputs))) (HasType inputs ty) (= hi (either-unwrap-left (maybe-unwrap (hi-bound val))))) ((panic "context should not be present")) :ruleset interval-analysis) +(rule ((Arg ty (InLoop inputs outputs)) (= (Get (Arg ty some_ctx) ith) (Get outputs (+ 1 ith))) (= bound (lo-bound (Get inputs ith)))) ((panic "context should not be present")) :ruleset interval-analysis) +(rule ((Arg ty (InLoop inputs outputs)) (= (Get (Arg ty some_ctx) ith) (Get outputs (+ 1 ith))) (= bound (hi-bound (Get inputs ith)))) ((panic "context should not be present")) :ruleset interval-analysis) +(ruleset switch_rewrite) +(ruleset always-switch-rewrite) +(rule ((= pred (Bop (LessThan) a b)) (= if_e (If pred inputs thn els)) (= a (Get inputs i)) (= b (Get inputs j)) (= (Get thn k) (Get (Arg ty (InIf true pred inputs)) i)) (= (Get els k) (Get (Arg ty (InIf false pred inputs)) j))) ((panic "context should not be present")) :ruleset switch_rewrite) +(rule ((= pred (Bop (LessThan) a b)) (= if_e (If pred inputs thn els)) (= a (Get inputs i)) (= b (Get inputs j)) (= (Get thn k) (Get (Arg ty (InIf true pred inputs)) j)) (= (Get els k) (Get (Arg ty (InIf false pred inputs)) i))) ((panic "context should not be present")) :ruleset switch_rewrite) +(rule ((= if_e (If pred inputs thn els)) (= a (Get inputs i)) (= b (Get inputs j)) (= (Get thn k) (Get (Arg ty (InIf true pred inputs)) i)) (= (Get els k) (Get (Arg ty (InIf false pred inputs)) j)) (!= i j)) ((panic "context should not be present")) :ruleset switch_rewrite) +(rule ((= if_e (If pred inputs thn els)) (ContextOf if_e ctx) (HasArgType if_e ty) (= (Get thn i) (Const x _ty (InIf true pred inputs))) (= (Get els i) (Const y _ty (InIf false pred inputs)))) ((panic "context should not be present")) :ruleset switch_rewrite) +(rule ((= if_e (If pred inputs thn els)) (ContextOf if_e ctx) (HasArgType if_e ty) (= a (Get inputs i)) (= (Get thn k) (Get (Arg _ty (InIf true pred inputs)) i)) (= els_out (Get els k)) (= y (either-unwrap-left (maybe-unwrap (lo-bound els_out)))) (= y (either-unwrap-left (maybe-unwrap (hi-bound els_out))))) ((panic "context should not be present")) :ruleset switch_rewrite) +(rule ((= if_e (If pred inputs thn els)) (ContextOf if_e ctx) (HasArgType if_e ty) (= thn_out (Get thn k)) (= y (either-unwrap-left (maybe-unwrap (lo-bound thn_out)))) (= y (either-unwrap-left (maybe-unwrap (hi-bound thn_out)))) (= b (Get inputs i)) (= (Get els k) (Get (Arg _ty (InIf false pred inputs)) i))) ((panic "context should not be present")) :ruleset switch_rewrite) +(rule ((= lhs (If (Bop (And) a b) ins X Y)) (HasType ins (TupleT ins_ty)) (= len (tuple-length ins)) (< (Expr-size Y) 100)) ((let outer_ins (Concat (Single b) ins)) (let outer_ins_ty (TupleT (TCons (BoolT) ins_ty))) (let inner_pred (Get (Arg outer_ins_ty DUMMYCTX) 0)) (let sub_arg_true (SubTuple (Arg outer_ins_ty DUMMYCTX) 1 len)) (let sub_arg_false (SubTuple (Arg outer_ins_ty DUMMYCTX) 1 len)) (let inner_Y (AddContext DUMMYCTX Y)) (let outer_Y (Subst DUMMYCTX sub_arg_false Y)) (let inner (If inner_pred sub_arg_true X inner_Y)) (union lhs (If a outer_ins inner outer_Y))) :ruleset switch_rewrite) +(rule ((= lhs (If (Bop (Or) a b) ins X Y)) (HasType ins (TupleT ins_ty)) (= len (tuple-length ins)) (< (Expr-size X) 100) (< (Expr-size Y) 100)) ((let outer_ins (Concat (Single b) ins)) (let outer_ins_ty (TupleT (TCons (BoolT) ins_ty))) (let inner_pred (Get (Arg outer_ins_ty DUMMYCTX) 0)) (let sub_arg_true (SubTuple (Arg outer_ins_ty DUMMYCTX) 1 len)) (let sub_arg_false (SubTuple (Arg outer_ins_ty DUMMYCTX) 1 len)) (let outer_X (Subst DUMMYCTX sub_arg_true X)) (let inner_X (AddContext DUMMYCTX X)) (let inner_Y (AddContext DUMMYCTX Y)) (let inner (If inner_pred sub_arg_false inner_X inner_Y)) (union lhs (If a outer_ins outer_X inner))) :ruleset switch_rewrite) +(ruleset select_opt) +(rule ((= if_e (If pred inputs thn els)) (ExprIsPure (Get thn i)) (ExprIsPure (Get els i)) (> 10 (Expr-size (Get thn i))) (> 10 (Expr-size (Get els i))) (= t1 (pair-first (ExtractedExpr (Get thn i)))) (= t2 (pair-first (ExtractedExpr (Get els i)))) (ContextOf if_e ctx)) ((union (Get if_e i) (Top (Select) pred (TermSubst ctx inputs t1) (TermSubst ctx inputs t2)))) :ruleset select_opt) +(ruleset peepholes) +(rewrite (Bop (Mul) (Const (Int 0) ty ctx) e) (Const (Int 0) ty ctx) :ruleset peepholes) +(rewrite (Bop (Mul) e (Const (Int 0) ty ctx)) (Const (Int 0) ty ctx) :ruleset peepholes) +(rewrite (Bop (Mul) (Const (Int 1) ty ctx) e) e :ruleset peepholes) +(rewrite (Bop (Mul) e (Const (Int 1) ty ctx)) e :ruleset peepholes) +(rewrite (Bop (Add) (Const (Int 0) ty ctx) e) e :ruleset peepholes) +(rewrite (Bop (Add) e (Const (Int 0) ty ctx)) e :ruleset peepholes) +(rewrite (Bop (Mul) (Const (Int j) ty ctx) (Const (Int i) ty ctx)) (Const (Int (* i j)) ty ctx) :ruleset peepholes) +(rewrite (Bop (Add) (Const (Int j) ty ctx) (Const (Int i) ty ctx)) (Const (Int (+ i j)) ty ctx) :ruleset peepholes) +(rewrite (Bop (And) (Const (Bool true) ty ctx) e) e :ruleset peepholes) +(rewrite (Bop (And) e (Const (Bool true) ty ctx)) e :ruleset peepholes) +(rewrite (Bop (And) (Const (Bool false) ty ctx) e) (Const (Bool false) ty ctx) :ruleset peepholes) +(rewrite (Bop (And) e (Const (Bool false) ty ctx)) (Const (Bool false) ty ctx) :ruleset peepholes) +(rewrite (Bop (Or) (Const (Bool false) ty ctx) e) e :ruleset peepholes) +(rewrite (Bop (Or) e (Const (Bool false) ty ctx)) e :ruleset peepholes) +(rewrite (Bop (Or) (Const (Bool true) ty ctx) e) (Const (Bool true) ty ctx) :ruleset peepholes) +(rewrite (Bop (Or) e (Const (Bool true) ty ctx)) (Const (Bool true) ty ctx) :ruleset peepholes) +(rule ((= expr (Bop (Sub) x x)) (HasArgType expr ty) (ContextOf expr ctx)) ((union expr (Const (Int 0) ty ctx))) :ruleset peepholes) +(rewrite (Bop (Add) (Bop (Sub) x y) z) (Bop (Add) x (Bop (Sub) z y)) :ruleset peepholes) +(rewrite (Bop (Sub) (Bop (Add) a b) c) (Bop (Add) a (Bop (Sub) b c)) :ruleset peepholes) +(rule ((= expr (Bop (Add) (Bop (Mul) a x) a)) (HasArgType expr ty) (ContextOf expr ctx)) ((union expr (Bop (Mul) a (Bop (Add) x (Const (Int 1) ty ctx))))) :ruleset peepholes) +(rewrite (Top (Select) pred x x) x :ruleset peepholes) +(rewrite (Bop (Add) (Bop (Add) x (Const (Int i) ty ctx)) (Const (Int j) ty ctx)) (Bop (Add) x (Const (Int (+ i j)) ty ctx)) :ruleset peepholes) +(rewrite (Bop (PtrAdd) (Bop (PtrAdd) p x) y) (Bop (PtrAdd) p (Bop (Add) x y)) :ruleset peepholes) +(datatype IntOrInfinity (Infinity) (NegInfinity) (I i64)) +(constructor MaxIntOrInfinity (IntOrInfinity IntOrInfinity) IntOrInfinity) +(rewrite (MaxIntOrInfinity (Infinity) _) (Infinity) :ruleset always-run) +(rewrite (MaxIntOrInfinity _ (Infinity)) (Infinity) :ruleset always-run) +(rewrite (MaxIntOrInfinity (NegInfinity) x) x :ruleset always-run) +(rewrite (MaxIntOrInfinity x (NegInfinity)) x :ruleset always-run) +(rewrite (MaxIntOrInfinity (I x) (I y)) (I (max x y)) :ruleset always-run) +(constructor MinIntOrInfinity (IntOrInfinity IntOrInfinity) IntOrInfinity) +(rewrite (MinIntOrInfinity (NegInfinity) _) (NegInfinity) :ruleset always-run) +(rewrite (MinIntOrInfinity _ (NegInfinity)) (NegInfinity) :ruleset always-run) +(rewrite (MinIntOrInfinity (Infinity) x) x :ruleset always-run) +(rewrite (MinIntOrInfinity x (Infinity)) x :ruleset always-run) +(rewrite (MinIntOrInfinity (I x) (I y)) (I (min x y)) :ruleset always-run) +(constructor AddIntOrInfinity (IntOrInfinity IntOrInfinity) IntOrInfinity) +(rewrite (AddIntOrInfinity (Infinity) (Infinity)) (Infinity) :ruleset always-run) +(rewrite (AddIntOrInfinity (Infinity) (I _)) (Infinity) :ruleset always-run) +(rewrite (AddIntOrInfinity (I _) (Infinity)) (Infinity) :ruleset always-run) +(rewrite (AddIntOrInfinity (NegInfinity) (NegInfinity)) (NegInfinity) :ruleset always-run) +(rewrite (AddIntOrInfinity (NegInfinity) (I _)) (NegInfinity) :ruleset always-run) +(rewrite (AddIntOrInfinity (I _) (NegInfinity)) (NegInfinity) :ruleset always-run) +(rewrite (AddIntOrInfinity (I x) (I y)) (I (+ x y)) :ruleset always-run) +(datatype IntInterval (MkIntInterval IntOrInfinity IntOrInfinity)) +(constructor UnionIntInterval (IntInterval IntInterval) IntInterval) +(rewrite (UnionIntInterval (MkIntInterval lo1 hi1) (MkIntInterval lo2 hi2)) (MkIntInterval (MinIntOrInfinity lo1 lo2) (MaxIntOrInfinity hi1 hi2)) :ruleset always-run) +(constructor IntersectIntInterval (IntInterval IntInterval) IntInterval) +(rewrite (IntersectIntInterval (MkIntInterval lo1 hi1) (MkIntInterval lo2 hi2)) (MkIntInterval (MaxIntOrInfinity lo1 lo2) (MinIntOrInfinity hi1 hi2)) :ruleset always-run) +(constructor AddIntInterval (IntInterval IntInterval) IntInterval) +(rewrite (AddIntInterval (MkIntInterval lo1 hi1) (MkIntInterval lo2 hi2)) (MkIntInterval (AddIntOrInfinity lo1 lo2) (AddIntOrInfinity hi1 hi2)) :ruleset always-run) +(datatype List (Nil-List) (Cons-List i64 IntInterval List)) +(function Length-List (List) i64 :merge old) +(rule ((= x (Nil-List))) ((set (Length-List x) 0)) :ruleset always-run) +(rule ((= x (Cons-List hd0 hd1 tl)) (= l (Length-List tl))) ((set (Length-List x) (+ l 1))) :ruleset always-run) +(rule ((= x (Nil-List))) ((set (Length-List x) 0)) :ruleset memory-helpers) +(rule ((= x (Cons-List hd0 hd1 tl)) (= l (Length-List tl))) ((set (Length-List x) (+ l 1))) :ruleset memory-helpers) +(relation IsEmpty-List (List)) +(rule ((= x (Nil-List))) ((IsEmpty-List x)) :ruleset always-run) +(relation IsNonEmpty-List (List)) +(rule ((= x (Cons-List hd0 hd1 tl))) ((IsNonEmpty-List x)) :ruleset always-run) +(constructor RevConcat-List (List List) List :cost 1000) +(rewrite (RevConcat-List (Nil-List) l) l :ruleset always-run) +(rewrite (RevConcat-List (Cons-List hd0 hd1 tl) l) (RevConcat-List tl (Cons-List hd0 hd1 l)) :ruleset always-run) +(constructor Rev-List (List) List :cost 1000) +(rewrite (Rev-List m) (RevConcat-List m (Nil-List)) :ruleset always-run) +(constructor Concat-List (List List) List :cost 1000) +(rewrite (Concat-List x y) (RevConcat-List (Rev-List x) y) :ruleset always-run) +(relation DemandAt-List (List)) +(relation SuffixAt-List (List i64 List)) +(relation At-List (List i64 i64 IntInterval)) +(rule ((DemandAt-List x)) ((SuffixAt-List x 0 x)) :ruleset always-run) +(rule ((SuffixAt-List x i (Cons-List hd0 hd1 tl))) ((SuffixAt-List x (+ i 1) tl) (At-List x i hd0 hd1)) :ruleset always-run) +(constructor Union-List (List List) List) +(constructor UnionHelper-List (List List List) List) +(rewrite (Union-List m1 m2) (Rev-List (UnionHelper-List m1 m2 (Nil-List))) :ruleset always-run) +(rewrite (UnionHelper-List (Nil-List) (Nil-List) res) res :ruleset always-run) +(rewrite (UnionHelper-List (Nil-List) (Cons-List hd0 hd1 tl) res) (UnionHelper-List (Nil-List) tl (Cons-List hd0 hd1 res)) :ruleset always-run) +(rewrite (UnionHelper-List (Cons-List hd0 hd1 tl) (Nil-List) res) (UnionHelper-List tl (Nil-List) (Cons-List hd0 hd1 res)) :ruleset always-run) +(rule ((= f (UnionHelper-List l1 l2 res)) (= l1 (Cons-List k1 a1 tl1)) (= l2 (Cons-List k2 b1 tl2)) (< k1 k2)) ((union f (UnionHelper-List tl1 l2 (Cons-List k1 a1 res)))) :ruleset always-run) +(rule ((= f (UnionHelper-List l1 l2 res)) (= l1 (Cons-List k1 a1 tl1)) (= l2 (Cons-List k2 b1 tl2)) (< k2 k1)) ((union f (UnionHelper-List l1 tl2 (Cons-List k2 b1 res)))) :ruleset always-run) +(rule ((= f (UnionHelper-List l1 l2 res)) (= l1 (Cons-List k a1 tl1)) (= l2 (Cons-List k b1 tl2))) ((union f (UnionHelper-List tl1 tl2 (Cons-List k (UnionIntInterval a1 b1) res)))) :ruleset always-run) +(constructor Intersect-List (List List) List) +(constructor IntersectHelper-List (List List List) List) +(rewrite (Intersect-List m1 m2) (Rev-List (IntersectHelper-List m1 m2 (Nil-List))) :ruleset always-run) +(rewrite (IntersectHelper-List (Nil-List) m2 res) res :ruleset always-run) +(rewrite (IntersectHelper-List m1 (Nil-List) res) res :ruleset always-run) +(rule ((= f (IntersectHelper-List l1 l2 res)) (= l1 (Cons-List k1 a1 tl1)) (= l2 (Cons-List k2 b1 tl2)) (< k1 k2)) ((union f (IntersectHelper-List tl1 l2 res))) :ruleset always-run) +(rule ((= f (IntersectHelper-List l1 l2 res)) (= l1 (Cons-List k1 a1 tl1)) (= l2 (Cons-List k2 b1 tl2)) (< k2 k1)) ((union f (IntersectHelper-List tl1 l2 res))) :ruleset always-run) +(datatype MyBool (MyTrue) (MyFalse)) +(constructor IntIntervalValid (IntInterval) MyBool) +(rewrite (IntIntervalValid (MkIntInterval (I lo) (I hi))) (MyTrue) :when ((<= lo hi)) :ruleset always-run) +(rewrite (IntIntervalValid (MkIntInterval (I lo) (I hi))) (MyFalse) :when ((> lo hi)) :ruleset always-run) +(rewrite (IntIntervalValid (MkIntInterval (NegInfinity) _)) (MyTrue) :ruleset always-run) +(rewrite (IntIntervalValid (MkIntInterval _ (Infinity))) (MyTrue) :ruleset always-run) +(constructor ConsIfNonEmpty (i64 IntInterval List) List :cost 100) +(rule ((ConsIfNonEmpty k v tl)) ((IntIntervalValid v)) :ruleset always-run) +(rule ((= f (ConsIfNonEmpty k v tl)) (= (MyTrue) (IntIntervalValid v))) ((union f (Cons-List k v tl))) :ruleset always-run) +(rule ((= f (ConsIfNonEmpty k v tl)) (= (MyFalse) (IntIntervalValid v))) ((union f tl)) :ruleset always-run) +(rule ((= f (IntersectHelper-List l1 l2 res)) (= l1 (Cons-List k a1 tl1)) (= l2 (Cons-List k b1 tl2))) ((union f (IntersectHelper-List tl1 tl2 (ConsIfNonEmpty k (IntersectIntInterval a1 b1) res)))) :ruleset always-run) +(constructor AddIntIntervalToAll (IntInterval List) List) +(rewrite (AddIntIntervalToAll _ (Nil-List)) (Nil-List) :ruleset always-run) +(rewrite (AddIntIntervalToAll x (Cons-List allocid offset tl)) (Cons-List allocid (AddIntInterval x offset) (AddIntIntervalToAll x tl)) :ruleset always-run) +(datatype PtrPointees (PointsTo List) (PointsAnywhere)) +(constructor AddIntIntervalToPtrPointees (IntInterval PtrPointees) PtrPointees) +(rewrite (AddIntIntervalToPtrPointees interval (PointsAnywhere)) (PointsAnywhere) :ruleset always-run) +(rewrite (AddIntIntervalToPtrPointees interval (PointsTo l)) (PointsTo (AddIntIntervalToAll interval l)) :ruleset always-run) +(constructor Union-PtrPointees (PtrPointees PtrPointees) PtrPointees) +(rewrite (Union-PtrPointees (PointsAnywhere) _) (PointsAnywhere) :ruleset always-run) +(rewrite (Union-PtrPointees _ (PointsAnywhere)) (PointsAnywhere) :ruleset always-run) +(rewrite (Union-PtrPointees (PointsTo x) (PointsTo y)) (PointsTo (Union-List x y)) :ruleset always-run) +(constructor Intersect-PtrPointees (PtrPointees PtrPointees) PtrPointees) +(rewrite (Intersect-PtrPointees (PointsAnywhere) x) x :ruleset always-run) +(rewrite (Intersect-PtrPointees x (PointsAnywhere)) x :ruleset always-run) +(rewrite (Intersect-PtrPointees (PointsTo x) (PointsTo y)) (PointsTo (Intersect-List x y)) :ruleset always-run) +(relation PointsNowhere-PtrPointees (PtrPointees)) +(rule ((= f (PointsTo x)) (IsEmpty-List x)) ((PointsNowhere-PtrPointees f)) :ruleset always-run) +(datatype List (Nil-List) (Cons-List PtrPointees List)) +(function Length-List (List) i64 :merge old) +(rule ((= x (Nil-List))) ((set (Length-List x) 0)) :ruleset always-run) +(rule ((= x (Cons-List hd0 tl)) (= l (Length-List tl))) ((set (Length-List x) (+ l 1))) :ruleset always-run) +(rule ((= x (Nil-List))) ((set (Length-List x) 0)) :ruleset memory-helpers) +(rule ((= x (Cons-List hd0 tl)) (= l (Length-List tl))) ((set (Length-List x) (+ l 1))) :ruleset memory-helpers) +(relation IsEmpty-List (List)) +(rule ((= x (Nil-List))) ((IsEmpty-List x)) :ruleset always-run) +(relation IsNonEmpty-List (List)) +(rule ((= x (Cons-List hd0 tl))) ((IsNonEmpty-List x)) :ruleset always-run) +(constructor RevConcat-List (List List) List :cost 1000) +(rewrite (RevConcat-List (Nil-List) l) l :ruleset always-run) +(rewrite (RevConcat-List (Cons-List hd0 tl) l) (RevConcat-List tl (Cons-List hd0 l)) :ruleset always-run) +(constructor Rev-List (List) List :cost 1000) +(rewrite (Rev-List m) (RevConcat-List m (Nil-List)) :ruleset always-run) +(constructor Concat-List (List List) List :cost 1000) +(rewrite (Concat-List x y) (RevConcat-List (Rev-List x) y) :ruleset always-run) +(relation DemandAt-List (List)) +(relation SuffixAt-List (List i64 List)) +(relation At-List (List i64 PtrPointees)) +(rule ((DemandAt-List x)) ((SuffixAt-List x 0 x)) :ruleset always-run) +(rule ((SuffixAt-List x i (Cons-List hd0 tl))) ((SuffixAt-List x (+ i 1) tl) (At-List x i hd0)) :ruleset always-run) +(relation All (List)) +(rule ((= x (Nil-List))) ((All x)) :ruleset always-run) +(rule ((= x (Cons-List hd0 tl)) (PointsNowhere-PtrPointees hd0) (All tl)) ((All x)) :ruleset always-run) +(constructor Zip (List List) List :cost 1000) +(rewrite (Zip (Nil-List) (Nil-List)) (Nil-List) :ruleset always-run) +(rewrite (Zip (Cons-List x0 tl1) (Cons-List y0 tl2)) (Cons-List (Union-PtrPointees x0 y0) (Zip tl1 tl2)) :when ((= (Length-List tl1) (Length-List tl2))) :ruleset always-run) +(constructor Zip (List List) List :cost 1000) +(rewrite (Zip (Nil-List) (Nil-List)) (Nil-List) :ruleset always-run) +(rewrite (Zip (Cons-List x0 tl1) (Cons-List y0 tl2)) (Cons-List (Intersect-PtrPointees x0 y0) (Zip tl1 tl2)) :ruleset always-run) +(sort ExprSetPrim (Set Expr)) +(datatype ExprSet (ES ExprSetPrim)) +(constructor ExprSet-intersect (ExprSet ExprSet) ExprSet) +(rewrite (ExprSet-intersect (ES set1) (ES set2)) (ES (set-intersect set1 set2)) :ruleset memory-helpers) +(constructor ExprSet-union (ExprSet ExprSet) ExprSet) +(rewrite (ExprSet-union (ES set1) (ES set2)) (ES (set-union set1 set2)) :ruleset memory-helpers) +(constructor ExprSet-insert (ExprSet Expr) ExprSet) +(rewrite (ExprSet-insert (ES set1) x) (ES (set-insert set1 x)) :ruleset memory-helpers) +(function ExprSet-length (ExprSet) i64 :merge old) +(rule ((ES set1)) ((set (ExprSet-length (ES set1)) (set-length set1))) :ruleset memory-helpers) +(datatype Pointees (TuplePointsTo List) (PtrPointsTo PtrPointees)) +(constructor UnwrapPtrPointsTo (Pointees) PtrPointees) +(rewrite (UnwrapPtrPointsTo (PtrPointsTo x)) x :ruleset memory-helpers) +(constructor UnwrapTuplePointsTo (Pointees) List) +(rewrite (UnwrapTuplePointsTo (TuplePointsTo x)) x :ruleset memory-helpers) +(relation PointsNowhere (Pointees)) +(rule ((= f (PtrPointsTo x)) (PointsNowhere-PtrPointees x)) ((PointsNowhere f)) :ruleset memory-helpers) +(rule ((= f (TuplePointsTo l)) (All l)) ((PointsNowhere f)) :ruleset memory-helpers) +(constructor UnionPointees (Pointees Pointees) Pointees) +(rewrite (UnionPointees (PtrPointsTo x) (PtrPointsTo y)) (PtrPointsTo (Union-PtrPointees x y)) :ruleset memory-helpers) +(rewrite (UnionPointees (TuplePointsTo x) (TuplePointsTo y)) (TuplePointsTo (Zip x y)) :when ((= (Length-List x) (Length-List y))) :ruleset memory-helpers) +(constructor IntersectPointees (Pointees Pointees) Pointees) +(rewrite (IntersectPointees (PtrPointsTo x) (PtrPointsTo y)) (PtrPointsTo (Intersect-PtrPointees x y)) :ruleset memory-helpers) +(rewrite (IntersectPointees (TuplePointsTo x) (TuplePointsTo y)) (TuplePointsTo (Zip x y)) :ruleset memory-helpers) +(constructor GetPointees (Pointees i64) Pointees) +(rule ((= f (GetPointees (TuplePointsTo l) i)) (At-List l i x)) ((union f (PtrPointsTo x))) :ruleset memory-helpers) +(constructor PointeesDropFirst (Pointees) Pointees) +(rewrite (PointeesDropFirst (TuplePointsTo (Cons-List hd tl))) (TuplePointsTo tl) :ruleset memory-helpers) +(relation Resolved-IntOrInfinity (IntOrInfinity)) +(rule ((= f (I _))) ((Resolved-IntOrInfinity f)) :ruleset memory-helpers) +(rule ((= f (Infinity))) ((Resolved-IntOrInfinity f)) :ruleset memory-helpers) +(rule ((= f (NegInfinity))) ((Resolved-IntOrInfinity f)) :ruleset memory-helpers) +(relation Resolved-IntInterval (IntInterval)) +(rule ((= f (MkIntInterval lo hi)) (Resolved-IntOrInfinity lo) (Resolved-IntOrInfinity hi)) ((Resolved-IntInterval f)) :ruleset memory-helpers) +(relation Resolved-List (List)) +(rule ((= f (Nil-List))) ((Resolved-List f)) :ruleset memory-helpers) +(rule ((= f (Cons-List allocid offsets tl)) (Resolved-List tl) (Resolved-IntInterval offsets)) ((Resolved-List f)) :ruleset memory-helpers) +(relation Resolved-PtrPointees (PtrPointees)) +(rule ((= f (PointsAnywhere))) ((Resolved-PtrPointees f)) :ruleset memory-helpers) +(rule ((= f (PointsTo x)) (Resolved-List x)) ((Resolved-PtrPointees f)) :ruleset memory-helpers) +(relation Resolved-List (List)) +(rule ((= f (Nil-List))) ((Resolved-List f)) :ruleset memory-helpers) +(rule ((= f (Cons-List hd tl)) (Resolved-List tl) (Resolved-PtrPointees hd)) ((Resolved-List f)) :ruleset memory-helpers) +(relation Resolved-Pointees (Pointees)) +(rule ((= f (TuplePointsTo x)) (Resolved-List x)) ((Resolved-Pointees f)) :ruleset memory-helpers) +(rule ((= f (PtrPointsTo x)) (Resolved-PtrPointees x)) ((Resolved-Pointees f)) :ruleset memory-helpers) +(constructor BaseTypeToPtrPointees (BaseType) PtrPointees :cost 100) +(rewrite (BaseTypeToPtrPointees (PointerT _)) (PointsAnywhere) :ruleset memory-helpers) +(rewrite (BaseTypeToPtrPointees (IntT)) (PointsTo (Nil-List)) :ruleset memory-helpers) +(rewrite (BaseTypeToPtrPointees (StateT)) (PointsTo (Nil-List)) :ruleset memory-helpers) +(rewrite (BaseTypeToPtrPointees (BoolT)) (PointsTo (Nil-List)) :ruleset memory-helpers) +(constructor TypeListToList (TypeList) List :cost 1000) +(rewrite (TypeListToList (TNil)) (Nil-List) :ruleset memory-helpers) +(rewrite (TypeListToList (TCons hd tl)) (Cons-List (BaseTypeToPtrPointees hd) (TypeListToList tl)) :ruleset memory-helpers) +(constructor TypeToPointees (Type) Pointees :cost 1000) +(rewrite (TypeToPointees (TupleT tylist)) (TuplePointsTo (TypeListToList tylist)) :ruleset memory-helpers) +(rewrite (TypeToPointees (Base basety)) (PtrPointsTo (BaseTypeToPtrPointees basety)) :ruleset memory-helpers) +(relation PointerishType (Type)) +(relation PointerishTypeList (TypeList)) +(rule ((= f (Base (PointerT ty)))) ((PointerishType f)) :ruleset always-run) +(rule ((= f (TCons (PointerT ty) tl))) ((PointerishTypeList f)) :ruleset always-run) +(rule ((= f (TCons hd tl)) (PointerishTypeList tl)) ((PointerishTypeList f)) :ruleset always-run) +(rule ((= f (TupleT l)) (PointerishTypeList l)) ((PointerishType f)) :ruleset always-run) +(constructor PointsToCells (Expr Pointees) Pointees :unextractable) +(rule ((Function name in-ty out-ty body)) ((PointsToCells body (TypeToPointees in-ty))) :ruleset memory-helpers) +(rule ((PointsToCells (Bop (Print) e state) ap)) ((PointsToCells state ap)) :ruleset memory-helpers) +(rule ((PointsToCells (Bop (Load) e state) ap)) ((PointsToCells e ap) (PointsToCells state ap)) :ruleset memory-helpers) +(rule ((PointsToCells (Top (Write) ptr val state) ap)) ((PointsToCells ptr ap) (PointsToCells state ap)) :ruleset memory-helpers) +(rule ((PointsToCells (Alloc id sz state ty) ap)) ((PointsToCells state ap)) :ruleset memory-helpers) +(rule ((PointsToCells (Bop (Free) ptr state) ap)) ((PointsToCells ptr ap) (PointsToCells state ap)) :ruleset memory-helpers) +(rule ((PointsToCells (Get x i) ap)) ((PointsToCells x ap)) :ruleset memory-helpers) +(rule ((PointsToCells (Concat x y) ap)) ((PointsToCells x ap) (PointsToCells y ap)) :ruleset memory-helpers) +(rule ((PointsToCells (Single x) ap)) ((PointsToCells x ap)) :ruleset memory-helpers) +(rewrite (PointsToCells concat-x-y aps) (TuplePointsTo (Concat-List (UnwrapTuplePointsTo (PointsToCells x aps)) (UnwrapTuplePointsTo (PointsToCells y aps)))) :when ((= concat-x-y (Concat x y)) (HasType concat-x-y ty) (PointerishType ty)) :ruleset memory-helpers) +(rewrite (PointsToCells get-x-i aps) (GetPointees (PointsToCells x aps) i) :when ((= get-x-i (Get x i)) (HasType get-x-i ty) (PointerishType ty)) :ruleset memory-helpers) +(rewrite (PointsToCells (Single x) aps) (TuplePointsTo (Cons-List (UnwrapPtrPointsTo (PointsToCells x aps)) (Nil-List))) :when ((HasType (Single x) ty) (PointerishType ty)) :ruleset memory-helpers) +(rewrite (PointsToCells (Arg ty_ ctx) aps) aps :when ((HasType (Arg ty_ ctx) ty) (PointerishType ty)) :ruleset memory-helpers) +(rule ((PointsToCells x aps) (HasType x ty)) ((TypeToPointees ty)) :ruleset memory-helpers) +(rule ((= f (PointsToCells x aps)) (HasType x ty) (= pointees (TypeToPointees ty)) (PointsNowhere pointees)) ((union f pointees)) :ruleset memory-helpers) +(rewrite (PointsToCells (Bop (PtrAdd) x e) aps) (PtrPointsTo (AddIntIntervalToPtrPointees (MkIntInterval (I lo) (I hi)) (UnwrapPtrPointsTo (PointsToCells x aps)))) :when ((= lo (either-unwrap-left (maybe-unwrap (lo-bound e)))) (= hi (either-unwrap-left (maybe-unwrap (hi-bound e))))) :ruleset memory-helpers) +(rewrite (PointsToCells (If c inputs t e) aps) (UnionPointees (PointsToCells t (PointsToCells inputs aps)) (PointsToCells e (PointsToCells inputs aps))) :when ((HasType (If c inputs t e) ty) (PointerishType ty)) :ruleset memory) +(rewrite (PointsToCells (Alloc id sz state ty) aps) (TuplePointsTo (Cons-List (PointsTo (Cons-List id (MkIntInterval (I 0) (I 0)) (Nil-List))) (Cons-List (PointsTo (Nil-List)) (Nil-List)))) :ruleset memory-helpers) +(constructor PointsToCellsAtIter (Pointees Expr Expr i64) Pointees) +(rule ((= e (DoWhile inputs pred-body)) (PointsToCells e aps)) ((union (PointsToCellsAtIter aps inputs pred-body 0) (PointsToCells inputs aps)) (union (PointsToCellsAtIter aps inputs pred-body 1) (UnionPointees (PointsToCellsAtIter aps inputs pred-body 0) (PointeesDropFirst (PointsToCells pred-body (PointsToCellsAtIter aps inputs pred-body 0)))))) :ruleset memory-helpers) +(function succ (i64) i64 :merge old) +(rule ((PointsToCellsAtIter aps inputs pred-body i)) ((set (succ i) (+ i 1))) :ruleset memory-helpers) +(rule ((= pointees0 (PointsToCellsAtIter aps inputs pred-body i)) (= pointees1 (PointsToCellsAtIter aps inputs pred-body (succ i))) (Resolved-Pointees pointees0) (Resolved-Pointees pointees1) (!= pointees0 pointees1)) ((union (PointsToCellsAtIter aps inputs pred-body (+ i 2)) (UnionPointees pointees1 (PointeesDropFirst (PointsToCells pred-body pointees1))))) :ruleset memory) +(rule ((= pointees (PointsToCellsAtIter aps inputs pred-body i)) (= pointees (PointsToCellsAtIter aps inputs pred-body (succ i)))) ((union (PointsToCells (DoWhile inputs pred-body) aps) pointees)) :ruleset memory) +(rule ((PtrPointsTo (PointsTo l))) ((DemandAt-List l)) :ruleset memory-helpers) +(rule ((TuplePointsTo l)) ((DemandAt-List l)) :ruleset memory-helpers) +(relation DemandDontAlias (Expr Expr Pointees)) +(relation DontAlias (Expr Expr Pointees)) +(rule ((DemandDontAlias ptr1 ptr2 arg-pointees) (BodyContainsExpr body ptr1) (BodyContainsExpr body ptr2) (HasType ptr1 (Base (PointerT ty))) (HasType ptr2 (Base (PointerT ty))) (= pointees1 (PointsToCells ptr1 arg-pointees)) (= pointees2 (PointsToCells ptr2 arg-pointees))) ((IntersectPointees pointees1 pointees2)) :ruleset memory-helpers) +(rule ((PointsNowhere (IntersectPointees (PointsToCells ptr1 arg-pointees) (PointsToCells ptr2 arg-pointees)))) ((DontAlias ptr1 ptr2 arg-pointees)) :ruleset memory-helpers) +(constructor PointsToExpr (Expr Expr) Expr :unextractable) +(rule ((= f (Bop (Load) ptr state))) ((union (PointsToExpr (Get f 1) ptr) (Get f 0))) :ruleset memory-helpers) +(rule ((= f (PointsToExpr state addr)) (= e (Bop (Load) any-addr state))) ((let new-state (Get e 1)) (union (PointsToExpr new-state addr) f)) :ruleset memory-helpers) +(rule ((= f (PointsToExpr state addr)) (= e (Bop (Print) any-val state))) ((let new-state e) (union (PointsToExpr new-state addr) f)) :ruleset memory-helpers) +(rule ((= e (Top (Write) addr data state)) (HasArgType addr argty) (= otherdata (PointsToExpr state otheraddr))) ((DemandDontAlias addr otheraddr (TypeToPointees argty))) :ruleset memory-helpers) +(rule ((= e (Top (Write) addr data state)) (HasArgType addr argty) (= otherdata (PointsToExpr state otheraddr)) (DontAlias addr otheraddr (TypeToPointees argty))) ((union (PointsToExpr e otheraddr) otherdata)) :ruleset memory-helpers) +(rule ((= e (Top (Write) addr data state))) ((union (PointsToExpr e addr) data)) :ruleset memory-helpers) +(ruleset mem-simple) +(relation NoAlias (Expr Expr)) +(rule ((= if (If pred inputs thn els)) (= (Get inputs i) inputs-i) (= (Get inputs j) inputs-j) (NoAlias inputs-i inputs-j) (= arg-i (Get (Arg ty (InIf which pred inputs)) i)) (= arg-j (Get (Arg ty (InIf which pred inputs)) j))) ((panic "context should not be present")) :ruleset mem-simple) +(rule ((Bop (PtrAdd) e i) (= lo (either-unwrap-left (maybe-unwrap (lo-bound i)))) (> lo 0)) ((NoAlias e (Bop (PtrAdd) e i))) :ruleset mem-simple) +(rule ((Bop (PtrAdd) e i) (= hi (either-unwrap-left (maybe-unwrap (hi-bound i)))) (< hi 0)) ((NoAlias e (Bop (PtrAdd) e i))) :ruleset mem-simple) +(rule ((= p1 (Bop (PtrAdd) p i)) (= p2 (Bop (PtrAdd) p (Bop (Add) i diff))) (= lo (either-unwrap-left (maybe-unwrap (lo-bound diff)))) (> lo 0)) ((NoAlias p1 p2)) :ruleset mem-simple) +(rule ((= p1 (Bop (PtrAdd) p i)) (= p2 (Bop (PtrAdd) p (Bop (Add) i diff))) (= hi (either-unwrap-left (maybe-unwrap (hi-bound diff)))) (< hi 0)) ((NoAlias p1 p2)) :ruleset mem-simple) +(rule ((= p1 (Bop (PtrAdd) p i)) (= p2 (Bop (PtrAdd) p (Bop (Sub) i diff))) (= lo (either-unwrap-left (maybe-unwrap (lo-bound diff)))) (> lo 0)) ((NoAlias p1 p2)) :ruleset mem-simple) +(rule ((= p1 (Bop (PtrAdd) p i)) (= p2 (Bop (PtrAdd) p (Bop (Sub) i diff))) (= hi (either-unwrap-left (maybe-unwrap (hi-bound diff)))) (< hi 0)) ((NoAlias p1 p2)) :ruleset mem-simple) +(rule ((NoAlias x y)) ((NoAlias y x)) :ruleset mem-simple) +(relation DidMemOptimization (String)) +(rule ((NoAlias write-addr load-addr) (= write (Top (Write) write-addr write-val state)) (= load (Bop (Load) load-addr write))) ((let new-load (Bop (Load) load-addr state)) (union (Get load 1) (Top (Write) write-addr write-val (Get new-load 1))) (union (Get load 0) (Get new-load 0)) (DidMemOptimization "commute write then load")) :ruleset mem-simple) +(rule ((= first-load (Bop (Load) addr state)) (= second-load (Bop (Load) addr first-load))) ((union (Get first-load 0) (Get second-load 0)) (union (Get first-load 1) (Get second-load 1)) (DidMemOptimization "duplicate load")) :ruleset mem-simple) +(rule ((= write (Top (Write) addr write-val state)) (= load (Bop (Load) addr write))) ((union (Get load 0) write-val) (union (Get load 1) write) (DidMemOptimization "store forward")) :ruleset mem-simple) +(rule ((= first-write (Top (Write) addr write-val state)) (= second-write (Top (Write) addr write-val first-write))) ((union first-write second-write) (DidMemOptimization "duplicate write")) :ruleset mem-simple) +(rule ((= first-write (Top (Write) addr shadowed-val state)) (= second-write (Top (Write) addr write-val first-write))) ((union second-write (Top (Write) addr write-val state)) (DidMemOptimization "shadowed write")) :ruleset mem-simple) +(relation is-inv-Expr (Expr Expr)) +(relation is-inv-ListExpr (Expr ListExpr)) +(relation is-inv-ListExpr-helper (Expr ListExpr i64)) +(rule ((BodyContainsListExpr body list)) ((is-inv-ListExpr-helper body list 0)) :ruleset always-run) +(rule ((is-inv-ListExpr-helper body list i) (is-inv-Expr body (ListExpr-ith list i))) ((is-inv-ListExpr-helper body list (+ i 1))) :ruleset always-run) +(rule ((is-inv-ListExpr-helper body list i) (= i (ListExpr-length list))) ((is-inv-ListExpr body list)) :ruleset always-run) +(ruleset boundary-analysis) +(ruleset boundary-analysis-prep) +(function to-hoist (Expr Expr) Expr :merge new) +(function to-hoist-size (Expr Expr) i64 :merge (max old new)) +(rule ((is-inv-Expr body expr) (DoWhile inputs body) (HasType expr inv_type) (= inv_type (Base base_inv_ty)) (= size (Expr-size expr))) ((set (to-hoist-size inputs body) size)) :ruleset boundary-analysis-prep) +(rule ((is-inv-Expr body expr) (DoWhile inputs body) (HasType expr inv_type) (= inv_type (Base base_inv_ty)) (= (Expr-size expr) (to-hoist-size inputs body))) ((set (to-hoist inputs body) expr)) :ruleset boundary-analysis) +(ruleset loop-inv-motion) +(rule ((BodyContainsExpr body expr) (= loop (DoWhile in body)) (= expr (Const _n _ty _ctx))) ((is-inv-Expr body expr)) :ruleset always-run) +(rule ((BodyContainsExpr body expr) (= loop (DoWhile in body)) (= expr (Get (Arg ty ctx) i)) (= expr (Get body (+ i 1)))) ((is-inv-Expr body expr)) :ruleset always-run) +(rule ((BodyContainsExpr body expr) (= loop (DoWhile in body)) (= expr (Function _name _tyin _tyout _out))) ((is-inv-Expr body expr)) :ruleset always-run) +(rule ((BodyContainsExpr body expr) (= loop (DoWhile in body)) (= expr (Top _op _x _y _z)) (is-inv-Expr body _x) (is-inv-Expr body _y) (is-inv-Expr body _z)) ((is-inv-Expr body expr)) :ruleset always-run) +(rule ((BodyContainsExpr body expr) (= loop (DoWhile in body)) (= expr (Bop _op _x _y)) (BinaryOpIsPure _op) (is-inv-Expr body _x) (is-inv-Expr body _y)) ((is-inv-Expr body expr)) :ruleset always-run) +(rule ((BodyContainsExpr body expr) (= loop (DoWhile in body)) (= expr (Uop _op _x)) (UnaryOpIsPure _op) (is-inv-Expr body _x)) ((is-inv-Expr body expr)) :ruleset always-run) +(rule ((BodyContainsExpr body expr) (= loop (DoWhile in body)) (= expr (Get _tup _i)) (is-inv-Expr body _tup)) ((is-inv-Expr body expr)) :ruleset always-run) +(rule ((BodyContainsExpr body expr) (= loop (DoWhile in body)) (= expr (Concat _x _y)) (is-inv-Expr body _x) (is-inv-Expr body _y)) ((is-inv-Expr body expr)) :ruleset always-run) +(rule ((BodyContainsExpr body expr) (= loop (DoWhile in body)) (= expr (Single _x)) (is-inv-Expr body _x)) ((is-inv-Expr body expr)) :ruleset always-run) +(rule ((BodyContainsExpr body expr) (= loop (DoWhile in body)) (= expr (Switch _pred _inputs _branches)) (is-inv-Expr body _pred) (is-inv-Expr body _inputs) (is-inv-ListExpr body _branches)) ((is-inv-Expr body expr)) :ruleset always-run) +(rule ((BodyContainsExpr body expr) (= loop (DoWhile in body)) (= expr (If _pred _input _then _else)) (is-inv-Expr body _pred) (is-inv-Expr body _input)) ((is-inv-Expr body expr)) :ruleset always-run) +(rule ((BodyContainsExpr body expr) (= loop (DoWhile in body)) (= expr (DoWhile _in _pred-and-output)) (is-inv-Expr body _in) (ExprIsPure expr)) ((is-inv-Expr body expr)) :ruleset always-run) +(rule ((BodyContainsExpr body expr) (= loop (DoWhile in body)) (= expr (Call _func _arg)) (is-inv-Expr body _arg) (ExprIsPure expr)) ((is-inv-Expr body expr)) :ruleset always-run) +(rule ((BodyContainsExpr body expr) (= loop (DoWhile in body)) (= expr (Empty _ty _ctx))) ((is-inv-Expr body expr)) :ruleset always-run) +(ruleset loop-unroll) +(ruleset loop-iters-analysis) +(rule ((DoWhile inputs outputs)) ((set (LoopNumItersGuess inputs outputs) 1000)) :ruleset loop-iters-analysis) +(rule ((= loop (DoWhile inputs outputs)) (= (Const (Bool false) ty ctx) (Get outputs 0))) ((set (LoopNumItersGuess inputs outputs) 1) (LoopIsFinite inputs outputs)) :ruleset loop-iters-analysis) +(rule ((= lhs (DoWhile inputs outputs)) (= pred (Get outputs 0)) (= (Const (Int start_const) _ty1 _ctx1) (Get inputs counter_i)) (= next_counter (Get outputs (+ counter_i 1))) (= next_counter (Bop (Add) (Get (Arg _ty _ctx) counter_i) (Const (Int increment) _ty2 _ctx2))) (> increment 0) (= pred (Bop (LessThan) next_counter (Const (Int end_constant) _ty3 _ctx3))) (>= end_constant start_const)) ((set (LoopNumItersGuess inputs outputs) (/ (- end_constant start_const) increment)) (LoopIsFinite inputs outputs)) :ruleset loop-iters-analysis) +(rule ((= lhs (DoWhile inputs outputs)) (= pred (Get outputs 0)) (= (Const (Int start_const) _ty1 _ctx1) (Get inputs counter_i)) (= body-arg (Get (Arg _ty _ctx) counter_i)) (= next_counter (Get outputs (+ counter_i 1))) (= next_counter (Bop (Add) body-arg (Const (Int increment) _ty2 _ctx2))) (> increment 0) (= pred (Bop (LessThan) body-arg (Const (Int end_constant) _ty3 _ctx3))) (>= end_constant start_const)) ((set (LoopNumItersGuess inputs outputs) (+ (/ (- end_constant start_const) increment) 1)) (LoopIsFinite inputs outputs)) :ruleset loop-iters-analysis) +(rule ((= lhs (DoWhile inputs outputs)) (= num-inputs (tuple-length inputs)) (= pred (Get outputs 0)) (= (Const (Int start_const) _ty1 _ctx1) (Get inputs counter_i)) (= next_counter (Get outputs (+ counter_i 1))) (= next_counter (Bop (Add) (Get (Arg _ty _ctx) counter_i) (Const (Int 1) _ty2 _ctx2))) (= pred (Bop (LessThan) next_counter (Const (Int end_constant) _ty3 _ctx3))) (> end_constant start_const) (= (% start_const 4) 0) (= (% end_constant 4) 0) (= old_cost (LoopNumItersGuess inputs outputs))) ((let one-iter (SubTuple outputs 1 num-inputs)) (let fresh-ctx (unstable-fresh! Assumption)) (let unrolled (Subst fresh-ctx one-iter (Subst fresh-ctx one-iter (Subst fresh-ctx one-iter outputs)))) (union lhs (DoWhile inputs unrolled)) (let actual-ctx DUMMYCTX) (union fresh-ctx actual-ctx) (set (LoopNumItersGuess inputs unrolled) (/ old_cost 4)) (LoopIsFinite inputs unrolled)) :ruleset loop-unroll) +(ruleset swap-if) +(rule ((= lhs (If pred inputs then else))) ((union lhs (If (Uop (Not) pred) inputs else then))) :ruleset swap-if) +(rule ((= lhs (If pred inputs then else)) (= (tuple-length then) 2) (= (tuple-length else) 2)) ((union (Concat (Single (Get lhs 1)) (Single (Get lhs 0))) (If pred inputs (Concat (Single (Get then 1)) (Single (Get then 0))) (Concat (Single (Get else 1)) (Single (Get else 0)))))) :ruleset swap-if) +(ruleset rec-to-loop) +(rule ((Function name in out body) (= body (If pred always-runs (Call name rec_case) base-case)) (HasType always-runs start-ty) (HasType body func-ty)) ((let fresh-ctx (unstable-fresh! Assumption)) (let loop-inputs (Arg start-ty DUMMYCTX)) (let loop-outputs (Concat (Single (Subst fresh-ctx rec_case pred)) (Subst fresh-ctx rec_case always-runs))) (union fresh-ctx DUMMYCTX) (let loop (DoWhile loop-inputs loop-outputs)) (let outer-if (If pred always-runs loop (Arg start-ty DUMMYCTX))) (union (Function name in out body) (Function name in out (Subst DUMMYCTX outer-if base-case)))) :ruleset rec-to-loop) +(relation Accum-Bop (BinaryOp i64 BinaryOp)) +(Accum-Bop (Add) 0 (Add)) +(Accum-Bop (Sub) 0 (Add)) +(Accum-Bop (Mul) 1 (Mul)) +(rule ((Function name in out body) (= body (If pred always-runs then-case base-case)) (= call (Call name rec-case)) (= then-case (Concat (Single (Bop acc-op (Get call 0) extra)) (Single (Get call 1)))) (Accum-Bop acc-op initial-int base-case-op) (HasType always-runs start-ty) (= always-runs-len (tuple-length always-runs)) (= start-ty (TupleT start-ty-list)) (HasType body func-ty) (ContextOf body body-ctx)) ((let loop-ty (TupleT (TLConcat start-ty-list (TCons (IntT) (TNil))))) (let fresh-ctx (unstable-fresh! Assumption)) (let new-rec-case (Subst fresh-ctx (SubTuple (Arg loop-ty fresh-ctx) 0 always-runs-len) rec-case)) (let new-extra (Subst fresh-ctx (SubTuple (Arg loop-ty fresh-ctx) 0 always-runs-len) extra)) (let loop-inputs (Concat (Arg start-ty DUMMYCTX) (Single (Const (Int initial-int) start-ty DUMMYCTX)))) (let loop-outputs (Concat (Single (Subst fresh-ctx new-rec-case pred)) (Concat (Subst fresh-ctx new-rec-case always-runs) (Single (Bop acc-op (Get (Arg loop-ty fresh-ctx) always-runs-len) new-extra))))) (let loop (DoWhile loop-inputs loop-outputs)) (union fresh-ctx DUMMYCTX) (let outer-if (If pred always-runs loop (Concat (Arg start-ty DUMMYCTX) (Single (Const (Int 0) start-ty DUMMYCTX))))) (let new-base-case (Subst body-ctx (SubTuple outer-if 0 always-runs-len) base-case)) (let res (Concat (Single (Bop base-case-op (Get new-base-case 0) (Get outer-if always-runs-len))) (Single (Get new-base-case 1)))) (union (Function name in out body) (Function name in out res))) :ruleset rec-to-loop) +(ruleset passthrough) +(rule ((= lhs (Get loop i)) (= loop (DoWhile inputs pred-outputs)) (= (Get pred-outputs (+ i 1)) (Get (Arg _ty _ctx) i)) (HasType lhs lhs_ty) (PureType lhs_ty)) ((union lhs (Get inputs i))) :ruleset passthrough) +(rule ((= lhs (Get switch i)) (= switch (Switch pred inputs branches)) (= (ListExpr-length branches) 2) (= branch0 (ListExpr-ith branches 0)) (= branch1 (ListExpr-ith branches 1)) (= (Get branch0 i) (Get (Arg _ _ctx0) j)) (= (Get branch1 i) (Get (Arg _ _ctx1) j)) (= passed-through (Get inputs j)) (HasType lhs lhs_ty) (!= lhs_ty (Base (StateT)))) ((union lhs passed-through)) :ruleset passthrough) +(rule ((= lhs (Get switch i)) (= switch (Switch pred inputs branches)) (= (ListExpr-length branches) 2) (= branch0 (ListExpr-ith branches 0)) (= branch1 (ListExpr-ith branches 1)) (= (Get branch0 i) (Const (Bool false) _ _ctx0)) (= (Get branch1 i) (Const (Bool true) _ _ctx1))) ((union lhs pred)) :ruleset passthrough) +(rule ((= if (If pred inputs then_ else_)) (= then-branch (Get then_ i)) (= else-branch (Get else_ i)) (= then-branch (Get (Arg arg_ty _then_ctx) j)) (= else-branch (Get (Arg arg_ty _else_ctx) j)) (HasType then-branch lhs_ty) (!= lhs_ty (Base (StateT)))) ((union (Get if i) (Get inputs j))) :ruleset passthrough) +(ruleset state-edge-passthrough) +(rule ((= outputs (If pred inputs then_ else_)) (= (Get then_ i) (Get (Arg arg_ty then_ctx) j)) (= (Get else_ i) (Get (Arg arg_ty else_ctx) j)) (HasType (Get then_ i) (Base (StateT)))) ((let lhs (Get outputs i)) (let new_inputs (TupleRemoveAt inputs j)) (let new_then_ctx DUMMYCTX) (let new_else_ctx DUMMYCTX) (let old_then (TupleRemoveAt then_ i)) (let old_else (TupleRemoveAt else_ i)) (let new_then (DropAt new_then_ctx j old_then)) (let new_else (DropAt new_else_ctx j old_else)) (let old_outputs (TupleRemoveAt outputs i)) (let new_if (If pred new_inputs new_then new_else)) (union new_if old_outputs) (union lhs (Get inputs j)) (ToSubsumeIf pred inputs then_ else_)) :ruleset state-edge-passthrough) +(rule ((= if (If pred inputs then_ else_)) (= (Get then_ i) (Const (Bool true) _ _thenctx)) (= (Get else_ i) (Const (Bool false) _ _elsectx))) ((let new_then (TupleRemoveAt then_ i)) (let new_else (TupleRemoveAt else_ i)) (let new_if (If pred inputs new_then new_else)) (union (Get if i) pred) (union (TupleRemoveAt if i) new_if) (ToSubsumeIf pred inputs then_ else_)) :ruleset passthrough) +(rule ((= if (If pred inputs then_ else_)) (= (Get then_ i) (Const (Bool false) _ _thenctx)) (= (Get else_ i) (Const (Bool true) _ _elsectx))) ((let new_then (TupleRemoveAt then_ i)) (let new_else (TupleRemoveAt else_ i)) (let new_if (If pred inputs new_then new_else)) (union (Get if i) (Uop (Not) pred)) (union (TupleRemoveAt if i) new_if) (ToSubsumeIf pred inputs then_ else_)) :ruleset passthrough) +(ruleset loop-strength-reduction) +(relation lsr-inv (Expr Expr Expr)) +(rule ((= loop (DoWhile inputs pred-and-body)) (ContextOf inputs loop-input-ctx) (ContextOf pred-and-body loop-output-ctx) (= constant (Const c out-type loop-output-ctx)) (HasArgType inputs in-type)) ((lsr-inv loop (Const c in-type loop-input-ctx) constant)) :ruleset always-run) +(rule ((= old-loop (DoWhile inputs pred-and-outputs)) (ContextOf pred-and-outputs loop-ctx) (lsr-inv old-loop loop-incr-in loop-incr-out) (= (Get pred-and-outputs (+ i 1)) (Bop (Add) (Get (Arg arg-type assm) i) loop-incr-out)) (lsr-inv old-loop c-in c-out) (= old-mul (Bop (Mul) c-out (Get (Arg arg-type assm) i))) (ContextOf old-mul loop-ctx) (= arg-type (TupleT ty-list)) (= n (tuple-length inputs))) ((let addend (Bop (Mul) c-out loop-incr-out)) (let d-init (Bop (Mul) c-in (Get inputs i))) (let new-inputs (Concat inputs (Single d-init))) (let new-arg-ty (TupleT (TLConcat ty-list (TCons (IntT) (TNil))))) (let fresh-ctx (unstable-fresh! Assumption)) (let replace-arg (SubTuple (Arg new-arg-ty fresh-ctx) 0 n)) (let d-out (Bop (Add) (Get (Arg new-arg-ty fresh-ctx) n) (Subst fresh-ctx replace-arg addend))) (let new-body (Concat (Subst fresh-ctx replace-arg pred-and-outputs) (Single d-out))) (let new-loop (DoWhile new-inputs new-body)) (let new-c (Subst fresh-ctx replace-arg c-out)) (union fresh-ctx DUMMYCTX) (let new-mul (Bop (Mul) new-c (Get replace-arg i))) (union (Get (Arg new-arg-ty fresh-ctx) n) new-mul) (let before (Bop (Mul) new-c (Get replace-arg i))) (subsume (Bop (Mul) new-c (Get replace-arg i))) (union old-loop (SubTuple new-loop 0 n))) :ruleset loop-strength-reduction) +(relation IVTNewInputsAnalysisDemand (Expr)) +(ruleset ivt-analysis) +(sort IVTPayload) +(constructor IVTAnalysisPayload (Expr Expr TypeList) IVTPayload) +(sort IVTRes (Pair IVTPayload i64)) +(function IVTNewInputsAnalysisImpl (Expr Expr Node) IVTRes :merge (pair-min-by-second-i64 old new)) +(function IVTNewInputsAnalysis (Expr Node) IVTRes :merge (pair-min-by-second-i64 old new)) +(rule ((DoWhile inpW outW)) ((IVTNewInputsAnalysisDemand outW)) :ruleset ivt-analysis) +(rule ((IVTNewInputsAnalysisDemand loop-body) (= loop-body (Concat (Single pred) rest)) (= if-eclass (If pred inputs thn else)) (= (Get loop-body i) (Get if-eclass j)) (!= i 0)) ((let perm (Empty (TmpType) DUMMYCTX)) (set (IVTNewInputsAnalysisImpl loop-body rest (IfNode if-eclass pred inputs thn else)) (pair (IVTAnalysisPayload perm perm (TNil)) 0))) :ruleset ivt-analysis) +(rule ((= ivt-res (IVTNewInputsAnalysisImpl loop-body curr ifnode)) (= (IVTAnalysisPayload perm pperm passthrough-tys) (pair-first ivt-res)) (= len (pair-second ivt-res)) (= ifnode (IfNode if-eclass pred inputs then else)) (= curr (Concat (Single (Get if-eclass ith)) rest))) ((let new-perm (Concat perm (Single (Get (Arg (TmpType) DUMMYCTX) ith)))) (set (IVTNewInputsAnalysisImpl loop-body rest ifnode) (pair (IVTAnalysisPayload new-perm pperm passthrough-tys) len))) :ruleset ivt-analysis) +(rule ((= ivt-res (IVTNewInputsAnalysisImpl loop-body curr ifnode)) (= (IVTAnalysisPayload perm pperm passthrough-tys) (pair-first ivt-res)) (= len (pair-second ivt-res)) (= ifnode (IfNode if-eclass pred inputs then else)) (= curr (Concat (Single (Get (Arg ty ctx) ith)) rest)) (= (Get loop-body (+ ith 1)) (Get curr 0)) (HasType (Get (Arg ty ctx) ith) (Base new-ty)) (= (tuple-length if-eclass) if-len)) ((let get-passed-through (Single (Get (Arg (TmpType) DUMMYCTX) (+ if-len len)))) (let new-perm (Concat perm get-passed-through)) (let original-get-index (Single (Get (Arg (TmpType) DUMMYCTX) ith))) (let new-pperm (Concat pperm original-get-index)) (let new-passthrough-tys (TLConcat passthrough-tys (TCons new-ty (TNil)))) (set (IVTNewInputsAnalysisImpl loop-body rest ifnode) (pair (IVTAnalysisPayload new-perm new-pperm new-passthrough-tys) (+ len 1)))) :ruleset ivt-analysis) +(rule ((= ivt-res (IVTNewInputsAnalysisImpl loop-body (Single last) ifnode)) (= (IVTAnalysisPayload perm pperm passthrough-tys) (pair-first ivt-res)) (= len (pair-second ivt-res)) (= ifnode (IfNode if-eclass pred inputs then else)) (= last (Get if-eclass ith))) ((let new-perm (Concat perm (Single (Get (Arg (TmpType) DUMMYCTX) ith)))) (set (IVTNewInputsAnalysis loop-body ifnode) (pair (IVTAnalysisPayload new-perm pperm passthrough-tys) len))) :ruleset ivt-analysis) +(rule ((= ivt-res (IVTNewInputsAnalysisImpl loop-body curr ifnode)) (= (IVTAnalysisPayload perm pperm passthrough-tys) (pair-first ivt-res)) (= len (pair-second ivt-res)) (= ifnode (IfNode if-eclass pred inputs then else)) (= curr (Single (Get (Arg ty ctx) ith))) (= (Get loop-body (+ ith 1)) (Get curr 0)) (HasType (Get (Arg ty ctx) ith) (Base new-ty)) (= (tuple-length if-eclass) if-len)) ((let get-passed-through (Single (Get (Arg (TmpType) DUMMYCTX) (+ if-len len)))) (let new-perm (Concat perm get-passed-through)) (let original-get-index (Single (Get (Arg (TmpType) DUMMYCTX) ith))) (let new-pperm (Concat pperm original-get-index)) (let new-passthrough-tys (TLConcat passthrough-tys (TCons new-ty (TNil)))) (set (IVTNewInputsAnalysis loop-body ifnode) (pair (IVTAnalysisPayload new-perm new-pperm new-passthrough-tys) (+ len 1)))) :ruleset ivt-analysis) +(ruleset loop-inversion) +(rule ((= loop (DoWhile inpW outW)) (= (IVTAnalysisPayload perm pperm passthrough-tys) (pair-first (IVTNewInputsAnalysis outW ifnode))) (= ifnode (IfNode if if-cond if-inputs then else)) (= if-inputs-len (tuple-length if-inputs)) (= passthrough-len (TypeList-length passthrough-tys)) (ContextOf inpW outer-ctx) (ContextOf if-inputs if-ctx) (HasType if-inputs inputs-ty) (= inputs-ty (TupleT inputs-ty-list))) ((let new-if-cond (Subst outer-ctx inpW if-cond)) (let new-if-inp (Concat (Subst outer-ctx inpW if-inputs) (Subst outer-ctx inpW pperm))) (let new-if-true-ctx DUMMYCTX) (let new-if-false-ctx DUMMYCTX) (let new-loop-arg-ty (TupleT (TLConcat inputs-ty-list passthrough-tys))) (let new-loop-context (unstable-fresh! Assumption)) (let new-loop-arg (Arg new-loop-arg-ty new-loop-context)) (let then-arg (SubTuple new-loop-arg 0 if-inputs-len)) (let new-then-branch (Subst new-loop-context then-arg then)) (let then-branch-and-passthrough (Concat new-then-branch (SubTuple new-loop-arg if-inputs-len passthrough-len))) (let permuted-then-branch-and-passthrough (Subst new-loop-context then-branch-and-passthrough perm)) (let new-inputs-after-then-branch (Subst new-loop-context permuted-then-branch-and-passthrough (Concat (Single if-cond) if-inputs))) (let new-loop-outputs (Concat new-inputs-after-then-branch (SubTuple new-loop-arg if-inputs-len passthrough-len))) (let new-loop (DoWhile (Arg new-loop-arg-ty new-if-true-ctx) new-loop-outputs)) (let new-if (If new-if-cond new-if-inp new-loop (Arg new-loop-arg-ty new-if-false-ctx))) (let final-if-inputs (SubTuple new-if 0 if-inputs-len)) (let else-branch-end (Subst outer-ctx final-if-inputs else)) (let else-branch-end-and-passthrough (Concat else-branch-end (SubTuple new-if if-inputs-len passthrough-len))) (let final-permuted (Subst outer-ctx else-branch-end-and-passthrough perm)) (union final-permuted loop) (union new-loop-context DUMMYCTX) (subsume (DoWhile inpW outW))) :ruleset loop-inversion) +(ruleset cicm) +(ruleset cicm-index) +(relation InvCodeMotionCandidate (Expr Expr)) +(relation ExtractedExprCache (Term Expr Assumption)) +(rule ((= t1 (pair-first (ExtractedExpr e1))) (ContextOf e1 ctx1)) ((ExtractedExprCache t1 e1 ctx1)) :ruleset cicm-index) +(rule ((ExtractedExprCache t1 e1 (InIf true pred1 orig_ins3)) (ExtractedExprCache t1 e2 (InIf false pred2 orig_ins4)) (!= e1 e2)) ((panic "context should not be present")) :ruleset cicm-index) +(rule ((= if_e (If pred orig_ins thn els)) (HasArgType thn (TupleT tylist)) (HasArgType els (TupleT tylist)) (ContextOf if_e outer_ctx) (= e1 (Uop o x)) (HasType e1 (Base ty)) (= t1 (pair-first (ExtractedExpr e1))) (> 10 (Expr-size e1)) (ExprIsPure e1) (ContextOf e1 (InIf true pred orig_ins)) (= e2 (Uop o y)) (HasType e2 (Base ty)) (= t1 (pair-first (ExtractedExpr e2))) (> 10 (Expr-size e2)) (ExprIsPure e2) (ContextOf e2 (InIf false pred orig_ins)) (= orig_ins_len (TypeList-length tylist))) ((panic "context should not be present")) :ruleset cicm) +(rule ((InvCodeMotionCandidate e1 e2) (= if_e (If pred orig_ins thn els)) (HasArgType thn (TupleT tylist)) (HasArgType els (TupleT tylist)) (ContextOf if_e outer_ctx) (ContextOf e1 (InIf true pred orig_ins)) (ContextOf e2 (InIf false pred orig_ins)) (= e1 (Bop o x1 y1)) (= e2 (Bop o x2 y2)) (= t1 (pair-first (ExtractedExpr e1))) (> 10 (Expr-size e1)) (ExprIsPure e1) (HasType e1 (Base ty)) (HasType e2 (Base ty)) (= t1 (pair-first (ExtractedExpr e2))) (> 10 (Expr-size e2)) (ExprIsPure e2) (= orig_ins_len (TypeList-length tylist))) ((panic "context should not be present")) :ruleset cicm) +(ruleset push-in) +(ruleset debug-deletes) +(rule ((HasType a b)) ((delete (HasType a b))) :ruleset debug-deletes) +(rule ((BodyContainsExpr a b)) ((delete (BodyContainsExpr a b))) :ruleset debug-deletes) +(rule ((ExprIsPure e)) ((delete (ExprIsPure e))) :ruleset debug-deletes) +(rule ((HasArgType e ty)) ((delete (HasArgType e ty))) :ruleset debug-deletes) +(rule ((is-inv-Expr e ty)) ((delete (is-inv-Expr e ty))) :ruleset debug-deletes) +(rule ((tuple-length e)) ((delete (tuple-length e))) :ruleset debug-deletes) +(rule ((BinaryOpIsPure e)) ((delete (BinaryOpIsPure e))) :ruleset debug-deletes) +(rule ((ContextOf e a)) ((delete (ContextOf e a))) :ruleset debug-deletes) +(rule ((ExprIsResolved e)) ((delete (ExprIsResolved e))) :ruleset debug-deletes) +(rule ((bop->string a b)) ((delete (bop->string a b))) :ruleset debug-deletes) +(rule ((bpred-of-type a b)) ((delete (bpred-of-type a b))) :ruleset debug-deletes) +(rule ((PureType e)) ((delete (PureType e))) :ruleset debug-deletes) +(rule ((PointsToCells a b)) ((delete (PointsToCells a b))) :ruleset debug-deletes) +(rule ((TuplePointsTo e)) ((delete (TuplePointsTo e))) :ruleset debug-deletes) +(rule ((Resolved-List e)) ((delete (Resolved-List e))) :ruleset debug-deletes) +(rule ((TypeListToList e)) ((delete (TypeListToList e))) :ruleset debug-deletes) +(rule ((Cons-List a b)) ((delete (Cons-List a b))) :ruleset debug-deletes) +(rule ((Nil-List)) ((delete (Nil-List))) :ruleset debug-deletes) +(rule ((Length-List e)) ((delete (Length-List e))) :ruleset debug-deletes) +(rule ((At-List a b c)) ((delete (At-List a b c))) :ruleset debug-deletes) +(rule ((IsNonEmpty-List a)) ((delete (IsNonEmpty-List a))) :ruleset debug-deletes) +(rule ((Resolved-List e)) ((delete (Resolved-List e))) :ruleset debug-deletes) +(rule ((Cons-List a b c)) ((delete (Cons-List a b c))) :ruleset debug-deletes) +(rule ((Nil-List)) ((delete (Nil-List))) :ruleset debug-deletes) +(rule ((Length-List e)) ((delete (Length-List e))) :ruleset debug-deletes) +(rule ((At-List a b c d)) ((delete (At-List a b c d))) :ruleset debug-deletes) +(rule ((IsNonEmpty-List a)) ((delete (IsNonEmpty-List a))) :ruleset debug-deletes) +(rule ((TypeList-ith a b)) ((delete (TypeList-ith a b))) :ruleset debug-deletes) +(rule ((TupleT a)) ((delete (TupleT a))) :ruleset debug-deletes) +(rule ((TCons a b)) ((delete (TCons a b))) :ruleset debug-deletes) +(rule ((TNil)) ((delete (TNil))) :ruleset debug-deletes) +(rule ((Base a)) ((delete (Base a))) :ruleset debug-deletes) +(rule ((IntT)) ((delete (IntT))) :ruleset debug-deletes) +(ruleset hacker) +(relation IsIsEven (Expr Expr)) +(rule ((= two (Const (Int 2) _ty _ctx)) (= e (Bop (Eq) x (Bop (Mul) (Bop (Div) x two) two)))) ((IsIsEven e x)) :ruleset hacker) +(relation NTZIterations (Expr Expr i64)) +(rule ((= outerif (If cond inputs evenbr oddbr)) (= n (Get inputs i)) (IsIsEven cond n) (= evenbr (DoWhile lp_inputs lp_pred_outputs)) (= (Get lp_inputs j) (Get (Arg _ty1 _ctx1) i)) (= two (Const (Int 2) _ty2 _ctx2)) (= nd2 (Bop (Div) (Get (Arg _ty3 _ctx3) j) two)) (IsIsEven (Get lp_pred_outputs 0) nd2) (= nd2 (Get lp_pred_outputs (+ j 1))) (= (Get (Arg _ty4 _ctx4) i) (Get oddbr j))) ((NTZIterations outerif n j)) :ruleset hacker) +(rule ((NTZIterations outerif n i) (= outerif (If cond inputs evenbr oddbr)) (= evenbr (DoWhile lp_inputs lp_pred_outputs)) (= (Get lp_pred_outputs (+ k 1)) (Get (Arg _sty _sctx) k)) (HasType (Get lp_pred_outputs (+ k 1)) (Base (StateT))) (ContextOf outerif outer-ctx) (HasArgType inputs outer-arg-ty) (HasType inputs inputs-ty) (= nInputs (tuple-length inputs))) ((let zero (Const (Int 0) outer-arg-ty outer-ctx)) (let is-n-zero (Bop (Eq) n zero)) (let then-if-ctx DUMMYCTX) (let inf-loop-input (Arg inputs-ty then-if-ctx)) (let true-const (Const (Bool true) inputs-ty DUMMYCTX)) (let inf-loop-body (Concat (Single true-const) (SubTuple (Arg inputs-ty DUMMYCTX) 0 nInputs))) (let inf-loop (DoWhile inf-loop-input inf-loop-body)) (let else-if-ctx DUMMYCTX) (let else-arg (Arg inputs-ty else-if-ctx)) (let state-if (If is-n-zero inputs inf-loop else-arg)) (union (Get outerif k) (Get state-if k))) :ruleset hacker) +(rule ((NTZIterations outerif n i) (= outerif (If cond inputs evenbr oddbr)) (= evenbr (DoWhile lp_inputs lp_pred_outputs)) (= (Const (Int 1) _ty1 _ctx1) (Get lp_inputs j)) (= two (Const (Int 2) _ty2 _ctx2)) (= (Bop (Mul) (Get (Arg _ty3 _ctx3) j) two) (Get lp_pred_outputs (+ j 1))) (= (Const (Int 1) _ty0 _ctx0) (Get oddbr j))) ((let lowbitn (Bop (Bitand) n (Uop (Neg) n))) (union (Get outerif j) lowbitn) (union (Get outerif i) (Bop (Div) n lowbitn))) :ruleset hacker) +(ruleset non-weakly-linear) +(rule ((= pred (Const (Bool true) _ty ctx)) (= if_e (If pred inputs thn els))) ((union if_e (Subst ctx inputs thn))) :ruleset non-weakly-linear) +(rule ((= pred (Const (Bool false) _ty ctx)) (= if_e (If pred inputs thn els))) ((union if_e (Subst ctx inputs els))) :ruleset non-weakly-linear) +(rule ((= load (Bop (Load) load-addr state))) ((union (Get load 1) state)) :ruleset non-weakly-linear) +(rule ((= if (If pred inputs then_ else_)) (= then-branch (Get then_ i)) (= else-branch (Get else_ i)) (= then-branch (Get (Arg arg_ty _then_ctx) j)) (= else-branch (Get (Arg arg_ty _else_ctx) j))) ((union (Get if i) (Get inputs j))) :ruleset non-weakly-linear) +(rule ((= lhs (DoWhile inputs outputs)) (ContextOf lhs ctx) (HasType inputs inputs-ty) (= outputs-len (tuple-length outputs)) (= old_cost (LoopNumItersGuess inputs outputs)) (LoopIsFinite inputs outputs) (<= old_cost 5)) ((let executed-once (Subst ctx inputs outputs)) (let executed-once-body (SubTuple executed-once 1 (- outputs-len 1))) (let then-ctx DUMMYCTX) (let else-ctx DUMMYCTX) (let new-loop-input (Arg inputs-ty then-ctx)) (let fresh-ctx (unstable-fresh! Assumption)) (let new-loop-body (Subst fresh-ctx (Arg inputs-ty fresh-ctx) outputs)) (union DUMMYCTX fresh-ctx) (union lhs (If (Get executed-once 0) executed-once-body (DoWhile new-loop-input new-loop-body) (Arg inputs-ty else-ctx))) (set (LoopNumItersGuess new-loop-input new-loop-body) (- old_cost 1)) (LoopIsFinite new-loop-input new-loop-body)) :ruleset non-weakly-linear) +(rule ((= outputs (If pred inputs then_ else_)) (= (Get then_ i) (Get (Arg arg_ty then_ctx) j)) (= (Get else_ i) (Get (Arg arg_ty else_ctx) j)) (HasType (Get then_ i) (Base (StateT)))) ((union (Get outputs i) (Get inputs j))) :ruleset non-weakly-linear) +(rule ((= lp (DoWhile inputs pred_outputs)) (LoopIsFinite inputs pred_outputs) (= (Get pred_outputs (+ i 1)) (Get (Arg _ty _ctx) i)) (HasType (Get pred_outputs (+ i 1)) (Base (StateT)))) ((union (Get lp i) (Get inputs i))) :ruleset non-weakly-linear) +(unstable-combined-ruleset cheap-optimizations hacker interval-rewrite always-switch-rewrite peepholes) +(unstable-combined-ruleset all-optimizations select_opt loop-unroll switch_rewrite loop-inv-motion loop-strength-reduction cicm push-in hacker interval-rewrite always-switch-rewrite peepholes) + +; required by function_inlining_unoins +; Function inlining unions +(relation InlinedCall (String Expr)) + +(ruleset initialization) +(rule () ( + ; Program nodes + (let __tmp0 (StateT )) +(let __tmp1 (TNil )) +(let __tmp2 (TCons __tmp0 __tmp1)) +(let __tmp3 (TupleT __tmp2)) +(let __tmp4 (Print )) +(let __tmp5 (Int 180)) +(let __tmp6 (InFunc "dummy")) +(let __tmp7 (Const __tmp5 __tmp3 __tmp6)) +(let __tmp8 (Single __tmp7)) +(let __tmp9 (Int 190)) +(let __tmp10 (Const __tmp9 __tmp3 __tmp6)) +(let __tmp11 (Single __tmp10)) +(let __tmp12 (Int 210)) +(let __tmp13 (Const __tmp12 __tmp3 __tmp6)) +(let __tmp14 (Single __tmp13)) +(let __tmp15 (Arg __tmp3 __tmp6)) +(let __tmp16 (Get __tmp15 0)) +(let __tmp17 (Single __tmp16)) +(let __tmp18 (Concat __tmp14 __tmp17)) +(let __tmp19 (Concat __tmp8 __tmp18)) +(let __tmp20 (Call "matrix_new" __tmp19)) +(let __tmp21 (Get __tmp20 0)) +(let __tmp22 (Single __tmp21)) +(let __tmp23 (Get __tmp20 1)) +(let __tmp24 (Single __tmp23)) +(let __tmp25 (Concat __tmp11 __tmp24)) +(let __tmp26 (Concat __tmp14 __tmp25)) +(let __tmp27 (Call "matrix_new" __tmp26)) +(let __tmp28 (Get __tmp27 0)) +(let __tmp29 (Single __tmp28)) +(let __tmp30 (Int 220)) +(let __tmp31 (Const __tmp30 __tmp3 __tmp6)) +(let __tmp32 (Single __tmp31)) +(let __tmp33 (Get __tmp27 1)) +(let __tmp34 (Single __tmp33)) +(let __tmp35 (Concat __tmp32 __tmp34)) +(let __tmp36 (Concat __tmp11 __tmp35)) +(let __tmp37 (Call "matrix_new" __tmp36)) +(let __tmp38 (Get __tmp37 0)) +(let __tmp39 (Single __tmp38)) +(let __tmp40 (Get __tmp37 1)) +(let __tmp41 (Single __tmp40)) +(let __tmp42 (Concat __tmp32 __tmp41)) +(let __tmp43 (Concat __tmp8 __tmp42)) +(let __tmp44 (Call "matrix_new" __tmp43)) +(let __tmp45 (Get __tmp44 0)) +(let __tmp46 (Single __tmp45)) +(let __tmp47 (Float 180.0)) +(let __tmp48 (Const __tmp47 __tmp3 __tmp6)) +(let __tmp49 (Single __tmp48)) +(let __tmp50 (Float 190.0)) +(let __tmp51 (Const __tmp50 __tmp3 __tmp6)) +(let __tmp52 (Single __tmp51)) +(let __tmp53 (Float 210.0)) +(let __tmp54 (Const __tmp53 __tmp3 __tmp6)) +(let __tmp55 (Single __tmp54)) +(let __tmp56 (Float 220.0)) +(let __tmp57 (Const __tmp56 __tmp3 __tmp6)) +(let __tmp58 (Single __tmp57)) +(let __tmp59 (Get __tmp44 1)) +(let __tmp60 (Single __tmp59)) +(let __tmp61 (Concat __tmp58 __tmp60)) +(let __tmp62 (Concat __tmp32 __tmp61)) +(let __tmp63 (Concat __tmp55 __tmp62)) +(let __tmp64 (Concat __tmp14 __tmp63)) +(let __tmp65 (Concat __tmp52 __tmp64)) +(let __tmp66 (Concat __tmp11 __tmp65)) +(let __tmp67 (Concat __tmp49 __tmp66)) +(let __tmp68 (Concat __tmp8 __tmp67)) +(let __tmp69 (Concat __tmp46 __tmp68)) +(let __tmp70 (Concat __tmp39 __tmp69)) +(let __tmp71 (Concat __tmp29 __tmp70)) +(let __tmp72 (Concat __tmp22 __tmp71)) +(let __tmp73 (Call "init" __tmp72)) +(let __tmp74 (Get __tmp73 0)) +(let __tmp75 (Single __tmp74)) +(let __tmp76 (Concat __tmp11 __tmp75)) +(let __tmp77 (Concat __tmp8 __tmp76)) +(let __tmp78 (Call "matrix_new" __tmp77)) +(let __tmp79 (Get __tmp78 1)) +(let __tmp80 (Single __tmp79)) +(let __tmp81 (Get __tmp78 0)) +(let __tmp82 (Single __tmp81)) +(let __tmp83 (Int 0)) +(let __tmp84 (Const __tmp83 __tmp3 __tmp6)) +(let __tmp85 (Single __tmp84)) +(let __tmp86 (Int 1)) +(let __tmp87 (Const __tmp86 __tmp3 __tmp6)) +(let __tmp88 (Single __tmp87)) +(let __tmp89 (Float 1.2)) +(let __tmp90 (Const __tmp89 __tmp3 __tmp6)) +(let __tmp91 (Single __tmp90)) +(let __tmp92 (Float 1.5)) +(let __tmp93 (Const __tmp92 __tmp3 __tmp6)) +(let __tmp94 (Single __tmp93)) +(let __tmp95 (Float 0.0)) +(let __tmp96 (Const __tmp95 __tmp3 __tmp6)) +(let __tmp97 (Single __tmp96)) +(let __tmp98 (Concat __tmp14 __tmp97)) +(let __tmp99 (Concat __tmp94 __tmp98)) +(let __tmp100 (Concat __tmp91 __tmp99)) +(let __tmp101 (Concat __tmp11 __tmp100)) +(let __tmp102 (Concat __tmp88 __tmp101)) +(let __tmp103 (Concat __tmp85 __tmp102)) +(let __tmp104 (Concat __tmp32 __tmp103)) +(let __tmp105 (Concat __tmp8 __tmp104)) +(let __tmp106 (Concat __tmp22 __tmp105)) +(let __tmp107 (Concat __tmp29 __tmp106)) +(let __tmp108 (Concat __tmp39 __tmp107)) +(let __tmp109 (Concat __tmp46 __tmp108)) +(let __tmp110 (Concat __tmp82 __tmp109)) +(let __tmp111 (Concat __tmp80 __tmp110)) +(let __tmp112 (LessThan )) +(let __tmp113 (FloatT )) +(let __tmp114 (PointerT __tmp113)) +(let __tmp115 (IntT )) +(let __tmp116 (TCons __tmp113 __tmp1)) +(let __tmp117 (TCons __tmp115 __tmp116)) +(let __tmp118 (TCons __tmp113 __tmp117)) +(let __tmp119 (TCons __tmp113 __tmp118)) +(let __tmp120 (TCons __tmp115 __tmp119)) +(let __tmp121 (TCons __tmp115 __tmp120)) +(let __tmp122 (TCons __tmp115 __tmp121)) +(let __tmp123 (TCons __tmp115 __tmp122)) +(let __tmp124 (TCons __tmp115 __tmp123)) +(let __tmp125 (TCons __tmp114 __tmp124)) +(let __tmp126 (TCons __tmp114 __tmp125)) +(let __tmp127 (TCons __tmp114 __tmp126)) +(let __tmp128 (TCons __tmp114 __tmp127)) +(let __tmp129 (TCons __tmp114 __tmp128)) +(let __tmp130 (TCons __tmp0 __tmp129)) +(let __tmp131 (TupleT __tmp130)) +(let __tmp132 (Arg __tmp131 __tmp6)) +(let __tmp133 (Get __tmp132 8)) +(let __tmp134 (Get __tmp132 6)) +(let __tmp135 (Bop __tmp112 __tmp133 __tmp134)) +(let __tmp136 (Get __tmp132 0)) +(let __tmp137 (Single __tmp136)) +(let __tmp138 (Get __tmp132 1)) +(let __tmp139 (Single __tmp138)) +(let __tmp140 (Get __tmp132 2)) +(let __tmp141 (Single __tmp140)) +(let __tmp142 (Get __tmp132 3)) +(let __tmp143 (Single __tmp142)) +(let __tmp144 (Get __tmp132 4)) +(let __tmp145 (Single __tmp144)) +(let __tmp146 (Get __tmp132 5)) +(let __tmp147 (Single __tmp146)) +(let __tmp148 (Single __tmp134)) +(let __tmp149 (Get __tmp132 7)) +(let __tmp150 (Single __tmp149)) +(let __tmp151 (Single __tmp133)) +(let __tmp152 (Get __tmp132 9)) +(let __tmp153 (Single __tmp152)) +(let __tmp154 (Get __tmp132 10)) +(let __tmp155 (Single __tmp154)) +(let __tmp156 (Get __tmp132 11)) +(let __tmp157 (Single __tmp156)) +(let __tmp158 (Get __tmp132 12)) +(let __tmp159 (Single __tmp158)) +(let __tmp160 (Get __tmp132 13)) +(let __tmp161 (Single __tmp160)) +(let __tmp162 (Get __tmp132 14)) +(let __tmp163 (Single __tmp162)) +(let __tmp164 (Concat __tmp161 __tmp163)) +(let __tmp165 (Concat __tmp159 __tmp164)) +(let __tmp166 (Concat __tmp157 __tmp165)) +(let __tmp167 (Concat __tmp155 __tmp166)) +(let __tmp168 (Concat __tmp153 __tmp167)) +(let __tmp169 (Concat __tmp151 __tmp168)) +(let __tmp170 (Concat __tmp150 __tmp169)) +(let __tmp171 (Concat __tmp148 __tmp170)) +(let __tmp172 (Concat __tmp147 __tmp171)) +(let __tmp173 (Concat __tmp145 __tmp172)) +(let __tmp174 (Concat __tmp143 __tmp173)) +(let __tmp175 (Concat __tmp141 __tmp174)) +(let __tmp176 (Concat __tmp139 __tmp175)) +(let __tmp177 (Concat __tmp137 __tmp176)) +(let __tmp178 (Const __tmp83 __tmp131 __tmp6)) +(let __tmp179 (Single __tmp178)) +(let __tmp180 (Concat __tmp179 __tmp167)) +(let __tmp181 (Concat __tmp153 __tmp180)) +(let __tmp182 (Concat __tmp151 __tmp181)) +(let __tmp183 (Concat __tmp150 __tmp182)) +(let __tmp184 (Concat __tmp148 __tmp183)) +(let __tmp185 (Concat __tmp147 __tmp184)) +(let __tmp186 (Concat __tmp145 __tmp185)) +(let __tmp187 (Concat __tmp143 __tmp186)) +(let __tmp188 (Concat __tmp141 __tmp187)) +(let __tmp189 (Concat __tmp139 __tmp188)) +(let __tmp190 (Concat __tmp137 __tmp189)) +(let __tmp191 (TCons __tmp115 __tmp124)) +(let __tmp192 (TCons __tmp114 __tmp191)) +(let __tmp193 (TCons __tmp114 __tmp192)) +(let __tmp194 (TCons __tmp114 __tmp193)) +(let __tmp195 (TCons __tmp114 __tmp194)) +(let __tmp196 (TCons __tmp114 __tmp195)) +(let __tmp197 (TCons __tmp0 __tmp196)) +(let __tmp198 (TupleT __tmp197)) +(let __tmp199 (Arg __tmp198 __tmp6)) +(let __tmp200 (Get __tmp199 10)) +(let __tmp201 (Get __tmp199 11)) +(let __tmp202 (Bop __tmp112 __tmp200 __tmp201)) +(let __tmp203 (Get __tmp199 0)) +(let __tmp204 (Single __tmp203)) +(let __tmp205 (Get __tmp199 1)) +(let __tmp206 (Single __tmp205)) +(let __tmp207 (Get __tmp199 2)) +(let __tmp208 (Single __tmp207)) +(let __tmp209 (Get __tmp199 3)) +(let __tmp210 (Single __tmp209)) +(let __tmp211 (Get __tmp199 4)) +(let __tmp212 (Single __tmp211)) +(let __tmp213 (Get __tmp199 5)) +(let __tmp214 (Single __tmp213)) +(let __tmp215 (Get __tmp199 6)) +(let __tmp216 (Single __tmp215)) +(let __tmp217 (Get __tmp199 7)) +(let __tmp218 (Single __tmp217)) +(let __tmp219 (Get __tmp199 8)) +(let __tmp220 (Single __tmp219)) +(let __tmp221 (Get __tmp199 9)) +(let __tmp222 (Single __tmp221)) +(let __tmp223 (Single __tmp200)) +(let __tmp224 (Single __tmp201)) +(let __tmp225 (Get __tmp199 12)) +(let __tmp226 (Single __tmp225)) +(let __tmp227 (Get __tmp199 13)) +(let __tmp228 (Single __tmp227)) +(let __tmp229 (Get __tmp199 14)) +(let __tmp230 (Single __tmp229)) +(let __tmp231 (Get __tmp199 15)) +(let __tmp232 (Single __tmp231)) +(let __tmp233 (Concat __tmp230 __tmp232)) +(let __tmp234 (Concat __tmp228 __tmp233)) +(let __tmp235 (Concat __tmp226 __tmp234)) +(let __tmp236 (Concat __tmp224 __tmp235)) +(let __tmp237 (Concat __tmp223 __tmp236)) +(let __tmp238 (Concat __tmp222 __tmp237)) +(let __tmp239 (Concat __tmp220 __tmp238)) +(let __tmp240 (Concat __tmp218 __tmp239)) +(let __tmp241 (Concat __tmp216 __tmp240)) +(let __tmp242 (Concat __tmp214 __tmp241)) +(let __tmp243 (Concat __tmp212 __tmp242)) +(let __tmp244 (Concat __tmp210 __tmp243)) +(let __tmp245 (Concat __tmp208 __tmp244)) +(let __tmp246 (Concat __tmp206 __tmp245)) +(let __tmp247 (Concat __tmp204 __tmp246)) +(let __tmp248 (Concat __tmp232 __tmp204)) +(let __tmp249 (Concat __tmp224 __tmp248)) +(let __tmp250 (Concat __tmp223 __tmp249)) +(let __tmp251 (Concat __tmp220 __tmp250)) +(let __tmp252 (Concat __tmp206 __tmp251)) +(let __tmp253 (Call "matrix_set" __tmp252)) +(let __tmp254 (Get __tmp253 0)) +(let __tmp255 (Single __tmp254)) +(let __tmp256 (Const __tmp83 __tmp198 __tmp6)) +(let __tmp257 (Single __tmp256)) +(let __tmp258 (Concat __tmp257 __tmp236)) +(let __tmp259 (Concat __tmp223 __tmp258)) +(let __tmp260 (Concat __tmp222 __tmp259)) +(let __tmp261 (Concat __tmp220 __tmp260)) +(let __tmp262 (Concat __tmp218 __tmp261)) +(let __tmp263 (Concat __tmp216 __tmp262)) +(let __tmp264 (Concat __tmp214 __tmp263)) +(let __tmp265 (Concat __tmp212 __tmp264)) +(let __tmp266 (Concat __tmp210 __tmp265)) +(let __tmp267 (Concat __tmp208 __tmp266)) +(let __tmp268 (Concat __tmp206 __tmp267)) +(let __tmp269 (Concat __tmp255 __tmp268)) +(let __tmp270 (TCons __tmp115 __tmp191)) +(let __tmp271 (TCons __tmp114 __tmp270)) +(let __tmp272 (TCons __tmp114 __tmp271)) +(let __tmp273 (TCons __tmp114 __tmp272)) +(let __tmp274 (TCons __tmp114 __tmp273)) +(let __tmp275 (TCons __tmp114 __tmp274)) +(let __tmp276 (TCons __tmp0 __tmp275)) +(let __tmp277 (TupleT __tmp276)) +(let __tmp278 (Arg __tmp277 __tmp6)) +(let __tmp279 (Get __tmp278 11)) +(let __tmp280 (Get __tmp278 15)) +(let __tmp281 (Bop __tmp112 __tmp279 __tmp280)) +(let __tmp282 (Get __tmp278 0)) +(let __tmp283 (Single __tmp282)) +(let __tmp284 (Get __tmp278 1)) +(let __tmp285 (Single __tmp284)) +(let __tmp286 (Get __tmp278 2)) +(let __tmp287 (Single __tmp286)) +(let __tmp288 (Get __tmp278 3)) +(let __tmp289 (Single __tmp288)) +(let __tmp290 (Get __tmp278 4)) +(let __tmp291 (Single __tmp290)) +(let __tmp292 (Get __tmp278 5)) +(let __tmp293 (Single __tmp292)) +(let __tmp294 (Get __tmp278 6)) +(let __tmp295 (Single __tmp294)) +(let __tmp296 (Get __tmp278 7)) +(let __tmp297 (Single __tmp296)) +(let __tmp298 (Get __tmp278 8)) +(let __tmp299 (Single __tmp298)) +(let __tmp300 (Get __tmp278 9)) +(let __tmp301 (Single __tmp300)) +(let __tmp302 (Get __tmp278 10)) +(let __tmp303 (Single __tmp302)) +(let __tmp304 (Single __tmp279)) +(let __tmp305 (Get __tmp278 12)) +(let __tmp306 (Single __tmp305)) +(let __tmp307 (Get __tmp278 13)) +(let __tmp308 (Single __tmp307)) +(let __tmp309 (Get __tmp278 14)) +(let __tmp310 (Single __tmp309)) +(let __tmp311 (Single __tmp280)) +(let __tmp312 (Get __tmp278 16)) +(let __tmp313 (Single __tmp312)) +(let __tmp314 (Concat __tmp311 __tmp313)) +(let __tmp315 (Concat __tmp310 __tmp314)) +(let __tmp316 (Concat __tmp308 __tmp315)) +(let __tmp317 (Concat __tmp306 __tmp316)) +(let __tmp318 (Concat __tmp304 __tmp317)) +(let __tmp319 (Concat __tmp303 __tmp318)) +(let __tmp320 (Concat __tmp301 __tmp319)) +(let __tmp321 (Concat __tmp299 __tmp320)) +(let __tmp322 (Concat __tmp297 __tmp321)) +(let __tmp323 (Concat __tmp295 __tmp322)) +(let __tmp324 (Concat __tmp293 __tmp323)) +(let __tmp325 (Concat __tmp291 __tmp324)) +(let __tmp326 (Concat __tmp289 __tmp325)) +(let __tmp327 (Concat __tmp287 __tmp326)) +(let __tmp328 (Concat __tmp285 __tmp327)) +(let __tmp329 (Concat __tmp283 __tmp328)) +(let __tmp330 (FMul )) +(let __tmp331 (Concat __tmp311 __tmp283)) +(let __tmp332 (Concat __tmp304 __tmp331)) +(let __tmp333 (Concat __tmp299 __tmp332)) +(let __tmp334 (Concat __tmp293 __tmp333)) +(let __tmp335 (Call "matrix_get" __tmp334)) +(let __tmp336 (Get __tmp335 0)) +(let __tmp337 (Bop __tmp330 __tmp309 __tmp336)) +(let __tmp338 (Get __tmp335 1)) +(let __tmp339 (Single __tmp338)) +(let __tmp340 (Concat __tmp306 __tmp339)) +(let __tmp341 (Concat __tmp303 __tmp340)) +(let __tmp342 (Concat __tmp304 __tmp341)) +(let __tmp343 (Concat __tmp291 __tmp342)) +(let __tmp344 (Call "matrix_get" __tmp343)) +(let __tmp345 (Get __tmp344 0)) +(let __tmp346 (Bop __tmp330 __tmp337 __tmp345)) +(let __tmp347 (Single __tmp346)) +(let __tmp348 (Get __tmp344 1)) +(let __tmp349 (Single __tmp348)) +(let __tmp350 (Concat __tmp347 __tmp349)) +(let __tmp351 (Concat __tmp306 __tmp350)) +(let __tmp352 (Concat __tmp303 __tmp351)) +(let __tmp353 (Concat __tmp299 __tmp352)) +(let __tmp354 (Concat __tmp285 __tmp353)) +(let __tmp355 (Call "matrix_incr" __tmp354)) +(let __tmp356 (Get __tmp355 0)) +(let __tmp357 (Single __tmp356)) +(let __tmp358 (Add )) +(let __tmp359 (Bop __tmp358 __tmp279 __tmp300)) +(let __tmp360 (Single __tmp359)) +(let __tmp361 (Bool true)) +(let __tmp362 (Const __tmp361 __tmp277 __tmp6)) +(let __tmp363 (Single __tmp362)) +(let __tmp364 (Concat __tmp363 __tmp315)) +(let __tmp365 (Concat __tmp308 __tmp364)) +(let __tmp366 (Concat __tmp306 __tmp365)) +(let __tmp367 (Concat __tmp360 __tmp366)) +(let __tmp368 (Concat __tmp303 __tmp367)) +(let __tmp369 (Concat __tmp301 __tmp368)) +(let __tmp370 (Concat __tmp299 __tmp369)) +(let __tmp371 (Concat __tmp297 __tmp370)) +(let __tmp372 (Concat __tmp295 __tmp371)) +(let __tmp373 (Concat __tmp293 __tmp372)) +(let __tmp374 (Concat __tmp291 __tmp373)) +(let __tmp375 (Concat __tmp289 __tmp374)) +(let __tmp376 (Concat __tmp287 __tmp375)) +(let __tmp377 (Concat __tmp285 __tmp376)) +(let __tmp378 (Concat __tmp357 __tmp377)) +(let __tmp379 (Bool false)) +(let __tmp380 (Const __tmp379 __tmp277 __tmp6)) +(let __tmp381 (Single __tmp380)) +(let __tmp382 (Concat __tmp381 __tmp315)) +(let __tmp383 (Concat __tmp308 __tmp382)) +(let __tmp384 (Concat __tmp306 __tmp383)) +(let __tmp385 (Concat __tmp304 __tmp384)) +(let __tmp386 (Concat __tmp303 __tmp385)) +(let __tmp387 (Concat __tmp301 __tmp386)) +(let __tmp388 (Concat __tmp299 __tmp387)) +(let __tmp389 (Concat __tmp297 __tmp388)) +(let __tmp390 (Concat __tmp295 __tmp389)) +(let __tmp391 (Concat __tmp293 __tmp390)) +(let __tmp392 (Concat __tmp291 __tmp391)) +(let __tmp393 (Concat __tmp289 __tmp392)) +(let __tmp394 (Concat __tmp287 __tmp393)) +(let __tmp395 (Concat __tmp285 __tmp394)) +(let __tmp396 (Concat __tmp283 __tmp395)) +(let __tmp397 (If __tmp281 __tmp329 __tmp378 __tmp396)) +(let __tmp398 (Get __tmp397 14)) +(let __tmp399 (Single __tmp398)) +(let __tmp400 (Get __tmp397 0)) +(let __tmp401 (Single __tmp400)) +(let __tmp402 (Get __tmp397 1)) +(let __tmp403 (Single __tmp402)) +(let __tmp404 (Get __tmp397 2)) +(let __tmp405 (Single __tmp404)) +(let __tmp406 (Get __tmp397 3)) +(let __tmp407 (Single __tmp406)) +(let __tmp408 (Get __tmp397 4)) +(let __tmp409 (Single __tmp408)) +(let __tmp410 (Get __tmp397 5)) +(let __tmp411 (Single __tmp410)) +(let __tmp412 (Get __tmp397 6)) +(let __tmp413 (Single __tmp412)) +(let __tmp414 (Get __tmp397 7)) +(let __tmp415 (Single __tmp414)) +(let __tmp416 (Get __tmp397 8)) +(let __tmp417 (Single __tmp416)) +(let __tmp418 (Get __tmp397 9)) +(let __tmp419 (Single __tmp418)) +(let __tmp420 (Get __tmp397 10)) +(let __tmp421 (Single __tmp420)) +(let __tmp422 (Get __tmp397 11)) +(let __tmp423 (Single __tmp422)) +(let __tmp424 (Get __tmp397 12)) +(let __tmp425 (Single __tmp424)) +(let __tmp426 (Get __tmp397 13)) +(let __tmp427 (Single __tmp426)) +(let __tmp428 (Get __tmp397 15)) +(let __tmp429 (Single __tmp428)) +(let __tmp430 (Get __tmp397 16)) +(let __tmp431 (Single __tmp430)) +(let __tmp432 (Get __tmp397 17)) +(let __tmp433 (Single __tmp432)) +(let __tmp434 (Concat __tmp431 __tmp433)) +(let __tmp435 (Concat __tmp429 __tmp434)) +(let __tmp436 (Concat __tmp427 __tmp435)) +(let __tmp437 (Concat __tmp425 __tmp436)) +(let __tmp438 (Concat __tmp423 __tmp437)) +(let __tmp439 (Concat __tmp421 __tmp438)) +(let __tmp440 (Concat __tmp419 __tmp439)) +(let __tmp441 (Concat __tmp417 __tmp440)) +(let __tmp442 (Concat __tmp415 __tmp441)) +(let __tmp443 (Concat __tmp413 __tmp442)) +(let __tmp444 (Concat __tmp411 __tmp443)) +(let __tmp445 (Concat __tmp409 __tmp444)) +(let __tmp446 (Concat __tmp407 __tmp445)) +(let __tmp447 (Concat __tmp405 __tmp446)) +(let __tmp448 (Concat __tmp403 __tmp447)) +(let __tmp449 (Concat __tmp401 __tmp448)) +(let __tmp450 (Concat __tmp399 __tmp449)) +(let __tmp451 (DoWhile __tmp269 __tmp450)) +(let __tmp452 (Get __tmp451 0)) +(let __tmp453 (Single __tmp452)) +(let __tmp454 (Get __tmp451 1)) +(let __tmp455 (Single __tmp454)) +(let __tmp456 (Get __tmp451 2)) +(let __tmp457 (Single __tmp456)) +(let __tmp458 (Get __tmp451 3)) +(let __tmp459 (Single __tmp458)) +(let __tmp460 (Get __tmp451 4)) +(let __tmp461 (Single __tmp460)) +(let __tmp462 (Get __tmp451 5)) +(let __tmp463 (Single __tmp462)) +(let __tmp464 (Get __tmp451 6)) +(let __tmp465 (Single __tmp464)) +(let __tmp466 (Get __tmp451 7)) +(let __tmp467 (Single __tmp466)) +(let __tmp468 (Get __tmp451 8)) +(let __tmp469 (Single __tmp468)) +(let __tmp470 (Get __tmp451 9)) +(let __tmp471 (Single __tmp470)) +(let __tmp472 (Get __tmp451 10)) +(let __tmp473 (Bop __tmp358 __tmp472 __tmp470)) +(let __tmp474 (Single __tmp473)) +(let __tmp475 (Get __tmp451 12)) +(let __tmp476 (Single __tmp475)) +(let __tmp477 (Get __tmp451 13)) +(let __tmp478 (Single __tmp477)) +(let __tmp479 (Const __tmp361 __tmp198 __tmp6)) +(let __tmp480 (Single __tmp479)) +(let __tmp481 (Get __tmp451 14)) +(let __tmp482 (Single __tmp481)) +(let __tmp483 (Get __tmp451 15)) +(let __tmp484 (Single __tmp483)) +(let __tmp485 (Get __tmp451 16)) +(let __tmp486 (Single __tmp485)) +(let __tmp487 (Concat __tmp484 __tmp486)) +(let __tmp488 (Concat __tmp482 __tmp487)) +(let __tmp489 (Concat __tmp480 __tmp488)) +(let __tmp490 (Concat __tmp478 __tmp489)) +(let __tmp491 (Concat __tmp476 __tmp490)) +(let __tmp492 (Concat __tmp474 __tmp491)) +(let __tmp493 (Concat __tmp471 __tmp492)) +(let __tmp494 (Concat __tmp469 __tmp493)) +(let __tmp495 (Concat __tmp467 __tmp494)) +(let __tmp496 (Concat __tmp465 __tmp495)) +(let __tmp497 (Concat __tmp463 __tmp496)) +(let __tmp498 (Concat __tmp461 __tmp497)) +(let __tmp499 (Concat __tmp459 __tmp498)) +(let __tmp500 (Concat __tmp457 __tmp499)) +(let __tmp501 (Concat __tmp455 __tmp500)) +(let __tmp502 (Concat __tmp453 __tmp501)) +(let __tmp503 (Const __tmp379 __tmp198 __tmp6)) +(let __tmp504 (Single __tmp503)) +(let __tmp505 (Concat __tmp504 __tmp234)) +(let __tmp506 (Concat __tmp226 __tmp505)) +(let __tmp507 (Concat __tmp224 __tmp506)) +(let __tmp508 (Concat __tmp223 __tmp507)) +(let __tmp509 (Concat __tmp222 __tmp508)) +(let __tmp510 (Concat __tmp220 __tmp509)) +(let __tmp511 (Concat __tmp218 __tmp510)) +(let __tmp512 (Concat __tmp216 __tmp511)) +(let __tmp513 (Concat __tmp214 __tmp512)) +(let __tmp514 (Concat __tmp212 __tmp513)) +(let __tmp515 (Concat __tmp210 __tmp514)) +(let __tmp516 (Concat __tmp208 __tmp515)) +(let __tmp517 (Concat __tmp206 __tmp516)) +(let __tmp518 (Concat __tmp204 __tmp517)) +(let __tmp519 (If __tmp202 __tmp247 __tmp502 __tmp518)) +(let __tmp520 (Get __tmp519 13)) +(let __tmp521 (Single __tmp520)) +(let __tmp522 (Get __tmp519 0)) +(let __tmp523 (Single __tmp522)) +(let __tmp524 (Get __tmp519 1)) +(let __tmp525 (Single __tmp524)) +(let __tmp526 (Get __tmp519 2)) +(let __tmp527 (Single __tmp526)) +(let __tmp528 (Get __tmp519 3)) +(let __tmp529 (Single __tmp528)) +(let __tmp530 (Get __tmp519 4)) +(let __tmp531 (Single __tmp530)) +(let __tmp532 (Get __tmp519 5)) +(let __tmp533 (Single __tmp532)) +(let __tmp534 (Get __tmp519 6)) +(let __tmp535 (Single __tmp534)) +(let __tmp536 (Get __tmp519 7)) +(let __tmp537 (Single __tmp536)) +(let __tmp538 (Get __tmp519 8)) +(let __tmp539 (Single __tmp538)) +(let __tmp540 (Get __tmp519 9)) +(let __tmp541 (Single __tmp540)) +(let __tmp542 (Get __tmp519 10)) +(let __tmp543 (Single __tmp542)) +(let __tmp544 (Get __tmp519 11)) +(let __tmp545 (Single __tmp544)) +(let __tmp546 (Get __tmp519 12)) +(let __tmp547 (Single __tmp546)) +(let __tmp548 (Get __tmp519 14)) +(let __tmp549 (Single __tmp548)) +(let __tmp550 (Get __tmp519 15)) +(let __tmp551 (Single __tmp550)) +(let __tmp552 (Get __tmp519 16)) +(let __tmp553 (Single __tmp552)) +(let __tmp554 (Concat __tmp551 __tmp553)) +(let __tmp555 (Concat __tmp549 __tmp554)) +(let __tmp556 (Concat __tmp547 __tmp555)) +(let __tmp557 (Concat __tmp545 __tmp556)) +(let __tmp558 (Concat __tmp543 __tmp557)) +(let __tmp559 (Concat __tmp541 __tmp558)) +(let __tmp560 (Concat __tmp539 __tmp559)) +(let __tmp561 (Concat __tmp537 __tmp560)) +(let __tmp562 (Concat __tmp535 __tmp561)) +(let __tmp563 (Concat __tmp533 __tmp562)) +(let __tmp564 (Concat __tmp531 __tmp563)) +(let __tmp565 (Concat __tmp529 __tmp564)) +(let __tmp566 (Concat __tmp527 __tmp565)) +(let __tmp567 (Concat __tmp525 __tmp566)) +(let __tmp568 (Concat __tmp523 __tmp567)) +(let __tmp569 (Concat __tmp521 __tmp568)) +(let __tmp570 (DoWhile __tmp190 __tmp569)) +(let __tmp571 (Get __tmp570 0)) +(let __tmp572 (Single __tmp571)) +(let __tmp573 (Get __tmp570 1)) +(let __tmp574 (Single __tmp573)) +(let __tmp575 (Get __tmp570 2)) +(let __tmp576 (Single __tmp575)) +(let __tmp577 (Get __tmp570 3)) +(let __tmp578 (Single __tmp577)) +(let __tmp579 (Get __tmp570 4)) +(let __tmp580 (Single __tmp579)) +(let __tmp581 (Get __tmp570 5)) +(let __tmp582 (Single __tmp581)) +(let __tmp583 (Get __tmp570 6)) +(let __tmp584 (Single __tmp583)) +(let __tmp585 (Get __tmp570 7)) +(let __tmp586 (Single __tmp585)) +(let __tmp587 (Get __tmp570 8)) +(let __tmp588 (Get __tmp570 9)) +(let __tmp589 (Bop __tmp358 __tmp587 __tmp588)) +(let __tmp590 (Single __tmp589)) +(let __tmp591 (Single __tmp588)) +(let __tmp592 (Get __tmp570 11)) +(let __tmp593 (Single __tmp592)) +(let __tmp594 (Get __tmp570 12)) +(let __tmp595 (Single __tmp594)) +(let __tmp596 (Const __tmp361 __tmp131 __tmp6)) +(let __tmp597 (Single __tmp596)) +(let __tmp598 (Get __tmp570 13)) +(let __tmp599 (Single __tmp598)) +(let __tmp600 (Get __tmp570 14)) +(let __tmp601 (Single __tmp600)) +(let __tmp602 (Get __tmp570 15)) +(let __tmp603 (Single __tmp602)) +(let __tmp604 (Concat __tmp601 __tmp603)) +(let __tmp605 (Concat __tmp599 __tmp604)) +(let __tmp606 (Concat __tmp597 __tmp605)) +(let __tmp607 (Concat __tmp595 __tmp606)) +(let __tmp608 (Concat __tmp593 __tmp607)) +(let __tmp609 (Concat __tmp591 __tmp608)) +(let __tmp610 (Concat __tmp590 __tmp609)) +(let __tmp611 (Concat __tmp586 __tmp610)) +(let __tmp612 (Concat __tmp584 __tmp611)) +(let __tmp613 (Concat __tmp582 __tmp612)) +(let __tmp614 (Concat __tmp580 __tmp613)) +(let __tmp615 (Concat __tmp578 __tmp614)) +(let __tmp616 (Concat __tmp576 __tmp615)) +(let __tmp617 (Concat __tmp574 __tmp616)) +(let __tmp618 (Concat __tmp572 __tmp617)) +(let __tmp619 (Const __tmp379 __tmp131 __tmp6)) +(let __tmp620 (Single __tmp619)) +(let __tmp621 (Concat __tmp620 __tmp165)) +(let __tmp622 (Concat __tmp157 __tmp621)) +(let __tmp623 (Concat __tmp155 __tmp622)) +(let __tmp624 (Concat __tmp153 __tmp623)) +(let __tmp625 (Concat __tmp151 __tmp624)) +(let __tmp626 (Concat __tmp150 __tmp625)) +(let __tmp627 (Concat __tmp148 __tmp626)) +(let __tmp628 (Concat __tmp147 __tmp627)) +(let __tmp629 (Concat __tmp145 __tmp628)) +(let __tmp630 (Concat __tmp143 __tmp629)) +(let __tmp631 (Concat __tmp141 __tmp630)) +(let __tmp632 (Concat __tmp139 __tmp631)) +(let __tmp633 (Concat __tmp137 __tmp632)) +(let __tmp634 (If __tmp135 __tmp177 __tmp618 __tmp633)) +(let __tmp635 (Get __tmp634 12)) +(let __tmp636 (Single __tmp635)) +(let __tmp637 (Get __tmp634 0)) +(let __tmp638 (Single __tmp637)) +(let __tmp639 (Get __tmp634 1)) +(let __tmp640 (Single __tmp639)) +(let __tmp641 (Get __tmp634 2)) +(let __tmp642 (Single __tmp641)) +(let __tmp643 (Get __tmp634 3)) +(let __tmp644 (Single __tmp643)) +(let __tmp645 (Get __tmp634 4)) +(let __tmp646 (Single __tmp645)) +(let __tmp647 (Get __tmp634 5)) +(let __tmp648 (Single __tmp647)) +(let __tmp649 (Get __tmp634 6)) +(let __tmp650 (Single __tmp649)) +(let __tmp651 (Get __tmp634 7)) +(let __tmp652 (Single __tmp651)) +(let __tmp653 (Get __tmp634 8)) +(let __tmp654 (Single __tmp653)) +(let __tmp655 (Get __tmp634 9)) +(let __tmp656 (Single __tmp655)) +(let __tmp657 (Get __tmp634 10)) +(let __tmp658 (Single __tmp657)) +(let __tmp659 (Get __tmp634 11)) +(let __tmp660 (Single __tmp659)) +(let __tmp661 (Get __tmp634 13)) +(let __tmp662 (Single __tmp661)) +(let __tmp663 (Get __tmp634 14)) +(let __tmp664 (Single __tmp663)) +(let __tmp665 (Get __tmp634 15)) +(let __tmp666 (Single __tmp665)) +(let __tmp667 (Concat __tmp664 __tmp666)) +(let __tmp668 (Concat __tmp662 __tmp667)) +(let __tmp669 (Concat __tmp660 __tmp668)) +(let __tmp670 (Concat __tmp658 __tmp669)) +(let __tmp671 (Concat __tmp656 __tmp670)) +(let __tmp672 (Concat __tmp654 __tmp671)) +(let __tmp673 (Concat __tmp652 __tmp672)) +(let __tmp674 (Concat __tmp650 __tmp673)) +(let __tmp675 (Concat __tmp648 __tmp674)) +(let __tmp676 (Concat __tmp646 __tmp675)) +(let __tmp677 (Concat __tmp644 __tmp676)) +(let __tmp678 (Concat __tmp642 __tmp677)) +(let __tmp679 (Concat __tmp640 __tmp678)) +(let __tmp680 (Concat __tmp638 __tmp679)) +(let __tmp681 (Concat __tmp636 __tmp680)) +(let __tmp682 (DoWhile __tmp111 __tmp681)) +(let __tmp683 (Get __tmp682 0)) +(let __tmp684 (Single __tmp683)) +(let __tmp685 (Get __tmp682 1)) +(let __tmp686 (Single __tmp685)) +(let __tmp687 (Get __tmp682 2)) +(let __tmp688 (Single __tmp687)) +(let __tmp689 (Get __tmp682 3)) +(let __tmp690 (Single __tmp689)) +(let __tmp691 (Get __tmp682 4)) +(let __tmp692 (Single __tmp691)) +(let __tmp693 (Get __tmp682 5)) +(let __tmp694 (Single __tmp693)) +(let __tmp695 (Get __tmp682 6)) +(let __tmp696 (Single __tmp695)) +(let __tmp697 (Get __tmp682 7)) +(let __tmp698 (Single __tmp697)) +(let __tmp699 (Get __tmp682 9)) +(let __tmp700 (Single __tmp699)) +(let __tmp701 (Get __tmp682 10)) +(let __tmp702 (Single __tmp701)) +(let __tmp703 (Get __tmp682 11)) +(let __tmp704 (Single __tmp703)) +(let __tmp705 (Concat __tmp702 __tmp704)) +(let __tmp706 (Concat __tmp700 __tmp705)) +(let __tmp707 (Concat __tmp85 __tmp706)) +(let __tmp708 (Concat __tmp698 __tmp707)) +(let __tmp709 (Concat __tmp696 __tmp708)) +(let __tmp710 (Concat __tmp694 __tmp709)) +(let __tmp711 (Concat __tmp692 __tmp710)) +(let __tmp712 (Concat __tmp690 __tmp711)) +(let __tmp713 (Concat __tmp688 __tmp712)) +(let __tmp714 (Concat __tmp686 __tmp713)) +(let __tmp715 (Concat __tmp684 __tmp714)) +(let __tmp716 (TCons __tmp115 __tmp117)) +(let __tmp717 (TCons __tmp115 __tmp716)) +(let __tmp718 (TCons __tmp115 __tmp717)) +(let __tmp719 (TCons __tmp115 __tmp718)) +(let __tmp720 (TCons __tmp114 __tmp719)) +(let __tmp721 (TCons __tmp114 __tmp720)) +(let __tmp722 (TCons __tmp114 __tmp721)) +(let __tmp723 (TCons __tmp114 __tmp722)) +(let __tmp724 (TCons __tmp114 __tmp723)) +(let __tmp725 (TCons __tmp0 __tmp724)) +(let __tmp726 (TupleT __tmp725)) +(let __tmp727 (Arg __tmp726 __tmp6)) +(let __tmp728 (Get __tmp727 8)) +(let __tmp729 (Get __tmp727 6)) +(let __tmp730 (Bop __tmp112 __tmp728 __tmp729)) +(let __tmp731 (Get __tmp727 0)) +(let __tmp732 (Single __tmp731)) +(let __tmp733 (Get __tmp727 1)) +(let __tmp734 (Single __tmp733)) +(let __tmp735 (Get __tmp727 2)) +(let __tmp736 (Single __tmp735)) +(let __tmp737 (Get __tmp727 3)) +(let __tmp738 (Single __tmp737)) +(let __tmp739 (Get __tmp727 4)) +(let __tmp740 (Single __tmp739)) +(let __tmp741 (Get __tmp727 5)) +(let __tmp742 (Single __tmp741)) +(let __tmp743 (Single __tmp729)) +(let __tmp744 (Get __tmp727 7)) +(let __tmp745 (Single __tmp744)) +(let __tmp746 (Single __tmp728)) +(let __tmp747 (Get __tmp727 9)) +(let __tmp748 (Single __tmp747)) +(let __tmp749 (Get __tmp727 10)) +(let __tmp750 (Single __tmp749)) +(let __tmp751 (Get __tmp727 11)) +(let __tmp752 (Single __tmp751)) +(let __tmp753 (Concat __tmp750 __tmp752)) +(let __tmp754 (Concat __tmp748 __tmp753)) +(let __tmp755 (Concat __tmp746 __tmp754)) +(let __tmp756 (Concat __tmp745 __tmp755)) +(let __tmp757 (Concat __tmp743 __tmp756)) +(let __tmp758 (Concat __tmp742 __tmp757)) +(let __tmp759 (Concat __tmp740 __tmp758)) +(let __tmp760 (Concat __tmp738 __tmp759)) +(let __tmp761 (Concat __tmp736 __tmp760)) +(let __tmp762 (Concat __tmp734 __tmp761)) +(let __tmp763 (Concat __tmp732 __tmp762)) +(let __tmp764 (Const __tmp83 __tmp726 __tmp6)) +(let __tmp765 (Single __tmp764)) +(let __tmp766 (Concat __tmp765 __tmp753)) +(let __tmp767 (Concat __tmp748 __tmp766)) +(let __tmp768 (Concat __tmp746 __tmp767)) +(let __tmp769 (Concat __tmp745 __tmp768)) +(let __tmp770 (Concat __tmp743 __tmp769)) +(let __tmp771 (Concat __tmp742 __tmp770)) +(let __tmp772 (Concat __tmp740 __tmp771)) +(let __tmp773 (Concat __tmp738 __tmp772)) +(let __tmp774 (Concat __tmp736 __tmp773)) +(let __tmp775 (Concat __tmp734 __tmp774)) +(let __tmp776 (Concat __tmp732 __tmp775)) +(let __tmp777 (TCons __tmp115 __tmp719)) +(let __tmp778 (TCons __tmp114 __tmp777)) +(let __tmp779 (TCons __tmp114 __tmp778)) +(let __tmp780 (TCons __tmp114 __tmp779)) +(let __tmp781 (TCons __tmp114 __tmp780)) +(let __tmp782 (TCons __tmp114 __tmp781)) +(let __tmp783 (TCons __tmp0 __tmp782)) +(let __tmp784 (TupleT __tmp783)) +(let __tmp785 (Arg __tmp784 __tmp6)) +(let __tmp786 (Get __tmp785 10)) +(let __tmp787 (Get __tmp785 7)) +(let __tmp788 (Bop __tmp112 __tmp786 __tmp787)) +(let __tmp789 (Get __tmp785 0)) +(let __tmp790 (Single __tmp789)) +(let __tmp791 (Get __tmp785 1)) +(let __tmp792 (Single __tmp791)) +(let __tmp793 (Get __tmp785 2)) +(let __tmp794 (Single __tmp793)) +(let __tmp795 (Get __tmp785 3)) +(let __tmp796 (Single __tmp795)) +(let __tmp797 (Get __tmp785 4)) +(let __tmp798 (Single __tmp797)) +(let __tmp799 (Get __tmp785 5)) +(let __tmp800 (Single __tmp799)) +(let __tmp801 (Get __tmp785 6)) +(let __tmp802 (Single __tmp801)) +(let __tmp803 (Single __tmp787)) +(let __tmp804 (Get __tmp785 8)) +(let __tmp805 (Single __tmp804)) +(let __tmp806 (Get __tmp785 9)) +(let __tmp807 (Single __tmp806)) +(let __tmp808 (Single __tmp786)) +(let __tmp809 (Get __tmp785 11)) +(let __tmp810 (Single __tmp809)) +(let __tmp811 (Get __tmp785 12)) +(let __tmp812 (Single __tmp811)) +(let __tmp813 (Concat __tmp810 __tmp812)) +(let __tmp814 (Concat __tmp808 __tmp813)) +(let __tmp815 (Concat __tmp807 __tmp814)) +(let __tmp816 (Concat __tmp805 __tmp815)) +(let __tmp817 (Concat __tmp803 __tmp816)) +(let __tmp818 (Concat __tmp802 __tmp817)) +(let __tmp819 (Concat __tmp800 __tmp818)) +(let __tmp820 (Concat __tmp798 __tmp819)) +(let __tmp821 (Concat __tmp796 __tmp820)) +(let __tmp822 (Concat __tmp794 __tmp821)) +(let __tmp823 (Concat __tmp792 __tmp822)) +(let __tmp824 (Concat __tmp790 __tmp823)) +(let __tmp825 (Concat __tmp812 __tmp790)) +(let __tmp826 (Concat __tmp803 __tmp825)) +(let __tmp827 (Concat __tmp808 __tmp826)) +(let __tmp828 (Concat __tmp805 __tmp827)) +(let __tmp829 (Concat __tmp794 __tmp828)) +(let __tmp830 (Call "matrix_scale" __tmp829)) +(let __tmp831 (Get __tmp830 0)) +(let __tmp832 (Single __tmp831)) +(let __tmp833 (Const __tmp83 __tmp784 __tmp6)) +(let __tmp834 (Single __tmp833)) +(let __tmp835 (Concat __tmp834 __tmp813)) +(let __tmp836 (Concat __tmp808 __tmp835)) +(let __tmp837 (Concat __tmp807 __tmp836)) +(let __tmp838 (Concat __tmp805 __tmp837)) +(let __tmp839 (Concat __tmp803 __tmp838)) +(let __tmp840 (Concat __tmp802 __tmp839)) +(let __tmp841 (Concat __tmp800 __tmp840)) +(let __tmp842 (Concat __tmp798 __tmp841)) +(let __tmp843 (Concat __tmp796 __tmp842)) +(let __tmp844 (Concat __tmp794 __tmp843)) +(let __tmp845 (Concat __tmp792 __tmp844)) +(let __tmp846 (Concat __tmp832 __tmp845)) +(let __tmp847 (TCons __tmp115 __tmp777)) +(let __tmp848 (TCons __tmp114 __tmp847)) +(let __tmp849 (TCons __tmp114 __tmp848)) +(let __tmp850 (TCons __tmp114 __tmp849)) +(let __tmp851 (TCons __tmp114 __tmp850)) +(let __tmp852 (TCons __tmp114 __tmp851)) +(let __tmp853 (TCons __tmp0 __tmp852)) +(let __tmp854 (TupleT __tmp853)) +(let __tmp855 (Arg __tmp854 __tmp6)) +(let __tmp856 (Get __tmp855 11)) +(let __tmp857 (Get __tmp855 12)) +(let __tmp858 (Bop __tmp112 __tmp856 __tmp857)) +(let __tmp859 (Get __tmp855 0)) +(let __tmp860 (Single __tmp859)) +(let __tmp861 (Get __tmp855 1)) +(let __tmp862 (Single __tmp861)) +(let __tmp863 (Get __tmp855 2)) +(let __tmp864 (Single __tmp863)) +(let __tmp865 (Get __tmp855 3)) +(let __tmp866 (Single __tmp865)) +(let __tmp867 (Get __tmp855 4)) +(let __tmp868 (Single __tmp867)) +(let __tmp869 (Get __tmp855 5)) +(let __tmp870 (Single __tmp869)) +(let __tmp871 (Get __tmp855 6)) +(let __tmp872 (Single __tmp871)) +(let __tmp873 (Get __tmp855 7)) +(let __tmp874 (Single __tmp873)) +(let __tmp875 (Get __tmp855 8)) +(let __tmp876 (Single __tmp875)) +(let __tmp877 (Get __tmp855 9)) +(let __tmp878 (Single __tmp877)) +(let __tmp879 (Get __tmp855 10)) +(let __tmp880 (Single __tmp879)) +(let __tmp881 (Single __tmp856)) +(let __tmp882 (Single __tmp857)) +(let __tmp883 (Get __tmp855 13)) +(let __tmp884 (Single __tmp883)) +(let __tmp885 (Concat __tmp882 __tmp884)) +(let __tmp886 (Concat __tmp881 __tmp885)) +(let __tmp887 (Concat __tmp880 __tmp886)) +(let __tmp888 (Concat __tmp878 __tmp887)) +(let __tmp889 (Concat __tmp876 __tmp888)) +(let __tmp890 (Concat __tmp874 __tmp889)) +(let __tmp891 (Concat __tmp872 __tmp890)) +(let __tmp892 (Concat __tmp870 __tmp891)) +(let __tmp893 (Concat __tmp868 __tmp892)) +(let __tmp894 (Concat __tmp866 __tmp893)) +(let __tmp895 (Concat __tmp864 __tmp894)) +(let __tmp896 (Concat __tmp862 __tmp895)) +(let __tmp897 (Concat __tmp860 __tmp896)) +(let __tmp898 (Concat __tmp882 __tmp860)) +(let __tmp899 (Concat __tmp881 __tmp898)) +(let __tmp900 (Concat __tmp876 __tmp899)) +(let __tmp901 (Concat __tmp862 __tmp900)) +(let __tmp902 (Call "matrix_get" __tmp901)) +(let __tmp903 (Get __tmp902 0)) +(let __tmp904 (Get __tmp902 1)) +(let __tmp905 (Single __tmp904)) +(let __tmp906 (Concat __tmp874 __tmp905)) +(let __tmp907 (Concat __tmp880 __tmp906)) +(let __tmp908 (Concat __tmp881 __tmp907)) +(let __tmp909 (Concat __tmp866 __tmp908)) +(let __tmp910 (Call "matrix_get" __tmp909)) +(let __tmp911 (Get __tmp910 0)) +(let __tmp912 (Bop __tmp330 __tmp903 __tmp911)) +(let __tmp913 (Single __tmp912)) +(let __tmp914 (Get __tmp910 1)) +(let __tmp915 (Single __tmp914)) +(let __tmp916 (Concat __tmp913 __tmp915)) +(let __tmp917 (Concat __tmp874 __tmp916)) +(let __tmp918 (Concat __tmp880 __tmp917)) +(let __tmp919 (Concat __tmp876 __tmp918)) +(let __tmp920 (Concat __tmp864 __tmp919)) +(let __tmp921 (Call "matrix_incr" __tmp920)) +(let __tmp922 (Get __tmp921 0)) +(let __tmp923 (Single __tmp922)) +(let __tmp924 (Const __tmp361 __tmp854 __tmp6)) +(let __tmp925 (Single __tmp924)) +(let __tmp926 (Bop __tmp358 __tmp856 __tmp877)) +(let __tmp927 (Single __tmp926)) +(let __tmp928 (Concat __tmp927 __tmp885)) +(let __tmp929 (Concat __tmp925 __tmp928)) +(let __tmp930 (Concat __tmp880 __tmp929)) +(let __tmp931 (Concat __tmp878 __tmp930)) +(let __tmp932 (Concat __tmp876 __tmp931)) +(let __tmp933 (Concat __tmp874 __tmp932)) +(let __tmp934 (Concat __tmp872 __tmp933)) +(let __tmp935 (Concat __tmp870 __tmp934)) +(let __tmp936 (Concat __tmp868 __tmp935)) +(let __tmp937 (Concat __tmp866 __tmp936)) +(let __tmp938 (Concat __tmp864 __tmp937)) +(let __tmp939 (Concat __tmp862 __tmp938)) +(let __tmp940 (Concat __tmp923 __tmp939)) +(let __tmp941 (Const __tmp379 __tmp854 __tmp6)) +(let __tmp942 (Single __tmp941)) +(let __tmp943 (Concat __tmp942 __tmp886)) +(let __tmp944 (Concat __tmp880 __tmp943)) +(let __tmp945 (Concat __tmp878 __tmp944)) +(let __tmp946 (Concat __tmp876 __tmp945)) +(let __tmp947 (Concat __tmp874 __tmp946)) +(let __tmp948 (Concat __tmp872 __tmp947)) +(let __tmp949 (Concat __tmp870 __tmp948)) +(let __tmp950 (Concat __tmp868 __tmp949)) +(let __tmp951 (Concat __tmp866 __tmp950)) +(let __tmp952 (Concat __tmp864 __tmp951)) +(let __tmp953 (Concat __tmp862 __tmp952)) +(let __tmp954 (Concat __tmp860 __tmp953)) +(let __tmp955 (If __tmp858 __tmp897 __tmp940 __tmp954)) +(let __tmp956 (Get __tmp955 11)) +(let __tmp957 (Single __tmp956)) +(let __tmp958 (Get __tmp955 0)) +(let __tmp959 (Single __tmp958)) +(let __tmp960 (Get __tmp955 1)) +(let __tmp961 (Single __tmp960)) +(let __tmp962 (Get __tmp955 2)) +(let __tmp963 (Single __tmp962)) +(let __tmp964 (Get __tmp955 3)) +(let __tmp965 (Single __tmp964)) +(let __tmp966 (Get __tmp955 4)) +(let __tmp967 (Single __tmp966)) +(let __tmp968 (Get __tmp955 5)) +(let __tmp969 (Single __tmp968)) +(let __tmp970 (Get __tmp955 6)) +(let __tmp971 (Single __tmp970)) +(let __tmp972 (Get __tmp955 7)) +(let __tmp973 (Single __tmp972)) +(let __tmp974 (Get __tmp955 8)) +(let __tmp975 (Single __tmp974)) +(let __tmp976 (Get __tmp955 9)) +(let __tmp977 (Single __tmp976)) +(let __tmp978 (Get __tmp955 10)) +(let __tmp979 (Single __tmp978)) +(let __tmp980 (Get __tmp955 12)) +(let __tmp981 (Single __tmp980)) +(let __tmp982 (Get __tmp955 13)) +(let __tmp983 (Single __tmp982)) +(let __tmp984 (Get __tmp955 14)) +(let __tmp985 (Single __tmp984)) +(let __tmp986 (Concat __tmp983 __tmp985)) +(let __tmp987 (Concat __tmp981 __tmp986)) +(let __tmp988 (Concat __tmp979 __tmp987)) +(let __tmp989 (Concat __tmp977 __tmp988)) +(let __tmp990 (Concat __tmp975 __tmp989)) +(let __tmp991 (Concat __tmp973 __tmp990)) +(let __tmp992 (Concat __tmp971 __tmp991)) +(let __tmp993 (Concat __tmp969 __tmp992)) +(let __tmp994 (Concat __tmp967 __tmp993)) +(let __tmp995 (Concat __tmp965 __tmp994)) +(let __tmp996 (Concat __tmp963 __tmp995)) +(let __tmp997 (Concat __tmp961 __tmp996)) +(let __tmp998 (Concat __tmp959 __tmp997)) +(let __tmp999 (Concat __tmp957 __tmp998)) +(let __tmp1000 (DoWhile __tmp846 __tmp999)) +(let __tmp1001 (Get __tmp1000 0)) +(let __tmp1002 (Single __tmp1001)) +(let __tmp1003 (Get __tmp1000 1)) +(let __tmp1004 (Single __tmp1003)) +(let __tmp1005 (Get __tmp1000 2)) +(let __tmp1006 (Single __tmp1005)) +(let __tmp1007 (Get __tmp1000 3)) +(let __tmp1008 (Single __tmp1007)) +(let __tmp1009 (Get __tmp1000 4)) +(let __tmp1010 (Single __tmp1009)) +(let __tmp1011 (Get __tmp1000 5)) +(let __tmp1012 (Single __tmp1011)) +(let __tmp1013 (Get __tmp1000 6)) +(let __tmp1014 (Single __tmp1013)) +(let __tmp1015 (Get __tmp1000 7)) +(let __tmp1016 (Single __tmp1015)) +(let __tmp1017 (Get __tmp1000 8)) +(let __tmp1018 (Single __tmp1017)) +(let __tmp1019 (Get __tmp1000 9)) +(let __tmp1020 (Single __tmp1019)) +(let __tmp1021 (Const __tmp361 __tmp784 __tmp6)) +(let __tmp1022 (Single __tmp1021)) +(let __tmp1023 (Get __tmp1000 10)) +(let __tmp1024 (Bop __tmp358 __tmp1023 __tmp1019)) +(let __tmp1025 (Single __tmp1024)) +(let __tmp1026 (Get __tmp1000 12)) +(let __tmp1027 (Single __tmp1026)) +(let __tmp1028 (Get __tmp1000 13)) +(let __tmp1029 (Single __tmp1028)) +(let __tmp1030 (Concat __tmp1027 __tmp1029)) +(let __tmp1031 (Concat __tmp1025 __tmp1030)) +(let __tmp1032 (Concat __tmp1022 __tmp1031)) +(let __tmp1033 (Concat __tmp1020 __tmp1032)) +(let __tmp1034 (Concat __tmp1018 __tmp1033)) +(let __tmp1035 (Concat __tmp1016 __tmp1034)) +(let __tmp1036 (Concat __tmp1014 __tmp1035)) +(let __tmp1037 (Concat __tmp1012 __tmp1036)) +(let __tmp1038 (Concat __tmp1010 __tmp1037)) +(let __tmp1039 (Concat __tmp1008 __tmp1038)) +(let __tmp1040 (Concat __tmp1006 __tmp1039)) +(let __tmp1041 (Concat __tmp1004 __tmp1040)) +(let __tmp1042 (Concat __tmp1002 __tmp1041)) +(let __tmp1043 (Const __tmp379 __tmp784 __tmp6)) +(let __tmp1044 (Single __tmp1043)) +(let __tmp1045 (Concat __tmp1044 __tmp814)) +(let __tmp1046 (Concat __tmp807 __tmp1045)) +(let __tmp1047 (Concat __tmp805 __tmp1046)) +(let __tmp1048 (Concat __tmp803 __tmp1047)) +(let __tmp1049 (Concat __tmp802 __tmp1048)) +(let __tmp1050 (Concat __tmp800 __tmp1049)) +(let __tmp1051 (Concat __tmp798 __tmp1050)) +(let __tmp1052 (Concat __tmp796 __tmp1051)) +(let __tmp1053 (Concat __tmp794 __tmp1052)) +(let __tmp1054 (Concat __tmp792 __tmp1053)) +(let __tmp1055 (Concat __tmp790 __tmp1054)) +(let __tmp1056 (If __tmp788 __tmp824 __tmp1042 __tmp1055)) +(let __tmp1057 (Get __tmp1056 10)) +(let __tmp1058 (Single __tmp1057)) +(let __tmp1059 (Get __tmp1056 0)) +(let __tmp1060 (Single __tmp1059)) +(let __tmp1061 (Get __tmp1056 1)) +(let __tmp1062 (Single __tmp1061)) +(let __tmp1063 (Get __tmp1056 2)) +(let __tmp1064 (Single __tmp1063)) +(let __tmp1065 (Get __tmp1056 3)) +(let __tmp1066 (Single __tmp1065)) +(let __tmp1067 (Get __tmp1056 4)) +(let __tmp1068 (Single __tmp1067)) +(let __tmp1069 (Get __tmp1056 5)) +(let __tmp1070 (Single __tmp1069)) +(let __tmp1071 (Get __tmp1056 6)) +(let __tmp1072 (Single __tmp1071)) +(let __tmp1073 (Get __tmp1056 7)) +(let __tmp1074 (Single __tmp1073)) +(let __tmp1075 (Get __tmp1056 8)) +(let __tmp1076 (Single __tmp1075)) +(let __tmp1077 (Get __tmp1056 9)) +(let __tmp1078 (Single __tmp1077)) +(let __tmp1079 (Get __tmp1056 11)) +(let __tmp1080 (Single __tmp1079)) +(let __tmp1081 (Get __tmp1056 12)) +(let __tmp1082 (Single __tmp1081)) +(let __tmp1083 (Get __tmp1056 13)) +(let __tmp1084 (Single __tmp1083)) +(let __tmp1085 (Concat __tmp1082 __tmp1084)) +(let __tmp1086 (Concat __tmp1080 __tmp1085)) +(let __tmp1087 (Concat __tmp1078 __tmp1086)) +(let __tmp1088 (Concat __tmp1076 __tmp1087)) +(let __tmp1089 (Concat __tmp1074 __tmp1088)) +(let __tmp1090 (Concat __tmp1072 __tmp1089)) +(let __tmp1091 (Concat __tmp1070 __tmp1090)) +(let __tmp1092 (Concat __tmp1068 __tmp1091)) +(let __tmp1093 (Concat __tmp1066 __tmp1092)) +(let __tmp1094 (Concat __tmp1064 __tmp1093)) +(let __tmp1095 (Concat __tmp1062 __tmp1094)) +(let __tmp1096 (Concat __tmp1060 __tmp1095)) +(let __tmp1097 (Concat __tmp1058 __tmp1096)) +(let __tmp1098 (DoWhile __tmp776 __tmp1097)) +(let __tmp1099 (Get __tmp1098 0)) +(let __tmp1100 (Single __tmp1099)) +(let __tmp1101 (Get __tmp1098 1)) +(let __tmp1102 (Single __tmp1101)) +(let __tmp1103 (Get __tmp1098 2)) +(let __tmp1104 (Single __tmp1103)) +(let __tmp1105 (Get __tmp1098 3)) +(let __tmp1106 (Single __tmp1105)) +(let __tmp1107 (Get __tmp1098 4)) +(let __tmp1108 (Single __tmp1107)) +(let __tmp1109 (Get __tmp1098 5)) +(let __tmp1110 (Single __tmp1109)) +(let __tmp1111 (Get __tmp1098 6)) +(let __tmp1112 (Single __tmp1111)) +(let __tmp1113 (Get __tmp1098 7)) +(let __tmp1114 (Single __tmp1113)) +(let __tmp1115 (Const __tmp361 __tmp726 __tmp6)) +(let __tmp1116 (Single __tmp1115)) +(let __tmp1117 (Get __tmp1098 8)) +(let __tmp1118 (Get __tmp1098 9)) +(let __tmp1119 (Bop __tmp358 __tmp1117 __tmp1118)) +(let __tmp1120 (Single __tmp1119)) +(let __tmp1121 (Single __tmp1118)) +(let __tmp1122 (Get __tmp1098 11)) +(let __tmp1123 (Single __tmp1122)) +(let __tmp1124 (Get __tmp1098 12)) +(let __tmp1125 (Single __tmp1124)) +(let __tmp1126 (Concat __tmp1123 __tmp1125)) +(let __tmp1127 (Concat __tmp1121 __tmp1126)) +(let __tmp1128 (Concat __tmp1120 __tmp1127)) +(let __tmp1129 (Concat __tmp1116 __tmp1128)) +(let __tmp1130 (Concat __tmp1114 __tmp1129)) +(let __tmp1131 (Concat __tmp1112 __tmp1130)) +(let __tmp1132 (Concat __tmp1110 __tmp1131)) +(let __tmp1133 (Concat __tmp1108 __tmp1132)) +(let __tmp1134 (Concat __tmp1106 __tmp1133)) +(let __tmp1135 (Concat __tmp1104 __tmp1134)) +(let __tmp1136 (Concat __tmp1102 __tmp1135)) +(let __tmp1137 (Concat __tmp1100 __tmp1136)) +(let __tmp1138 (Const __tmp379 __tmp726 __tmp6)) +(let __tmp1139 (Single __tmp1138)) +(let __tmp1140 (Concat __tmp1139 __tmp755)) +(let __tmp1141 (Concat __tmp745 __tmp1140)) +(let __tmp1142 (Concat __tmp743 __tmp1141)) +(let __tmp1143 (Concat __tmp742 __tmp1142)) +(let __tmp1144 (Concat __tmp740 __tmp1143)) +(let __tmp1145 (Concat __tmp738 __tmp1144)) +(let __tmp1146 (Concat __tmp736 __tmp1145)) +(let __tmp1147 (Concat __tmp734 __tmp1146)) +(let __tmp1148 (Concat __tmp732 __tmp1147)) +(let __tmp1149 (If __tmp730 __tmp763 __tmp1137 __tmp1148)) +(let __tmp1150 (Get __tmp1149 8)) +(let __tmp1151 (Single __tmp1150)) +(let __tmp1152 (Get __tmp1149 0)) +(let __tmp1153 (Single __tmp1152)) +(let __tmp1154 (Get __tmp1149 1)) +(let __tmp1155 (Single __tmp1154)) +(let __tmp1156 (Get __tmp1149 2)) +(let __tmp1157 (Single __tmp1156)) +(let __tmp1158 (Get __tmp1149 3)) +(let __tmp1159 (Single __tmp1158)) +(let __tmp1160 (Get __tmp1149 4)) +(let __tmp1161 (Single __tmp1160)) +(let __tmp1162 (Get __tmp1149 5)) +(let __tmp1163 (Single __tmp1162)) +(let __tmp1164 (Get __tmp1149 6)) +(let __tmp1165 (Single __tmp1164)) +(let __tmp1166 (Get __tmp1149 7)) +(let __tmp1167 (Single __tmp1166)) +(let __tmp1168 (Get __tmp1149 9)) +(let __tmp1169 (Single __tmp1168)) +(let __tmp1170 (Get __tmp1149 10)) +(let __tmp1171 (Single __tmp1170)) +(let __tmp1172 (Get __tmp1149 11)) +(let __tmp1173 (Single __tmp1172)) +(let __tmp1174 (Get __tmp1149 12)) +(let __tmp1175 (Single __tmp1174)) +(let __tmp1176 (Concat __tmp1173 __tmp1175)) +(let __tmp1177 (Concat __tmp1171 __tmp1176)) +(let __tmp1178 (Concat __tmp1169 __tmp1177)) +(let __tmp1179 (Concat __tmp1167 __tmp1178)) +(let __tmp1180 (Concat __tmp1165 __tmp1179)) +(let __tmp1181 (Concat __tmp1163 __tmp1180)) +(let __tmp1182 (Concat __tmp1161 __tmp1181)) +(let __tmp1183 (Concat __tmp1159 __tmp1182)) +(let __tmp1184 (Concat __tmp1157 __tmp1183)) +(let __tmp1185 (Concat __tmp1155 __tmp1184)) +(let __tmp1186 (Concat __tmp1153 __tmp1185)) +(let __tmp1187 (Concat __tmp1151 __tmp1186)) +(let __tmp1188 (DoWhile __tmp715 __tmp1187)) +(let __tmp1189 (Get __tmp1188 2)) +(let __tmp1190 (Single __tmp1189)) +(let __tmp1191 (Get __tmp1188 6)) +(let __tmp1192 (Single __tmp1191)) +(let __tmp1193 (Get __tmp1188 7)) +(let __tmp1194 (Single __tmp1193)) +(let __tmp1195 (Get __tmp1188 0)) +(let __tmp1196 (Single __tmp1195)) +(let __tmp1197 (Concat __tmp1194 __tmp1196)) +(let __tmp1198 (Concat __tmp1192 __tmp1197)) +(let __tmp1199 (Concat __tmp1190 __tmp1198)) +(let __tmp1200 (Call "matrix_sum" __tmp1199)) +(let __tmp1201 (Get __tmp1200 0)) +(let __tmp1202 (Free )) +(let __tmp1203 (Get __tmp1188 1)) +(let __tmp1204 (Get __tmp1188 3)) +(let __tmp1205 (Get __tmp1188 4)) +(let __tmp1206 (Get __tmp1188 5)) +(let __tmp1207 (Get __tmp1200 1)) +(let __tmp1208 (Bop __tmp1202 __tmp1206 __tmp1207)) +(let __tmp1209 (Bop __tmp1202 __tmp1205 __tmp1208)) +(let __tmp1210 (Bop __tmp1202 __tmp1204 __tmp1209)) +(let __tmp1211 (Bop __tmp1202 __tmp1189 __tmp1210)) +(let __tmp1212 (Bop __tmp1202 __tmp1203 __tmp1211)) +(let __tmp1213 (Bop __tmp4 __tmp1201 __tmp1212)) +(let __tmp1214 (Single __tmp1213)) +(let __tmp1215 (Function "main" __tmp3 __tmp3 __tmp1214)) +(let __tmp1216 (TCons __tmp113 __tmp2)) +(let __tmp1217 (TCons __tmp115 __tmp1216)) +(let __tmp1218 (TCons __tmp113 __tmp1217)) +(let __tmp1219 (TCons __tmp115 __tmp1218)) +(let __tmp1220 (TCons __tmp113 __tmp1219)) +(let __tmp1221 (TCons __tmp115 __tmp1220)) +(let __tmp1222 (TCons __tmp113 __tmp1221)) +(let __tmp1223 (TCons __tmp115 __tmp1222)) +(let __tmp1224 (TCons __tmp114 __tmp1223)) +(let __tmp1225 (TCons __tmp114 __tmp1224)) +(let __tmp1226 (TCons __tmp114 __tmp1225)) +(let __tmp1227 (TCons __tmp114 __tmp1226)) +(let __tmp1228 (TupleT __tmp1227)) +(let __tmp1229 (Arg __tmp1228 __tmp6)) +(let __tmp1230 (Get __tmp1229 12)) +(let __tmp1231 (Single __tmp1230)) +(let __tmp1232 (Const __tmp95 __tmp1228 __tmp6)) +(let __tmp1233 (Single __tmp1232)) +(let __tmp1234 (Float 1.0)) +(let __tmp1235 (Const __tmp1234 __tmp1228 __tmp6)) +(let __tmp1236 (Single __tmp1235)) +(let __tmp1237 (Const __tmp83 __tmp1228 __tmp6)) +(let __tmp1238 (Single __tmp1237)) +(let __tmp1239 (Const __tmp86 __tmp1228 __tmp6)) +(let __tmp1240 (Single __tmp1239)) +(let __tmp1241 (Get __tmp1229 3)) +(let __tmp1242 (Single __tmp1241)) +(let __tmp1243 (Get __tmp1229 10)) +(let __tmp1244 (Single __tmp1243)) +(let __tmp1245 (Get __tmp1229 9)) +(let __tmp1246 (Single __tmp1245)) +(let __tmp1247 (Float 2.0)) +(let __tmp1248 (Const __tmp1247 __tmp1228 __tmp6)) +(let __tmp1249 (Single __tmp1248)) +(let __tmp1250 (Get __tmp1229 4)) +(let __tmp1251 (Single __tmp1250)) +(let __tmp1252 (Get __tmp1229 2)) +(let __tmp1253 (Single __tmp1252)) +(let __tmp1254 (Get __tmp1229 11)) +(let __tmp1255 (Single __tmp1254)) +(let __tmp1256 (Float 3.0)) +(let __tmp1257 (Const __tmp1256 __tmp1228 __tmp6)) +(let __tmp1258 (Single __tmp1257)) +(let __tmp1259 (Get __tmp1229 6)) +(let __tmp1260 (Single __tmp1259)) +(let __tmp1261 (Get __tmp1229 1)) +(let __tmp1262 (Single __tmp1261)) +(let __tmp1263 (Get __tmp1229 7)) +(let __tmp1264 (Single __tmp1263)) +(let __tmp1265 (Get __tmp1229 8)) +(let __tmp1266 (Single __tmp1265)) +(let __tmp1267 (Get __tmp1229 0)) +(let __tmp1268 (Single __tmp1267)) +(let __tmp1269 (Get __tmp1229 5)) +(let __tmp1270 (Single __tmp1269)) +(let __tmp1271 (Concat __tmp1268 __tmp1270)) +(let __tmp1272 (Concat __tmp1266 __tmp1271)) +(let __tmp1273 (Concat __tmp1264 __tmp1272)) +(let __tmp1274 (Concat __tmp1262 __tmp1273)) +(let __tmp1275 (Concat __tmp1260 __tmp1274)) +(let __tmp1276 (Concat __tmp1258 __tmp1275)) +(let __tmp1277 (Concat __tmp1255 __tmp1276)) +(let __tmp1278 (Concat __tmp1253 __tmp1277)) +(let __tmp1279 (Concat __tmp1251 __tmp1278)) +(let __tmp1280 (Concat __tmp1249 __tmp1279)) +(let __tmp1281 (Concat __tmp1246 __tmp1280)) +(let __tmp1282 (Concat __tmp1244 __tmp1281)) +(let __tmp1283 (Concat __tmp1242 __tmp1282)) +(let __tmp1284 (Concat __tmp1240 __tmp1283)) +(let __tmp1285 (Concat __tmp1238 __tmp1284)) +(let __tmp1286 (Concat __tmp1236 __tmp1285)) +(let __tmp1287 (Concat __tmp1233 __tmp1286)) +(let __tmp1288 (Concat __tmp1231 __tmp1287)) +(let __tmp1289 (TCons __tmp114 __tmp116)) +(let __tmp1290 (TCons __tmp115 __tmp1289)) +(let __tmp1291 (TCons __tmp113 __tmp1290)) +(let __tmp1292 (TCons __tmp114 __tmp1291)) +(let __tmp1293 (TCons __tmp115 __tmp1292)) +(let __tmp1294 (TCons __tmp113 __tmp1293)) +(let __tmp1295 (TCons __tmp113 __tmp1294)) +(let __tmp1296 (TCons __tmp114 __tmp1295)) +(let __tmp1297 (TCons __tmp115 __tmp1296)) +(let __tmp1298 (TCons __tmp113 __tmp1297)) +(let __tmp1299 (TCons __tmp113 __tmp1298)) +(let __tmp1300 (TCons __tmp115 __tmp1299)) +(let __tmp1301 (TCons __tmp114 __tmp1300)) +(let __tmp1302 (TCons __tmp115 __tmp1301)) +(let __tmp1303 (TCons __tmp115 __tmp1302)) +(let __tmp1304 (TCons __tmp113 __tmp1303)) +(let __tmp1305 (TCons __tmp113 __tmp1304)) +(let __tmp1306 (TCons __tmp0 __tmp1305)) +(let __tmp1307 (TupleT __tmp1306)) +(let __tmp1308 (Arg __tmp1307 __tmp6)) +(let __tmp1309 (Get __tmp1308 3)) +(let __tmp1310 (Get __tmp1308 9)) +(let __tmp1311 (Bop __tmp112 __tmp1309 __tmp1310)) +(let __tmp1312 (Get __tmp1308 0)) +(let __tmp1313 (Single __tmp1312)) +(let __tmp1314 (Get __tmp1308 1)) +(let __tmp1315 (Single __tmp1314)) +(let __tmp1316 (Get __tmp1308 2)) +(let __tmp1317 (Single __tmp1316)) +(let __tmp1318 (Single __tmp1309)) +(let __tmp1319 (Get __tmp1308 4)) +(let __tmp1320 (Single __tmp1319)) +(let __tmp1321 (Get __tmp1308 5)) +(let __tmp1322 (Single __tmp1321)) +(let __tmp1323 (Get __tmp1308 6)) +(let __tmp1324 (Single __tmp1323)) +(let __tmp1325 (Get __tmp1308 7)) +(let __tmp1326 (Single __tmp1325)) +(let __tmp1327 (Get __tmp1308 8)) +(let __tmp1328 (Single __tmp1327)) +(let __tmp1329 (Single __tmp1310)) +(let __tmp1330 (Get __tmp1308 10)) +(let __tmp1331 (Single __tmp1330)) +(let __tmp1332 (Get __tmp1308 11)) +(let __tmp1333 (Single __tmp1332)) +(let __tmp1334 (Get __tmp1308 12)) +(let __tmp1335 (Single __tmp1334)) +(let __tmp1336 (Get __tmp1308 13)) +(let __tmp1337 (Single __tmp1336)) +(let __tmp1338 (Get __tmp1308 14)) +(let __tmp1339 (Single __tmp1338)) +(let __tmp1340 (Get __tmp1308 15)) +(let __tmp1341 (Single __tmp1340)) +(let __tmp1342 (Get __tmp1308 16)) +(let __tmp1343 (Single __tmp1342)) +(let __tmp1344 (Get __tmp1308 17)) +(let __tmp1345 (Single __tmp1344)) +(let __tmp1346 (Get __tmp1308 18)) +(let __tmp1347 (Single __tmp1346)) +(let __tmp1348 (Concat __tmp1345 __tmp1347)) +(let __tmp1349 (Concat __tmp1343 __tmp1348)) +(let __tmp1350 (Concat __tmp1341 __tmp1349)) +(let __tmp1351 (Concat __tmp1339 __tmp1350)) +(let __tmp1352 (Concat __tmp1337 __tmp1351)) +(let __tmp1353 (Concat __tmp1335 __tmp1352)) +(let __tmp1354 (Concat __tmp1333 __tmp1353)) +(let __tmp1355 (Concat __tmp1331 __tmp1354)) +(let __tmp1356 (Concat __tmp1329 __tmp1355)) +(let __tmp1357 (Concat __tmp1328 __tmp1356)) +(let __tmp1358 (Concat __tmp1326 __tmp1357)) +(let __tmp1359 (Concat __tmp1324 __tmp1358)) +(let __tmp1360 (Concat __tmp1322 __tmp1359)) +(let __tmp1361 (Concat __tmp1320 __tmp1360)) +(let __tmp1362 (Concat __tmp1318 __tmp1361)) +(let __tmp1363 (Concat __tmp1317 __tmp1362)) +(let __tmp1364 (Concat __tmp1315 __tmp1363)) +(let __tmp1365 (Concat __tmp1313 __tmp1364)) +(let __tmp1366 (Const __tmp95 __tmp1307 __tmp6)) +(let __tmp1367 (Single __tmp1366)) +(let __tmp1368 (Const __tmp83 __tmp1307 __tmp6)) +(let __tmp1369 (Single __tmp1368)) +(let __tmp1370 (Concat __tmp1369 __tmp1360)) +(let __tmp1371 (Concat __tmp1367 __tmp1370)) +(let __tmp1372 (Concat __tmp1320 __tmp1371)) +(let __tmp1373 (Concat __tmp1318 __tmp1372)) +(let __tmp1374 (Concat __tmp1317 __tmp1373)) +(let __tmp1375 (Concat __tmp1315 __tmp1374)) +(let __tmp1376 (Concat __tmp1313 __tmp1375)) +(let __tmp1377 (TCons __tmp113 __tmp1302)) +(let __tmp1378 (TCons __tmp115 __tmp1377)) +(let __tmp1379 (TCons __tmp115 __tmp1378)) +(let __tmp1380 (TCons __tmp113 __tmp1379)) +(let __tmp1381 (TCons __tmp113 __tmp1380)) +(let __tmp1382 (TCons __tmp0 __tmp1381)) +(let __tmp1383 (TupleT __tmp1382)) +(let __tmp1384 (Arg __tmp1383 __tmp6)) +(let __tmp1385 (Get __tmp1384 6)) +(let __tmp1386 (Get __tmp1384 18)) +(let __tmp1387 (Bop __tmp112 __tmp1385 __tmp1386)) +(let __tmp1388 (Get __tmp1384 0)) +(let __tmp1389 (Single __tmp1388)) +(let __tmp1390 (Get __tmp1384 1)) +(let __tmp1391 (Single __tmp1390)) +(let __tmp1392 (Get __tmp1384 2)) +(let __tmp1393 (Single __tmp1392)) +(let __tmp1394 (Get __tmp1384 3)) +(let __tmp1395 (Single __tmp1394)) +(let __tmp1396 (Get __tmp1384 4)) +(let __tmp1397 (Single __tmp1396)) +(let __tmp1398 (Get __tmp1384 5)) +(let __tmp1399 (Single __tmp1398)) +(let __tmp1400 (Single __tmp1385)) +(let __tmp1401 (Get __tmp1384 7)) +(let __tmp1402 (Single __tmp1401)) +(let __tmp1403 (Get __tmp1384 8)) +(let __tmp1404 (Single __tmp1403)) +(let __tmp1405 (Get __tmp1384 9)) +(let __tmp1406 (Single __tmp1405)) +(let __tmp1407 (Get __tmp1384 10)) +(let __tmp1408 (Single __tmp1407)) +(let __tmp1409 (Get __tmp1384 11)) +(let __tmp1410 (Single __tmp1409)) +(let __tmp1411 (Get __tmp1384 12)) +(let __tmp1412 (Single __tmp1411)) +(let __tmp1413 (Get __tmp1384 13)) +(let __tmp1414 (Single __tmp1413)) +(let __tmp1415 (Get __tmp1384 14)) +(let __tmp1416 (Single __tmp1415)) +(let __tmp1417 (Get __tmp1384 15)) +(let __tmp1418 (Single __tmp1417)) +(let __tmp1419 (Get __tmp1384 16)) +(let __tmp1420 (Single __tmp1419)) +(let __tmp1421 (Get __tmp1384 17)) +(let __tmp1422 (Single __tmp1421)) +(let __tmp1423 (Single __tmp1386)) +(let __tmp1424 (Get __tmp1384 19)) +(let __tmp1425 (Single __tmp1424)) +(let __tmp1426 (Get __tmp1384 20)) +(let __tmp1427 (Single __tmp1426)) +(let __tmp1428 (Concat __tmp1425 __tmp1427)) +(let __tmp1429 (Concat __tmp1423 __tmp1428)) +(let __tmp1430 (Concat __tmp1422 __tmp1429)) +(let __tmp1431 (Concat __tmp1420 __tmp1430)) +(let __tmp1432 (Concat __tmp1418 __tmp1431)) +(let __tmp1433 (Concat __tmp1416 __tmp1432)) +(let __tmp1434 (Concat __tmp1414 __tmp1433)) +(let __tmp1435 (Concat __tmp1412 __tmp1434)) +(let __tmp1436 (Concat __tmp1410 __tmp1435)) +(let __tmp1437 (Concat __tmp1408 __tmp1436)) +(let __tmp1438 (Concat __tmp1406 __tmp1437)) +(let __tmp1439 (Concat __tmp1404 __tmp1438)) +(let __tmp1440 (Concat __tmp1402 __tmp1439)) +(let __tmp1441 (Concat __tmp1400 __tmp1440)) +(let __tmp1442 (Concat __tmp1399 __tmp1441)) +(let __tmp1443 (Concat __tmp1397 __tmp1442)) +(let __tmp1444 (Concat __tmp1395 __tmp1443)) +(let __tmp1445 (Concat __tmp1393 __tmp1444)) +(let __tmp1446 (Concat __tmp1391 __tmp1445)) +(let __tmp1447 (Concat __tmp1389 __tmp1446)) +(let __tmp1448 (FDiv )) +(let __tmp1449 (FAdd )) +(let __tmp1450 (Bop __tmp330 __tmp1390 __tmp1398)) +(let __tmp1451 (Bop __tmp1449 __tmp1450 __tmp1392)) +(let __tmp1452 (Single __tmp1451)) +(let __tmp1453 (Concat __tmp1427 __tmp1389)) +(let __tmp1454 (Concat __tmp1452 __tmp1453)) +(let __tmp1455 (Call "fmod" __tmp1454)) +(let __tmp1456 (Get __tmp1455 0)) +(let __tmp1457 (Bop __tmp1448 __tmp1456 __tmp1426)) +(let __tmp1458 (Single __tmp1457)) +(let __tmp1459 (Get __tmp1455 1)) +(let __tmp1460 (Single __tmp1459)) +(let __tmp1461 (Concat __tmp1458 __tmp1460)) +(let __tmp1462 (Concat __tmp1423 __tmp1461)) +(let __tmp1463 (Concat __tmp1400 __tmp1462)) +(let __tmp1464 (Concat __tmp1395 __tmp1463)) +(let __tmp1465 (Concat __tmp1425 __tmp1464)) +(let __tmp1466 (Call "matrix_set" __tmp1465)) +(let __tmp1467 (Get __tmp1466 0)) +(let __tmp1468 (Single __tmp1467)) +(let __tmp1469 (Bop __tmp1449 __tmp1398 __tmp1392)) +(let __tmp1470 (Single __tmp1469)) +(let __tmp1471 (Bop __tmp358 __tmp1385 __tmp1396)) +(let __tmp1472 (Single __tmp1471)) +(let __tmp1473 (Const __tmp361 __tmp1383 __tmp6)) +(let __tmp1474 (Single __tmp1473)) +(let __tmp1475 (Concat __tmp1474 __tmp1428)) +(let __tmp1476 (Concat __tmp1423 __tmp1475)) +(let __tmp1477 (Concat __tmp1422 __tmp1476)) +(let __tmp1478 (Concat __tmp1420 __tmp1477)) +(let __tmp1479 (Concat __tmp1418 __tmp1478)) +(let __tmp1480 (Concat __tmp1416 __tmp1479)) +(let __tmp1481 (Concat __tmp1414 __tmp1480)) +(let __tmp1482 (Concat __tmp1412 __tmp1481)) +(let __tmp1483 (Concat __tmp1410 __tmp1482)) +(let __tmp1484 (Concat __tmp1408 __tmp1483)) +(let __tmp1485 (Concat __tmp1406 __tmp1484)) +(let __tmp1486 (Concat __tmp1404 __tmp1485)) +(let __tmp1487 (Concat __tmp1402 __tmp1486)) +(let __tmp1488 (Concat __tmp1472 __tmp1487)) +(let __tmp1489 (Concat __tmp1470 __tmp1488)) +(let __tmp1490 (Concat __tmp1397 __tmp1489)) +(let __tmp1491 (Concat __tmp1395 __tmp1490)) +(let __tmp1492 (Concat __tmp1393 __tmp1491)) +(let __tmp1493 (Concat __tmp1391 __tmp1492)) +(let __tmp1494 (Concat __tmp1468 __tmp1493)) +(let __tmp1495 (Const __tmp379 __tmp1383 __tmp6)) +(let __tmp1496 (Single __tmp1495)) +(let __tmp1497 (Concat __tmp1496 __tmp1428)) +(let __tmp1498 (Concat __tmp1423 __tmp1497)) +(let __tmp1499 (Concat __tmp1422 __tmp1498)) +(let __tmp1500 (Concat __tmp1420 __tmp1499)) +(let __tmp1501 (Concat __tmp1418 __tmp1500)) +(let __tmp1502 (Concat __tmp1416 __tmp1501)) +(let __tmp1503 (Concat __tmp1414 __tmp1502)) +(let __tmp1504 (Concat __tmp1412 __tmp1503)) +(let __tmp1505 (Concat __tmp1410 __tmp1504)) +(let __tmp1506 (Concat __tmp1408 __tmp1505)) +(let __tmp1507 (Concat __tmp1406 __tmp1506)) +(let __tmp1508 (Concat __tmp1404 __tmp1507)) +(let __tmp1509 (Concat __tmp1402 __tmp1508)) +(let __tmp1510 (Concat __tmp1400 __tmp1509)) +(let __tmp1511 (Concat __tmp1399 __tmp1510)) +(let __tmp1512 (Concat __tmp1397 __tmp1511)) +(let __tmp1513 (Concat __tmp1395 __tmp1512)) +(let __tmp1514 (Concat __tmp1393 __tmp1513)) +(let __tmp1515 (Concat __tmp1391 __tmp1514)) +(let __tmp1516 (Concat __tmp1389 __tmp1515)) +(let __tmp1517 (If __tmp1387 __tmp1447 __tmp1494 __tmp1516)) +(let __tmp1518 (Get __tmp1517 19)) +(let __tmp1519 (Single __tmp1518)) +(let __tmp1520 (Get __tmp1517 0)) +(let __tmp1521 (Single __tmp1520)) +(let __tmp1522 (Get __tmp1517 1)) +(let __tmp1523 (Single __tmp1522)) +(let __tmp1524 (Get __tmp1517 2)) +(let __tmp1525 (Single __tmp1524)) +(let __tmp1526 (Get __tmp1517 3)) +(let __tmp1527 (Single __tmp1526)) +(let __tmp1528 (Get __tmp1517 4)) +(let __tmp1529 (Single __tmp1528)) +(let __tmp1530 (Get __tmp1517 5)) +(let __tmp1531 (Single __tmp1530)) +(let __tmp1532 (Get __tmp1517 6)) +(let __tmp1533 (Single __tmp1532)) +(let __tmp1534 (Get __tmp1517 7)) +(let __tmp1535 (Single __tmp1534)) +(let __tmp1536 (Get __tmp1517 8)) +(let __tmp1537 (Single __tmp1536)) +(let __tmp1538 (Get __tmp1517 9)) +(let __tmp1539 (Single __tmp1538)) +(let __tmp1540 (Get __tmp1517 10)) +(let __tmp1541 (Single __tmp1540)) +(let __tmp1542 (Get __tmp1517 11)) +(let __tmp1543 (Single __tmp1542)) +(let __tmp1544 (Get __tmp1517 12)) +(let __tmp1545 (Single __tmp1544)) +(let __tmp1546 (Get __tmp1517 13)) +(let __tmp1547 (Single __tmp1546)) +(let __tmp1548 (Get __tmp1517 14)) +(let __tmp1549 (Single __tmp1548)) +(let __tmp1550 (Get __tmp1517 15)) +(let __tmp1551 (Single __tmp1550)) +(let __tmp1552 (Get __tmp1517 16)) +(let __tmp1553 (Single __tmp1552)) +(let __tmp1554 (Get __tmp1517 17)) +(let __tmp1555 (Single __tmp1554)) +(let __tmp1556 (Get __tmp1517 18)) +(let __tmp1557 (Single __tmp1556)) +(let __tmp1558 (Get __tmp1517 20)) +(let __tmp1559 (Single __tmp1558)) +(let __tmp1560 (Get __tmp1517 21)) +(let __tmp1561 (Single __tmp1560)) +(let __tmp1562 (Concat __tmp1559 __tmp1561)) +(let __tmp1563 (Concat __tmp1557 __tmp1562)) +(let __tmp1564 (Concat __tmp1555 __tmp1563)) +(let __tmp1565 (Concat __tmp1553 __tmp1564)) +(let __tmp1566 (Concat __tmp1551 __tmp1565)) +(let __tmp1567 (Concat __tmp1549 __tmp1566)) +(let __tmp1568 (Concat __tmp1547 __tmp1567)) +(let __tmp1569 (Concat __tmp1545 __tmp1568)) +(let __tmp1570 (Concat __tmp1543 __tmp1569)) +(let __tmp1571 (Concat __tmp1541 __tmp1570)) +(let __tmp1572 (Concat __tmp1539 __tmp1571)) +(let __tmp1573 (Concat __tmp1537 __tmp1572)) +(let __tmp1574 (Concat __tmp1535 __tmp1573)) +(let __tmp1575 (Concat __tmp1533 __tmp1574)) +(let __tmp1576 (Concat __tmp1531 __tmp1575)) +(let __tmp1577 (Concat __tmp1529 __tmp1576)) +(let __tmp1578 (Concat __tmp1527 __tmp1577)) +(let __tmp1579 (Concat __tmp1525 __tmp1578)) +(let __tmp1580 (Concat __tmp1523 __tmp1579)) +(let __tmp1581 (Concat __tmp1521 __tmp1580)) +(let __tmp1582 (Concat __tmp1519 __tmp1581)) +(let __tmp1583 (DoWhile __tmp1376 __tmp1582)) +(let __tmp1584 (Get __tmp1583 0)) +(let __tmp1585 (Single __tmp1584)) +(let __tmp1586 (Get __tmp1583 1)) +(let __tmp1587 (Get __tmp1583 2)) +(let __tmp1588 (Bop __tmp1449 __tmp1586 __tmp1587)) +(let __tmp1589 (Single __tmp1588)) +(let __tmp1590 (Single __tmp1587)) +(let __tmp1591 (Get __tmp1583 3)) +(let __tmp1592 (Get __tmp1583 4)) +(let __tmp1593 (Bop __tmp358 __tmp1591 __tmp1592)) +(let __tmp1594 (Single __tmp1593)) +(let __tmp1595 (Single __tmp1592)) +(let __tmp1596 (Get __tmp1583 7)) +(let __tmp1597 (Single __tmp1596)) +(let __tmp1598 (Get __tmp1583 8)) +(let __tmp1599 (Single __tmp1598)) +(let __tmp1600 (Get __tmp1583 9)) +(let __tmp1601 (Single __tmp1600)) +(let __tmp1602 (Get __tmp1583 10)) +(let __tmp1603 (Single __tmp1602)) +(let __tmp1604 (Get __tmp1583 11)) +(let __tmp1605 (Single __tmp1604)) +(let __tmp1606 (Get __tmp1583 12)) +(let __tmp1607 (Single __tmp1606)) +(let __tmp1608 (Get __tmp1583 13)) +(let __tmp1609 (Single __tmp1608)) +(let __tmp1610 (Get __tmp1583 14)) +(let __tmp1611 (Single __tmp1610)) +(let __tmp1612 (Get __tmp1583 15)) +(let __tmp1613 (Single __tmp1612)) +(let __tmp1614 (Get __tmp1583 16)) +(let __tmp1615 (Single __tmp1614)) +(let __tmp1616 (Get __tmp1583 17)) +(let __tmp1617 (Single __tmp1616)) +(let __tmp1618 (Get __tmp1583 18)) +(let __tmp1619 (Single __tmp1618)) +(let __tmp1620 (Const __tmp361 __tmp1307 __tmp6)) +(let __tmp1621 (Single __tmp1620)) +(let __tmp1622 (Get __tmp1583 19)) +(let __tmp1623 (Single __tmp1622)) +(let __tmp1624 (Get __tmp1583 20)) +(let __tmp1625 (Single __tmp1624)) +(let __tmp1626 (Concat __tmp1623 __tmp1625)) +(let __tmp1627 (Concat __tmp1621 __tmp1626)) +(let __tmp1628 (Concat __tmp1619 __tmp1627)) +(let __tmp1629 (Concat __tmp1617 __tmp1628)) +(let __tmp1630 (Concat __tmp1615 __tmp1629)) +(let __tmp1631 (Concat __tmp1613 __tmp1630)) +(let __tmp1632 (Concat __tmp1611 __tmp1631)) +(let __tmp1633 (Concat __tmp1609 __tmp1632)) +(let __tmp1634 (Concat __tmp1607 __tmp1633)) +(let __tmp1635 (Concat __tmp1605 __tmp1634)) +(let __tmp1636 (Concat __tmp1603 __tmp1635)) +(let __tmp1637 (Concat __tmp1601 __tmp1636)) +(let __tmp1638 (Concat __tmp1599 __tmp1637)) +(let __tmp1639 (Concat __tmp1597 __tmp1638)) +(let __tmp1640 (Concat __tmp1595 __tmp1639)) +(let __tmp1641 (Concat __tmp1594 __tmp1640)) +(let __tmp1642 (Concat __tmp1590 __tmp1641)) +(let __tmp1643 (Concat __tmp1589 __tmp1642)) +(let __tmp1644 (Concat __tmp1585 __tmp1643)) +(let __tmp1645 (Const __tmp379 __tmp1307 __tmp6)) +(let __tmp1646 (Single __tmp1645)) +(let __tmp1647 (Concat __tmp1646 __tmp1348)) +(let __tmp1648 (Concat __tmp1343 __tmp1647)) +(let __tmp1649 (Concat __tmp1341 __tmp1648)) +(let __tmp1650 (Concat __tmp1339 __tmp1649)) +(let __tmp1651 (Concat __tmp1337 __tmp1650)) +(let __tmp1652 (Concat __tmp1335 __tmp1651)) +(let __tmp1653 (Concat __tmp1333 __tmp1652)) +(let __tmp1654 (Concat __tmp1331 __tmp1653)) +(let __tmp1655 (Concat __tmp1329 __tmp1654)) +(let __tmp1656 (Concat __tmp1328 __tmp1655)) +(let __tmp1657 (Concat __tmp1326 __tmp1656)) +(let __tmp1658 (Concat __tmp1324 __tmp1657)) +(let __tmp1659 (Concat __tmp1322 __tmp1658)) +(let __tmp1660 (Concat __tmp1320 __tmp1659)) +(let __tmp1661 (Concat __tmp1318 __tmp1660)) +(let __tmp1662 (Concat __tmp1317 __tmp1661)) +(let __tmp1663 (Concat __tmp1315 __tmp1662)) +(let __tmp1664 (Concat __tmp1313 __tmp1663)) +(let __tmp1665 (If __tmp1311 __tmp1365 __tmp1644 __tmp1664)) +(let __tmp1666 (Get __tmp1665 17)) +(let __tmp1667 (Single __tmp1666)) +(let __tmp1668 (Get __tmp1665 0)) +(let __tmp1669 (Single __tmp1668)) +(let __tmp1670 (Get __tmp1665 1)) +(let __tmp1671 (Single __tmp1670)) +(let __tmp1672 (Get __tmp1665 2)) +(let __tmp1673 (Single __tmp1672)) +(let __tmp1674 (Get __tmp1665 3)) +(let __tmp1675 (Single __tmp1674)) +(let __tmp1676 (Get __tmp1665 4)) +(let __tmp1677 (Single __tmp1676)) +(let __tmp1678 (Get __tmp1665 5)) +(let __tmp1679 (Single __tmp1678)) +(let __tmp1680 (Get __tmp1665 6)) +(let __tmp1681 (Single __tmp1680)) +(let __tmp1682 (Get __tmp1665 7)) +(let __tmp1683 (Single __tmp1682)) +(let __tmp1684 (Get __tmp1665 8)) +(let __tmp1685 (Single __tmp1684)) +(let __tmp1686 (Get __tmp1665 9)) +(let __tmp1687 (Single __tmp1686)) +(let __tmp1688 (Get __tmp1665 10)) +(let __tmp1689 (Single __tmp1688)) +(let __tmp1690 (Get __tmp1665 11)) +(let __tmp1691 (Single __tmp1690)) +(let __tmp1692 (Get __tmp1665 12)) +(let __tmp1693 (Single __tmp1692)) +(let __tmp1694 (Get __tmp1665 13)) +(let __tmp1695 (Single __tmp1694)) +(let __tmp1696 (Get __tmp1665 14)) +(let __tmp1697 (Single __tmp1696)) +(let __tmp1698 (Get __tmp1665 15)) +(let __tmp1699 (Single __tmp1698)) +(let __tmp1700 (Get __tmp1665 16)) +(let __tmp1701 (Single __tmp1700)) +(let __tmp1702 (Get __tmp1665 18)) +(let __tmp1703 (Single __tmp1702)) +(let __tmp1704 (Get __tmp1665 19)) +(let __tmp1705 (Single __tmp1704)) +(let __tmp1706 (Concat __tmp1703 __tmp1705)) +(let __tmp1707 (Concat __tmp1701 __tmp1706)) +(let __tmp1708 (Concat __tmp1699 __tmp1707)) +(let __tmp1709 (Concat __tmp1697 __tmp1708)) +(let __tmp1710 (Concat __tmp1695 __tmp1709)) +(let __tmp1711 (Concat __tmp1693 __tmp1710)) +(let __tmp1712 (Concat __tmp1691 __tmp1711)) +(let __tmp1713 (Concat __tmp1689 __tmp1712)) +(let __tmp1714 (Concat __tmp1687 __tmp1713)) +(let __tmp1715 (Concat __tmp1685 __tmp1714)) +(let __tmp1716 (Concat __tmp1683 __tmp1715)) +(let __tmp1717 (Concat __tmp1681 __tmp1716)) +(let __tmp1718 (Concat __tmp1679 __tmp1717)) +(let __tmp1719 (Concat __tmp1677 __tmp1718)) +(let __tmp1720 (Concat __tmp1675 __tmp1719)) +(let __tmp1721 (Concat __tmp1673 __tmp1720)) +(let __tmp1722 (Concat __tmp1671 __tmp1721)) +(let __tmp1723 (Concat __tmp1669 __tmp1722)) +(let __tmp1724 (Concat __tmp1667 __tmp1723)) +(let __tmp1725 (DoWhile __tmp1288 __tmp1724)) +(let __tmp1726 (Get __tmp1725 0)) +(let __tmp1727 (Single __tmp1726)) +(let __tmp1728 (Get __tmp1725 2)) +(let __tmp1729 (Single __tmp1728)) +(let __tmp1730 (Get __tmp1725 4)) +(let __tmp1731 (Single __tmp1730)) +(let __tmp1732 (Get __tmp1725 5)) +(let __tmp1733 (Single __tmp1732)) +(let __tmp1734 (Get __tmp1725 6)) +(let __tmp1735 (Single __tmp1734)) +(let __tmp1736 (Get __tmp1725 7)) +(let __tmp1737 (Single __tmp1736)) +(let __tmp1738 (Get __tmp1725 8)) +(let __tmp1739 (Single __tmp1738)) +(let __tmp1740 (Get __tmp1725 9)) +(let __tmp1741 (Single __tmp1740)) +(let __tmp1742 (Get __tmp1725 10)) +(let __tmp1743 (Single __tmp1742)) +(let __tmp1744 (Get __tmp1725 11)) +(let __tmp1745 (Single __tmp1744)) +(let __tmp1746 (Get __tmp1725 12)) +(let __tmp1747 (Single __tmp1746)) +(let __tmp1748 (Get __tmp1725 13)) +(let __tmp1749 (Single __tmp1748)) +(let __tmp1750 (Get __tmp1725 14)) +(let __tmp1751 (Single __tmp1750)) +(let __tmp1752 (Get __tmp1725 15)) +(let __tmp1753 (Single __tmp1752)) +(let __tmp1754 (Get __tmp1725 16)) +(let __tmp1755 (Single __tmp1754)) +(let __tmp1756 (Concat __tmp1753 __tmp1755)) +(let __tmp1757 (Concat __tmp1751 __tmp1756)) +(let __tmp1758 (Concat __tmp1749 __tmp1757)) +(let __tmp1759 (Concat __tmp1747 __tmp1758)) +(let __tmp1760 (Concat __tmp1745 __tmp1759)) +(let __tmp1761 (Concat __tmp1743 __tmp1760)) +(let __tmp1762 (Concat __tmp1741 __tmp1761)) +(let __tmp1763 (Concat __tmp1739 __tmp1762)) +(let __tmp1764 (Concat __tmp1737 __tmp1763)) +(let __tmp1765 (Concat __tmp1735 __tmp1764)) +(let __tmp1766 (Concat __tmp1733 __tmp1765)) +(let __tmp1767 (Concat __tmp1731 __tmp1766)) +(let __tmp1768 (Concat __tmp1238 __tmp1767)) +(let __tmp1769 (Concat __tmp1729 __tmp1768)) +(let __tmp1770 (Concat __tmp1233 __tmp1769)) +(let __tmp1771 (Concat __tmp1727 __tmp1770)) +(let __tmp1772 (TCons __tmp115 __tmp1)) +(let __tmp1773 (TCons __tmp113 __tmp1772)) +(let __tmp1774 (TCons __tmp114 __tmp1773)) +(let __tmp1775 (TCons __tmp115 __tmp1774)) +(let __tmp1776 (TCons __tmp113 __tmp1775)) +(let __tmp1777 (TCons __tmp113 __tmp1776)) +(let __tmp1778 (TCons __tmp114 __tmp1777)) +(let __tmp1779 (TCons __tmp115 __tmp1778)) +(let __tmp1780 (TCons __tmp113 __tmp1779)) +(let __tmp1781 (TCons __tmp113 __tmp1780)) +(let __tmp1782 (TCons __tmp115 __tmp1781)) +(let __tmp1783 (TCons __tmp114 __tmp1782)) +(let __tmp1784 (TCons __tmp115 __tmp1783)) +(let __tmp1785 (TCons __tmp115 __tmp1784)) +(let __tmp1786 (TCons __tmp113 __tmp1785)) +(let __tmp1787 (TCons __tmp113 __tmp1786)) +(let __tmp1788 (TCons __tmp0 __tmp1787)) +(let __tmp1789 (TupleT __tmp1788)) +(let __tmp1790 (Arg __tmp1789 __tmp6)) +(let __tmp1791 (Get __tmp1790 3)) +(let __tmp1792 (Get __tmp1790 16)) +(let __tmp1793 (Bop __tmp112 __tmp1791 __tmp1792)) +(let __tmp1794 (Get __tmp1790 0)) +(let __tmp1795 (Single __tmp1794)) +(let __tmp1796 (Get __tmp1790 1)) +(let __tmp1797 (Single __tmp1796)) +(let __tmp1798 (Get __tmp1790 2)) +(let __tmp1799 (Single __tmp1798)) +(let __tmp1800 (Single __tmp1791)) +(let __tmp1801 (Get __tmp1790 4)) +(let __tmp1802 (Single __tmp1801)) +(let __tmp1803 (Get __tmp1790 5)) +(let __tmp1804 (Single __tmp1803)) +(let __tmp1805 (Get __tmp1790 6)) +(let __tmp1806 (Single __tmp1805)) +(let __tmp1807 (Get __tmp1790 7)) +(let __tmp1808 (Single __tmp1807)) +(let __tmp1809 (Get __tmp1790 8)) +(let __tmp1810 (Single __tmp1809)) +(let __tmp1811 (Get __tmp1790 9)) +(let __tmp1812 (Single __tmp1811)) +(let __tmp1813 (Get __tmp1790 10)) +(let __tmp1814 (Single __tmp1813)) +(let __tmp1815 (Get __tmp1790 11)) +(let __tmp1816 (Single __tmp1815)) +(let __tmp1817 (Get __tmp1790 12)) +(let __tmp1818 (Single __tmp1817)) +(let __tmp1819 (Get __tmp1790 13)) +(let __tmp1820 (Single __tmp1819)) +(let __tmp1821 (Get __tmp1790 14)) +(let __tmp1822 (Single __tmp1821)) +(let __tmp1823 (Get __tmp1790 15)) +(let __tmp1824 (Single __tmp1823)) +(let __tmp1825 (Single __tmp1792)) +(let __tmp1826 (Concat __tmp1824 __tmp1825)) +(let __tmp1827 (Concat __tmp1822 __tmp1826)) +(let __tmp1828 (Concat __tmp1820 __tmp1827)) +(let __tmp1829 (Concat __tmp1818 __tmp1828)) +(let __tmp1830 (Concat __tmp1816 __tmp1829)) +(let __tmp1831 (Concat __tmp1814 __tmp1830)) +(let __tmp1832 (Concat __tmp1812 __tmp1831)) +(let __tmp1833 (Concat __tmp1810 __tmp1832)) +(let __tmp1834 (Concat __tmp1808 __tmp1833)) +(let __tmp1835 (Concat __tmp1806 __tmp1834)) +(let __tmp1836 (Concat __tmp1804 __tmp1835)) +(let __tmp1837 (Concat __tmp1802 __tmp1836)) +(let __tmp1838 (Concat __tmp1800 __tmp1837)) +(let __tmp1839 (Concat __tmp1799 __tmp1838)) +(let __tmp1840 (Concat __tmp1797 __tmp1839)) +(let __tmp1841 (Concat __tmp1795 __tmp1840)) +(let __tmp1842 (Const __tmp95 __tmp1789 __tmp6)) +(let __tmp1843 (Single __tmp1842)) +(let __tmp1844 (Const __tmp83 __tmp1789 __tmp6)) +(let __tmp1845 (Single __tmp1844)) +(let __tmp1846 (Concat __tmp1845 __tmp1836)) +(let __tmp1847 (Concat __tmp1843 __tmp1846)) +(let __tmp1848 (Concat __tmp1802 __tmp1847)) +(let __tmp1849 (Concat __tmp1800 __tmp1848)) +(let __tmp1850 (Concat __tmp1799 __tmp1849)) +(let __tmp1851 (Concat __tmp1797 __tmp1850)) +(let __tmp1852 (Concat __tmp1795 __tmp1851)) +(let __tmp1853 (TCons __tmp113 __tmp1784)) +(let __tmp1854 (TCons __tmp115 __tmp1853)) +(let __tmp1855 (TCons __tmp115 __tmp1854)) +(let __tmp1856 (TCons __tmp113 __tmp1855)) +(let __tmp1857 (TCons __tmp113 __tmp1856)) +(let __tmp1858 (TCons __tmp0 __tmp1857)) +(let __tmp1859 (TupleT __tmp1858)) +(let __tmp1860 (Arg __tmp1859 __tmp6)) +(let __tmp1861 (Get __tmp1860 6)) +(let __tmp1862 (Get __tmp1860 15)) +(let __tmp1863 (Bop __tmp112 __tmp1861 __tmp1862)) +(let __tmp1864 (Get __tmp1860 0)) +(let __tmp1865 (Single __tmp1864)) +(let __tmp1866 (Get __tmp1860 1)) +(let __tmp1867 (Single __tmp1866)) +(let __tmp1868 (Get __tmp1860 2)) +(let __tmp1869 (Single __tmp1868)) +(let __tmp1870 (Get __tmp1860 3)) +(let __tmp1871 (Single __tmp1870)) +(let __tmp1872 (Get __tmp1860 4)) +(let __tmp1873 (Single __tmp1872)) +(let __tmp1874 (Get __tmp1860 5)) +(let __tmp1875 (Single __tmp1874)) +(let __tmp1876 (Single __tmp1861)) +(let __tmp1877 (Get __tmp1860 7)) +(let __tmp1878 (Single __tmp1877)) +(let __tmp1879 (Get __tmp1860 8)) +(let __tmp1880 (Single __tmp1879)) +(let __tmp1881 (Get __tmp1860 9)) +(let __tmp1882 (Single __tmp1881)) +(let __tmp1883 (Get __tmp1860 10)) +(let __tmp1884 (Single __tmp1883)) +(let __tmp1885 (Get __tmp1860 11)) +(let __tmp1886 (Single __tmp1885)) +(let __tmp1887 (Get __tmp1860 12)) +(let __tmp1888 (Single __tmp1887)) +(let __tmp1889 (Get __tmp1860 13)) +(let __tmp1890 (Single __tmp1889)) +(let __tmp1891 (Get __tmp1860 14)) +(let __tmp1892 (Single __tmp1891)) +(let __tmp1893 (Single __tmp1862)) +(let __tmp1894 (Get __tmp1860 16)) +(let __tmp1895 (Single __tmp1894)) +(let __tmp1896 (Get __tmp1860 17)) +(let __tmp1897 (Single __tmp1896)) +(let __tmp1898 (Get __tmp1860 18)) +(let __tmp1899 (Single __tmp1898)) +(let __tmp1900 (Concat __tmp1897 __tmp1899)) +(let __tmp1901 (Concat __tmp1895 __tmp1900)) +(let __tmp1902 (Concat __tmp1893 __tmp1901)) +(let __tmp1903 (Concat __tmp1892 __tmp1902)) +(let __tmp1904 (Concat __tmp1890 __tmp1903)) +(let __tmp1905 (Concat __tmp1888 __tmp1904)) +(let __tmp1906 (Concat __tmp1886 __tmp1905)) +(let __tmp1907 (Concat __tmp1884 __tmp1906)) +(let __tmp1908 (Concat __tmp1882 __tmp1907)) +(let __tmp1909 (Concat __tmp1880 __tmp1908)) +(let __tmp1910 (Concat __tmp1878 __tmp1909)) +(let __tmp1911 (Concat __tmp1876 __tmp1910)) +(let __tmp1912 (Concat __tmp1875 __tmp1911)) +(let __tmp1913 (Concat __tmp1873 __tmp1912)) +(let __tmp1914 (Concat __tmp1871 __tmp1913)) +(let __tmp1915 (Concat __tmp1869 __tmp1914)) +(let __tmp1916 (Concat __tmp1867 __tmp1915)) +(let __tmp1917 (Concat __tmp1865 __tmp1916)) +(let __tmp1918 (Bop __tmp1449 __tmp1874 __tmp1868)) +(let __tmp1919 (Bop __tmp330 __tmp1866 __tmp1918)) +(let __tmp1920 (Single __tmp1919)) +(let __tmp1921 (Concat __tmp1897 __tmp1865)) +(let __tmp1922 (Concat __tmp1920 __tmp1921)) +(let __tmp1923 (Call "fmod" __tmp1922)) +(let __tmp1924 (Get __tmp1923 0)) +(let __tmp1925 (Bop __tmp1448 __tmp1924 __tmp1896)) +(let __tmp1926 (Single __tmp1925)) +(let __tmp1927 (Get __tmp1923 1)) +(let __tmp1928 (Single __tmp1927)) +(let __tmp1929 (Concat __tmp1926 __tmp1928)) +(let __tmp1930 (Concat __tmp1893 __tmp1929)) +(let __tmp1931 (Concat __tmp1876 __tmp1930)) +(let __tmp1932 (Concat __tmp1871 __tmp1931)) +(let __tmp1933 (Concat __tmp1895 __tmp1932)) +(let __tmp1934 (Call "matrix_set" __tmp1933)) +(let __tmp1935 (Get __tmp1934 0)) +(let __tmp1936 (Single __tmp1935)) +(let __tmp1937 (Single __tmp1918)) +(let __tmp1938 (Bop __tmp358 __tmp1861 __tmp1872)) +(let __tmp1939 (Single __tmp1938)) +(let __tmp1940 (Const __tmp361 __tmp1859 __tmp6)) +(let __tmp1941 (Single __tmp1940)) +(let __tmp1942 (Concat __tmp1941 __tmp1901)) +(let __tmp1943 (Concat __tmp1893 __tmp1942)) +(let __tmp1944 (Concat __tmp1892 __tmp1943)) +(let __tmp1945 (Concat __tmp1890 __tmp1944)) +(let __tmp1946 (Concat __tmp1888 __tmp1945)) +(let __tmp1947 (Concat __tmp1886 __tmp1946)) +(let __tmp1948 (Concat __tmp1884 __tmp1947)) +(let __tmp1949 (Concat __tmp1882 __tmp1948)) +(let __tmp1950 (Concat __tmp1880 __tmp1949)) +(let __tmp1951 (Concat __tmp1878 __tmp1950)) +(let __tmp1952 (Concat __tmp1939 __tmp1951)) +(let __tmp1953 (Concat __tmp1937 __tmp1952)) +(let __tmp1954 (Concat __tmp1873 __tmp1953)) +(let __tmp1955 (Concat __tmp1871 __tmp1954)) +(let __tmp1956 (Concat __tmp1869 __tmp1955)) +(let __tmp1957 (Concat __tmp1867 __tmp1956)) +(let __tmp1958 (Concat __tmp1936 __tmp1957)) +(let __tmp1959 (Const __tmp379 __tmp1859 __tmp6)) +(let __tmp1960 (Single __tmp1959)) +(let __tmp1961 (Concat __tmp1960 __tmp1901)) +(let __tmp1962 (Concat __tmp1893 __tmp1961)) +(let __tmp1963 (Concat __tmp1892 __tmp1962)) +(let __tmp1964 (Concat __tmp1890 __tmp1963)) +(let __tmp1965 (Concat __tmp1888 __tmp1964)) +(let __tmp1966 (Concat __tmp1886 __tmp1965)) +(let __tmp1967 (Concat __tmp1884 __tmp1966)) +(let __tmp1968 (Concat __tmp1882 __tmp1967)) +(let __tmp1969 (Concat __tmp1880 __tmp1968)) +(let __tmp1970 (Concat __tmp1878 __tmp1969)) +(let __tmp1971 (Concat __tmp1876 __tmp1970)) +(let __tmp1972 (Concat __tmp1875 __tmp1971)) +(let __tmp1973 (Concat __tmp1873 __tmp1972)) +(let __tmp1974 (Concat __tmp1871 __tmp1973)) +(let __tmp1975 (Concat __tmp1869 __tmp1974)) +(let __tmp1976 (Concat __tmp1867 __tmp1975)) +(let __tmp1977 (Concat __tmp1865 __tmp1976)) +(let __tmp1978 (If __tmp1863 __tmp1917 __tmp1958 __tmp1977)) +(let __tmp1979 (Get __tmp1978 16)) +(let __tmp1980 (Single __tmp1979)) +(let __tmp1981 (Get __tmp1978 0)) +(let __tmp1982 (Single __tmp1981)) +(let __tmp1983 (Get __tmp1978 1)) +(let __tmp1984 (Single __tmp1983)) +(let __tmp1985 (Get __tmp1978 2)) +(let __tmp1986 (Single __tmp1985)) +(let __tmp1987 (Get __tmp1978 3)) +(let __tmp1988 (Single __tmp1987)) +(let __tmp1989 (Get __tmp1978 4)) +(let __tmp1990 (Single __tmp1989)) +(let __tmp1991 (Get __tmp1978 5)) +(let __tmp1992 (Single __tmp1991)) +(let __tmp1993 (Get __tmp1978 6)) +(let __tmp1994 (Single __tmp1993)) +(let __tmp1995 (Get __tmp1978 7)) +(let __tmp1996 (Single __tmp1995)) +(let __tmp1997 (Get __tmp1978 8)) +(let __tmp1998 (Single __tmp1997)) +(let __tmp1999 (Get __tmp1978 9)) +(let __tmp2000 (Single __tmp1999)) +(let __tmp2001 (Get __tmp1978 10)) +(let __tmp2002 (Single __tmp2001)) +(let __tmp2003 (Get __tmp1978 11)) +(let __tmp2004 (Single __tmp2003)) +(let __tmp2005 (Get __tmp1978 12)) +(let __tmp2006 (Single __tmp2005)) +(let __tmp2007 (Get __tmp1978 13)) +(let __tmp2008 (Single __tmp2007)) +(let __tmp2009 (Get __tmp1978 14)) +(let __tmp2010 (Single __tmp2009)) +(let __tmp2011 (Get __tmp1978 15)) +(let __tmp2012 (Single __tmp2011)) +(let __tmp2013 (Get __tmp1978 17)) +(let __tmp2014 (Single __tmp2013)) +(let __tmp2015 (Get __tmp1978 18)) +(let __tmp2016 (Single __tmp2015)) +(let __tmp2017 (Get __tmp1978 19)) +(let __tmp2018 (Single __tmp2017)) +(let __tmp2019 (Concat __tmp2016 __tmp2018)) +(let __tmp2020 (Concat __tmp2014 __tmp2019)) +(let __tmp2021 (Concat __tmp2012 __tmp2020)) +(let __tmp2022 (Concat __tmp2010 __tmp2021)) +(let __tmp2023 (Concat __tmp2008 __tmp2022)) +(let __tmp2024 (Concat __tmp2006 __tmp2023)) +(let __tmp2025 (Concat __tmp2004 __tmp2024)) +(let __tmp2026 (Concat __tmp2002 __tmp2025)) +(let __tmp2027 (Concat __tmp2000 __tmp2026)) +(let __tmp2028 (Concat __tmp1998 __tmp2027)) +(let __tmp2029 (Concat __tmp1996 __tmp2028)) +(let __tmp2030 (Concat __tmp1994 __tmp2029)) +(let __tmp2031 (Concat __tmp1992 __tmp2030)) +(let __tmp2032 (Concat __tmp1990 __tmp2031)) +(let __tmp2033 (Concat __tmp1988 __tmp2032)) +(let __tmp2034 (Concat __tmp1986 __tmp2033)) +(let __tmp2035 (Concat __tmp1984 __tmp2034)) +(let __tmp2036 (Concat __tmp1982 __tmp2035)) +(let __tmp2037 (Concat __tmp1980 __tmp2036)) +(let __tmp2038 (DoWhile __tmp1852 __tmp2037)) +(let __tmp2039 (Get __tmp2038 0)) +(let __tmp2040 (Single __tmp2039)) +(let __tmp2041 (Get __tmp2038 1)) +(let __tmp2042 (Get __tmp2038 2)) +(let __tmp2043 (Bop __tmp1449 __tmp2041 __tmp2042)) +(let __tmp2044 (Single __tmp2043)) +(let __tmp2045 (Single __tmp2042)) +(let __tmp2046 (Get __tmp2038 3)) +(let __tmp2047 (Get __tmp2038 4)) +(let __tmp2048 (Bop __tmp358 __tmp2046 __tmp2047)) +(let __tmp2049 (Single __tmp2048)) +(let __tmp2050 (Single __tmp2047)) +(let __tmp2051 (Get __tmp2038 7)) +(let __tmp2052 (Single __tmp2051)) +(let __tmp2053 (Get __tmp2038 8)) +(let __tmp2054 (Single __tmp2053)) +(let __tmp2055 (Get __tmp2038 9)) +(let __tmp2056 (Single __tmp2055)) +(let __tmp2057 (Get __tmp2038 10)) +(let __tmp2058 (Single __tmp2057)) +(let __tmp2059 (Get __tmp2038 11)) +(let __tmp2060 (Single __tmp2059)) +(let __tmp2061 (Get __tmp2038 12)) +(let __tmp2062 (Single __tmp2061)) +(let __tmp2063 (Get __tmp2038 13)) +(let __tmp2064 (Single __tmp2063)) +(let __tmp2065 (Get __tmp2038 14)) +(let __tmp2066 (Single __tmp2065)) +(let __tmp2067 (Get __tmp2038 15)) +(let __tmp2068 (Single __tmp2067)) +(let __tmp2069 (Const __tmp361 __tmp1789 __tmp6)) +(let __tmp2070 (Single __tmp2069)) +(let __tmp2071 (Get __tmp2038 16)) +(let __tmp2072 (Single __tmp2071)) +(let __tmp2073 (Get __tmp2038 17)) +(let __tmp2074 (Single __tmp2073)) +(let __tmp2075 (Get __tmp2038 18)) +(let __tmp2076 (Single __tmp2075)) +(let __tmp2077 (Concat __tmp2074 __tmp2076)) +(let __tmp2078 (Concat __tmp2072 __tmp2077)) +(let __tmp2079 (Concat __tmp2070 __tmp2078)) +(let __tmp2080 (Concat __tmp2068 __tmp2079)) +(let __tmp2081 (Concat __tmp2066 __tmp2080)) +(let __tmp2082 (Concat __tmp2064 __tmp2081)) +(let __tmp2083 (Concat __tmp2062 __tmp2082)) +(let __tmp2084 (Concat __tmp2060 __tmp2083)) +(let __tmp2085 (Concat __tmp2058 __tmp2084)) +(let __tmp2086 (Concat __tmp2056 __tmp2085)) +(let __tmp2087 (Concat __tmp2054 __tmp2086)) +(let __tmp2088 (Concat __tmp2052 __tmp2087)) +(let __tmp2089 (Concat __tmp2050 __tmp2088)) +(let __tmp2090 (Concat __tmp2049 __tmp2089)) +(let __tmp2091 (Concat __tmp2045 __tmp2090)) +(let __tmp2092 (Concat __tmp2044 __tmp2091)) +(let __tmp2093 (Concat __tmp2040 __tmp2092)) +(let __tmp2094 (Const __tmp379 __tmp1789 __tmp6)) +(let __tmp2095 (Single __tmp2094)) +(let __tmp2096 (Concat __tmp2095 __tmp1827)) +(let __tmp2097 (Concat __tmp1820 __tmp2096)) +(let __tmp2098 (Concat __tmp1818 __tmp2097)) +(let __tmp2099 (Concat __tmp1816 __tmp2098)) +(let __tmp2100 (Concat __tmp1814 __tmp2099)) +(let __tmp2101 (Concat __tmp1812 __tmp2100)) +(let __tmp2102 (Concat __tmp1810 __tmp2101)) +(let __tmp2103 (Concat __tmp1808 __tmp2102)) +(let __tmp2104 (Concat __tmp1806 __tmp2103)) +(let __tmp2105 (Concat __tmp1804 __tmp2104)) +(let __tmp2106 (Concat __tmp1802 __tmp2105)) +(let __tmp2107 (Concat __tmp1800 __tmp2106)) +(let __tmp2108 (Concat __tmp1799 __tmp2107)) +(let __tmp2109 (Concat __tmp1797 __tmp2108)) +(let __tmp2110 (Concat __tmp1795 __tmp2109)) +(let __tmp2111 (If __tmp1793 __tmp1841 __tmp2093 __tmp2110)) +(let __tmp2112 (Get __tmp2111 14)) +(let __tmp2113 (Single __tmp2112)) +(let __tmp2114 (Get __tmp2111 0)) +(let __tmp2115 (Single __tmp2114)) +(let __tmp2116 (Get __tmp2111 1)) +(let __tmp2117 (Single __tmp2116)) +(let __tmp2118 (Get __tmp2111 2)) +(let __tmp2119 (Single __tmp2118)) +(let __tmp2120 (Get __tmp2111 3)) +(let __tmp2121 (Single __tmp2120)) +(let __tmp2122 (Get __tmp2111 4)) +(let __tmp2123 (Single __tmp2122)) +(let __tmp2124 (Get __tmp2111 5)) +(let __tmp2125 (Single __tmp2124)) +(let __tmp2126 (Get __tmp2111 6)) +(let __tmp2127 (Single __tmp2126)) +(let __tmp2128 (Get __tmp2111 7)) +(let __tmp2129 (Single __tmp2128)) +(let __tmp2130 (Get __tmp2111 8)) +(let __tmp2131 (Single __tmp2130)) +(let __tmp2132 (Get __tmp2111 9)) +(let __tmp2133 (Single __tmp2132)) +(let __tmp2134 (Get __tmp2111 10)) +(let __tmp2135 (Single __tmp2134)) +(let __tmp2136 (Get __tmp2111 11)) +(let __tmp2137 (Single __tmp2136)) +(let __tmp2138 (Get __tmp2111 12)) +(let __tmp2139 (Single __tmp2138)) +(let __tmp2140 (Get __tmp2111 13)) +(let __tmp2141 (Single __tmp2140)) +(let __tmp2142 (Get __tmp2111 15)) +(let __tmp2143 (Single __tmp2142)) +(let __tmp2144 (Get __tmp2111 16)) +(let __tmp2145 (Single __tmp2144)) +(let __tmp2146 (Get __tmp2111 17)) +(let __tmp2147 (Single __tmp2146)) +(let __tmp2148 (Concat __tmp2145 __tmp2147)) +(let __tmp2149 (Concat __tmp2143 __tmp2148)) +(let __tmp2150 (Concat __tmp2141 __tmp2149)) +(let __tmp2151 (Concat __tmp2139 __tmp2150)) +(let __tmp2152 (Concat __tmp2137 __tmp2151)) +(let __tmp2153 (Concat __tmp2135 __tmp2152)) +(let __tmp2154 (Concat __tmp2133 __tmp2153)) +(let __tmp2155 (Concat __tmp2131 __tmp2154)) +(let __tmp2156 (Concat __tmp2129 __tmp2155)) +(let __tmp2157 (Concat __tmp2127 __tmp2156)) +(let __tmp2158 (Concat __tmp2125 __tmp2157)) +(let __tmp2159 (Concat __tmp2123 __tmp2158)) +(let __tmp2160 (Concat __tmp2121 __tmp2159)) +(let __tmp2161 (Concat __tmp2119 __tmp2160)) +(let __tmp2162 (Concat __tmp2117 __tmp2161)) +(let __tmp2163 (Concat __tmp2115 __tmp2162)) +(let __tmp2164 (Concat __tmp2113 __tmp2163)) +(let __tmp2165 (DoWhile __tmp1771 __tmp2164)) +(let __tmp2166 (Get __tmp2165 0)) +(let __tmp2167 (Single __tmp2166)) +(let __tmp2168 (Get __tmp2165 2)) +(let __tmp2169 (Single __tmp2168)) +(let __tmp2170 (Get __tmp2165 4)) +(let __tmp2171 (Single __tmp2170)) +(let __tmp2172 (Get __tmp2165 5)) +(let __tmp2173 (Single __tmp2172)) +(let __tmp2174 (Get __tmp2165 6)) +(let __tmp2175 (Single __tmp2174)) +(let __tmp2176 (Get __tmp2165 7)) +(let __tmp2177 (Single __tmp2176)) +(let __tmp2178 (Get __tmp2165 8)) +(let __tmp2179 (Single __tmp2178)) +(let __tmp2180 (Get __tmp2165 9)) +(let __tmp2181 (Single __tmp2180)) +(let __tmp2182 (Get __tmp2165 10)) +(let __tmp2183 (Single __tmp2182)) +(let __tmp2184 (Get __tmp2165 11)) +(let __tmp2185 (Single __tmp2184)) +(let __tmp2186 (Get __tmp2165 12)) +(let __tmp2187 (Single __tmp2186)) +(let __tmp2188 (Get __tmp2165 13)) +(let __tmp2189 (Single __tmp2188)) +(let __tmp2190 (Concat __tmp2187 __tmp2189)) +(let __tmp2191 (Concat __tmp2185 __tmp2190)) +(let __tmp2192 (Concat __tmp2183 __tmp2191)) +(let __tmp2193 (Concat __tmp2181 __tmp2192)) +(let __tmp2194 (Concat __tmp2179 __tmp2193)) +(let __tmp2195 (Concat __tmp2177 __tmp2194)) +(let __tmp2196 (Concat __tmp2175 __tmp2195)) +(let __tmp2197 (Concat __tmp2173 __tmp2196)) +(let __tmp2198 (Concat __tmp2171 __tmp2197)) +(let __tmp2199 (Concat __tmp1238 __tmp2198)) +(let __tmp2200 (Concat __tmp2169 __tmp2199)) +(let __tmp2201 (Concat __tmp1233 __tmp2200)) +(let __tmp2202 (Concat __tmp2167 __tmp2201)) +(let __tmp2203 (TCons __tmp113 __tmp1773)) +(let __tmp2204 (TCons __tmp114 __tmp2203)) +(let __tmp2205 (TCons __tmp115 __tmp2204)) +(let __tmp2206 (TCons __tmp113 __tmp2205)) +(let __tmp2207 (TCons __tmp113 __tmp2206)) +(let __tmp2208 (TCons __tmp115 __tmp2207)) +(let __tmp2209 (TCons __tmp114 __tmp2208)) +(let __tmp2210 (TCons __tmp115 __tmp2209)) +(let __tmp2211 (TCons __tmp115 __tmp2210)) +(let __tmp2212 (TCons __tmp113 __tmp2211)) +(let __tmp2213 (TCons __tmp113 __tmp2212)) +(let __tmp2214 (TCons __tmp0 __tmp2213)) +(let __tmp2215 (TupleT __tmp2214)) +(let __tmp2216 (Arg __tmp2215 __tmp6)) +(let __tmp2217 (Get __tmp2216 3)) +(let __tmp2218 (Get __tmp2216 13)) +(let __tmp2219 (Bop __tmp112 __tmp2217 __tmp2218)) +(let __tmp2220 (Get __tmp2216 0)) +(let __tmp2221 (Single __tmp2220)) +(let __tmp2222 (Get __tmp2216 1)) +(let __tmp2223 (Single __tmp2222)) +(let __tmp2224 (Get __tmp2216 2)) +(let __tmp2225 (Single __tmp2224)) +(let __tmp2226 (Single __tmp2217)) +(let __tmp2227 (Get __tmp2216 4)) +(let __tmp2228 (Single __tmp2227)) +(let __tmp2229 (Get __tmp2216 5)) +(let __tmp2230 (Single __tmp2229)) +(let __tmp2231 (Get __tmp2216 6)) +(let __tmp2232 (Single __tmp2231)) +(let __tmp2233 (Get __tmp2216 7)) +(let __tmp2234 (Single __tmp2233)) +(let __tmp2235 (Get __tmp2216 8)) +(let __tmp2236 (Single __tmp2235)) +(let __tmp2237 (Get __tmp2216 9)) +(let __tmp2238 (Single __tmp2237)) +(let __tmp2239 (Get __tmp2216 10)) +(let __tmp2240 (Single __tmp2239)) +(let __tmp2241 (Get __tmp2216 11)) +(let __tmp2242 (Single __tmp2241)) +(let __tmp2243 (Get __tmp2216 12)) +(let __tmp2244 (Single __tmp2243)) +(let __tmp2245 (Single __tmp2218)) +(let __tmp2246 (Concat __tmp2244 __tmp2245)) +(let __tmp2247 (Concat __tmp2242 __tmp2246)) +(let __tmp2248 (Concat __tmp2240 __tmp2247)) +(let __tmp2249 (Concat __tmp2238 __tmp2248)) +(let __tmp2250 (Concat __tmp2236 __tmp2249)) +(let __tmp2251 (Concat __tmp2234 __tmp2250)) +(let __tmp2252 (Concat __tmp2232 __tmp2251)) +(let __tmp2253 (Concat __tmp2230 __tmp2252)) +(let __tmp2254 (Concat __tmp2228 __tmp2253)) +(let __tmp2255 (Concat __tmp2226 __tmp2254)) +(let __tmp2256 (Concat __tmp2225 __tmp2255)) +(let __tmp2257 (Concat __tmp2223 __tmp2256)) +(let __tmp2258 (Concat __tmp2221 __tmp2257)) +(let __tmp2259 (Const __tmp95 __tmp2215 __tmp6)) +(let __tmp2260 (Single __tmp2259)) +(let __tmp2261 (Const __tmp83 __tmp2215 __tmp6)) +(let __tmp2262 (Single __tmp2261)) +(let __tmp2263 (Concat __tmp2262 __tmp2253)) +(let __tmp2264 (Concat __tmp2260 __tmp2263)) +(let __tmp2265 (Concat __tmp2228 __tmp2264)) +(let __tmp2266 (Concat __tmp2226 __tmp2265)) +(let __tmp2267 (Concat __tmp2225 __tmp2266)) +(let __tmp2268 (Concat __tmp2223 __tmp2267)) +(let __tmp2269 (Concat __tmp2221 __tmp2268)) +(let __tmp2270 (TCons __tmp113 __tmp2210)) +(let __tmp2271 (TCons __tmp115 __tmp2270)) +(let __tmp2272 (TCons __tmp115 __tmp2271)) +(let __tmp2273 (TCons __tmp113 __tmp2272)) +(let __tmp2274 (TCons __tmp113 __tmp2273)) +(let __tmp2275 (TCons __tmp0 __tmp2274)) +(let __tmp2276 (TupleT __tmp2275)) +(let __tmp2277 (Arg __tmp2276 __tmp6)) +(let __tmp2278 (Get __tmp2277 6)) +(let __tmp2279 (Get __tmp2277 8)) +(let __tmp2280 (Bop __tmp112 __tmp2278 __tmp2279)) +(let __tmp2281 (Get __tmp2277 0)) +(let __tmp2282 (Single __tmp2281)) +(let __tmp2283 (Get __tmp2277 1)) +(let __tmp2284 (Single __tmp2283)) +(let __tmp2285 (Get __tmp2277 2)) +(let __tmp2286 (Single __tmp2285)) +(let __tmp2287 (Get __tmp2277 3)) +(let __tmp2288 (Single __tmp2287)) +(let __tmp2289 (Get __tmp2277 4)) +(let __tmp2290 (Single __tmp2289)) +(let __tmp2291 (Get __tmp2277 5)) +(let __tmp2292 (Single __tmp2291)) +(let __tmp2293 (Single __tmp2278)) +(let __tmp2294 (Get __tmp2277 7)) +(let __tmp2295 (Single __tmp2294)) +(let __tmp2296 (Single __tmp2279)) +(let __tmp2297 (Get __tmp2277 9)) +(let __tmp2298 (Single __tmp2297)) +(let __tmp2299 (Get __tmp2277 10)) +(let __tmp2300 (Single __tmp2299)) +(let __tmp2301 (Get __tmp2277 11)) +(let __tmp2302 (Single __tmp2301)) +(let __tmp2303 (Get __tmp2277 12)) +(let __tmp2304 (Single __tmp2303)) +(let __tmp2305 (Get __tmp2277 13)) +(let __tmp2306 (Single __tmp2305)) +(let __tmp2307 (Get __tmp2277 14)) +(let __tmp2308 (Single __tmp2307)) +(let __tmp2309 (Get __tmp2277 15)) +(let __tmp2310 (Single __tmp2309)) +(let __tmp2311 (Concat __tmp2308 __tmp2310)) +(let __tmp2312 (Concat __tmp2306 __tmp2311)) +(let __tmp2313 (Concat __tmp2304 __tmp2312)) +(let __tmp2314 (Concat __tmp2302 __tmp2313)) +(let __tmp2315 (Concat __tmp2300 __tmp2314)) +(let __tmp2316 (Concat __tmp2298 __tmp2315)) +(let __tmp2317 (Concat __tmp2296 __tmp2316)) +(let __tmp2318 (Concat __tmp2295 __tmp2317)) +(let __tmp2319 (Concat __tmp2293 __tmp2318)) +(let __tmp2320 (Concat __tmp2292 __tmp2319)) +(let __tmp2321 (Concat __tmp2290 __tmp2320)) +(let __tmp2322 (Concat __tmp2288 __tmp2321)) +(let __tmp2323 (Concat __tmp2286 __tmp2322)) +(let __tmp2324 (Concat __tmp2284 __tmp2323)) +(let __tmp2325 (Concat __tmp2282 __tmp2324)) +(let __tmp2326 (Bop __tmp1449 __tmp2291 __tmp2307)) +(let __tmp2327 (Bop __tmp330 __tmp2283 __tmp2326)) +(let __tmp2328 (Bop __tmp1449 __tmp2327 __tmp2285)) +(let __tmp2329 (Single __tmp2328)) +(let __tmp2330 (Concat __tmp2306 __tmp2282)) +(let __tmp2331 (Concat __tmp2329 __tmp2330)) +(let __tmp2332 (Call "fmod" __tmp2331)) +(let __tmp2333 (Get __tmp2332 0)) +(let __tmp2334 (Bop __tmp1448 __tmp2333 __tmp2305)) +(let __tmp2335 (Single __tmp2334)) +(let __tmp2336 (Get __tmp2332 1)) +(let __tmp2337 (Single __tmp2336)) +(let __tmp2338 (Concat __tmp2335 __tmp2337)) +(let __tmp2339 (Concat __tmp2296 __tmp2338)) +(let __tmp2340 (Concat __tmp2293 __tmp2339)) +(let __tmp2341 (Concat __tmp2288 __tmp2340)) +(let __tmp2342 (Concat __tmp2304 __tmp2341)) +(let __tmp2343 (Call "matrix_set" __tmp2342)) +(let __tmp2344 (Get __tmp2343 0)) +(let __tmp2345 (Single __tmp2344)) +(let __tmp2346 (Bop __tmp1449 __tmp2291 __tmp2285)) +(let __tmp2347 (Single __tmp2346)) +(let __tmp2348 (Bop __tmp358 __tmp2278 __tmp2289)) +(let __tmp2349 (Single __tmp2348)) +(let __tmp2350 (Const __tmp361 __tmp2276 __tmp6)) +(let __tmp2351 (Single __tmp2350)) +(let __tmp2352 (Concat __tmp2351 __tmp2313)) +(let __tmp2353 (Concat __tmp2302 __tmp2352)) +(let __tmp2354 (Concat __tmp2300 __tmp2353)) +(let __tmp2355 (Concat __tmp2298 __tmp2354)) +(let __tmp2356 (Concat __tmp2296 __tmp2355)) +(let __tmp2357 (Concat __tmp2295 __tmp2356)) +(let __tmp2358 (Concat __tmp2349 __tmp2357)) +(let __tmp2359 (Concat __tmp2347 __tmp2358)) +(let __tmp2360 (Concat __tmp2290 __tmp2359)) +(let __tmp2361 (Concat __tmp2288 __tmp2360)) +(let __tmp2362 (Concat __tmp2286 __tmp2361)) +(let __tmp2363 (Concat __tmp2284 __tmp2362)) +(let __tmp2364 (Concat __tmp2345 __tmp2363)) +(let __tmp2365 (Const __tmp379 __tmp2276 __tmp6)) +(let __tmp2366 (Single __tmp2365)) +(let __tmp2367 (Concat __tmp2366 __tmp2313)) +(let __tmp2368 (Concat __tmp2302 __tmp2367)) +(let __tmp2369 (Concat __tmp2300 __tmp2368)) +(let __tmp2370 (Concat __tmp2298 __tmp2369)) +(let __tmp2371 (Concat __tmp2296 __tmp2370)) +(let __tmp2372 (Concat __tmp2295 __tmp2371)) +(let __tmp2373 (Concat __tmp2293 __tmp2372)) +(let __tmp2374 (Concat __tmp2292 __tmp2373)) +(let __tmp2375 (Concat __tmp2290 __tmp2374)) +(let __tmp2376 (Concat __tmp2288 __tmp2375)) +(let __tmp2377 (Concat __tmp2286 __tmp2376)) +(let __tmp2378 (Concat __tmp2284 __tmp2377)) +(let __tmp2379 (Concat __tmp2282 __tmp2378)) +(let __tmp2380 (If __tmp2280 __tmp2325 __tmp2364 __tmp2379)) +(let __tmp2381 (Get __tmp2380 12)) +(let __tmp2382 (Single __tmp2381)) +(let __tmp2383 (Get __tmp2380 0)) +(let __tmp2384 (Single __tmp2383)) +(let __tmp2385 (Get __tmp2380 1)) +(let __tmp2386 (Single __tmp2385)) +(let __tmp2387 (Get __tmp2380 2)) +(let __tmp2388 (Single __tmp2387)) +(let __tmp2389 (Get __tmp2380 3)) +(let __tmp2390 (Single __tmp2389)) +(let __tmp2391 (Get __tmp2380 4)) +(let __tmp2392 (Single __tmp2391)) +(let __tmp2393 (Get __tmp2380 5)) +(let __tmp2394 (Single __tmp2393)) +(let __tmp2395 (Get __tmp2380 6)) +(let __tmp2396 (Single __tmp2395)) +(let __tmp2397 (Get __tmp2380 7)) +(let __tmp2398 (Single __tmp2397)) +(let __tmp2399 (Get __tmp2380 8)) +(let __tmp2400 (Single __tmp2399)) +(let __tmp2401 (Get __tmp2380 9)) +(let __tmp2402 (Single __tmp2401)) +(let __tmp2403 (Get __tmp2380 10)) +(let __tmp2404 (Single __tmp2403)) +(let __tmp2405 (Get __tmp2380 11)) +(let __tmp2406 (Single __tmp2405)) +(let __tmp2407 (Get __tmp2380 13)) +(let __tmp2408 (Single __tmp2407)) +(let __tmp2409 (Get __tmp2380 14)) +(let __tmp2410 (Single __tmp2409)) +(let __tmp2411 (Get __tmp2380 15)) +(let __tmp2412 (Single __tmp2411)) +(let __tmp2413 (Get __tmp2380 16)) +(let __tmp2414 (Single __tmp2413)) +(let __tmp2415 (Concat __tmp2412 __tmp2414)) +(let __tmp2416 (Concat __tmp2410 __tmp2415)) +(let __tmp2417 (Concat __tmp2408 __tmp2416)) +(let __tmp2418 (Concat __tmp2406 __tmp2417)) +(let __tmp2419 (Concat __tmp2404 __tmp2418)) +(let __tmp2420 (Concat __tmp2402 __tmp2419)) +(let __tmp2421 (Concat __tmp2400 __tmp2420)) +(let __tmp2422 (Concat __tmp2398 __tmp2421)) +(let __tmp2423 (Concat __tmp2396 __tmp2422)) +(let __tmp2424 (Concat __tmp2394 __tmp2423)) +(let __tmp2425 (Concat __tmp2392 __tmp2424)) +(let __tmp2426 (Concat __tmp2390 __tmp2425)) +(let __tmp2427 (Concat __tmp2388 __tmp2426)) +(let __tmp2428 (Concat __tmp2386 __tmp2427)) +(let __tmp2429 (Concat __tmp2384 __tmp2428)) +(let __tmp2430 (Concat __tmp2382 __tmp2429)) +(let __tmp2431 (DoWhile __tmp2269 __tmp2430)) +(let __tmp2432 (Get __tmp2431 0)) +(let __tmp2433 (Single __tmp2432)) +(let __tmp2434 (Get __tmp2431 1)) +(let __tmp2435 (Get __tmp2431 2)) +(let __tmp2436 (Bop __tmp1449 __tmp2434 __tmp2435)) +(let __tmp2437 (Single __tmp2436)) +(let __tmp2438 (Single __tmp2435)) +(let __tmp2439 (Get __tmp2431 3)) +(let __tmp2440 (Get __tmp2431 4)) +(let __tmp2441 (Bop __tmp358 __tmp2439 __tmp2440)) +(let __tmp2442 (Single __tmp2441)) +(let __tmp2443 (Single __tmp2440)) +(let __tmp2444 (Get __tmp2431 7)) +(let __tmp2445 (Single __tmp2444)) +(let __tmp2446 (Get __tmp2431 8)) +(let __tmp2447 (Single __tmp2446)) +(let __tmp2448 (Get __tmp2431 9)) +(let __tmp2449 (Single __tmp2448)) +(let __tmp2450 (Get __tmp2431 10)) +(let __tmp2451 (Single __tmp2450)) +(let __tmp2452 (Get __tmp2431 11)) +(let __tmp2453 (Single __tmp2452)) +(let __tmp2454 (Const __tmp361 __tmp2215 __tmp6)) +(let __tmp2455 (Single __tmp2454)) +(let __tmp2456 (Get __tmp2431 12)) +(let __tmp2457 (Single __tmp2456)) +(let __tmp2458 (Get __tmp2431 13)) +(let __tmp2459 (Single __tmp2458)) +(let __tmp2460 (Get __tmp2431 14)) +(let __tmp2461 (Single __tmp2460)) +(let __tmp2462 (Get __tmp2431 15)) +(let __tmp2463 (Single __tmp2462)) +(let __tmp2464 (Concat __tmp2461 __tmp2463)) +(let __tmp2465 (Concat __tmp2459 __tmp2464)) +(let __tmp2466 (Concat __tmp2457 __tmp2465)) +(let __tmp2467 (Concat __tmp2455 __tmp2466)) +(let __tmp2468 (Concat __tmp2453 __tmp2467)) +(let __tmp2469 (Concat __tmp2451 __tmp2468)) +(let __tmp2470 (Concat __tmp2449 __tmp2469)) +(let __tmp2471 (Concat __tmp2447 __tmp2470)) +(let __tmp2472 (Concat __tmp2445 __tmp2471)) +(let __tmp2473 (Concat __tmp2443 __tmp2472)) +(let __tmp2474 (Concat __tmp2442 __tmp2473)) +(let __tmp2475 (Concat __tmp2438 __tmp2474)) +(let __tmp2476 (Concat __tmp2437 __tmp2475)) +(let __tmp2477 (Concat __tmp2433 __tmp2476)) +(let __tmp2478 (Const __tmp379 __tmp2215 __tmp6)) +(let __tmp2479 (Single __tmp2478)) +(let __tmp2480 (Concat __tmp2479 __tmp2248)) +(let __tmp2481 (Concat __tmp2238 __tmp2480)) +(let __tmp2482 (Concat __tmp2236 __tmp2481)) +(let __tmp2483 (Concat __tmp2234 __tmp2482)) +(let __tmp2484 (Concat __tmp2232 __tmp2483)) +(let __tmp2485 (Concat __tmp2230 __tmp2484)) +(let __tmp2486 (Concat __tmp2228 __tmp2485)) +(let __tmp2487 (Concat __tmp2226 __tmp2486)) +(let __tmp2488 (Concat __tmp2225 __tmp2487)) +(let __tmp2489 (Concat __tmp2223 __tmp2488)) +(let __tmp2490 (Concat __tmp2221 __tmp2489)) +(let __tmp2491 (If __tmp2219 __tmp2258 __tmp2477 __tmp2490)) +(let __tmp2492 (Get __tmp2491 10)) +(let __tmp2493 (Single __tmp2492)) +(let __tmp2494 (Get __tmp2491 0)) +(let __tmp2495 (Single __tmp2494)) +(let __tmp2496 (Get __tmp2491 1)) +(let __tmp2497 (Single __tmp2496)) +(let __tmp2498 (Get __tmp2491 2)) +(let __tmp2499 (Single __tmp2498)) +(let __tmp2500 (Get __tmp2491 3)) +(let __tmp2501 (Single __tmp2500)) +(let __tmp2502 (Get __tmp2491 4)) +(let __tmp2503 (Single __tmp2502)) +(let __tmp2504 (Get __tmp2491 5)) +(let __tmp2505 (Single __tmp2504)) +(let __tmp2506 (Get __tmp2491 6)) +(let __tmp2507 (Single __tmp2506)) +(let __tmp2508 (Get __tmp2491 7)) +(let __tmp2509 (Single __tmp2508)) +(let __tmp2510 (Get __tmp2491 8)) +(let __tmp2511 (Single __tmp2510)) +(let __tmp2512 (Get __tmp2491 9)) +(let __tmp2513 (Single __tmp2512)) +(let __tmp2514 (Get __tmp2491 11)) +(let __tmp2515 (Single __tmp2514)) +(let __tmp2516 (Get __tmp2491 12)) +(let __tmp2517 (Single __tmp2516)) +(let __tmp2518 (Get __tmp2491 13)) +(let __tmp2519 (Single __tmp2518)) +(let __tmp2520 (Get __tmp2491 14)) +(let __tmp2521 (Single __tmp2520)) +(let __tmp2522 (Concat __tmp2519 __tmp2521)) +(let __tmp2523 (Concat __tmp2517 __tmp2522)) +(let __tmp2524 (Concat __tmp2515 __tmp2523)) +(let __tmp2525 (Concat __tmp2513 __tmp2524)) +(let __tmp2526 (Concat __tmp2511 __tmp2525)) +(let __tmp2527 (Concat __tmp2509 __tmp2526)) +(let __tmp2528 (Concat __tmp2507 __tmp2527)) +(let __tmp2529 (Concat __tmp2505 __tmp2528)) +(let __tmp2530 (Concat __tmp2503 __tmp2529)) +(let __tmp2531 (Concat __tmp2501 __tmp2530)) +(let __tmp2532 (Concat __tmp2499 __tmp2531)) +(let __tmp2533 (Concat __tmp2497 __tmp2532)) +(let __tmp2534 (Concat __tmp2495 __tmp2533)) +(let __tmp2535 (Concat __tmp2493 __tmp2534)) +(let __tmp2536 (DoWhile __tmp2202 __tmp2535)) +(let __tmp2537 (Get __tmp2536 0)) +(let __tmp2538 (Single __tmp2537)) +(let __tmp2539 (Get __tmp2536 2)) +(let __tmp2540 (Single __tmp2539)) +(let __tmp2541 (Get __tmp2536 4)) +(let __tmp2542 (Single __tmp2541)) +(let __tmp2543 (Get __tmp2536 5)) +(let __tmp2544 (Single __tmp2543)) +(let __tmp2545 (Get __tmp2536 6)) +(let __tmp2546 (Single __tmp2545)) +(let __tmp2547 (Get __tmp2536 7)) +(let __tmp2548 (Single __tmp2547)) +(let __tmp2549 (Get __tmp2536 8)) +(let __tmp2550 (Single __tmp2549)) +(let __tmp2551 (Get __tmp2536 9)) +(let __tmp2552 (Single __tmp2551)) +(let __tmp2553 (Concat __tmp2550 __tmp2552)) +(let __tmp2554 (Concat __tmp2548 __tmp2553)) +(let __tmp2555 (Concat __tmp2546 __tmp2554)) +(let __tmp2556 (Concat __tmp2544 __tmp2555)) +(let __tmp2557 (Concat __tmp2542 __tmp2556)) +(let __tmp2558 (Concat __tmp1238 __tmp2557)) +(let __tmp2559 (Concat __tmp2540 __tmp2558)) +(let __tmp2560 (Concat __tmp1233 __tmp2559)) +(let __tmp2561 (Concat __tmp2538 __tmp2560)) +(let __tmp2562 (TCons __tmp115 __tmp2203)) +(let __tmp2563 (TCons __tmp114 __tmp2562)) +(let __tmp2564 (TCons __tmp115 __tmp2563)) +(let __tmp2565 (TCons __tmp115 __tmp2564)) +(let __tmp2566 (TCons __tmp113 __tmp2565)) +(let __tmp2567 (TCons __tmp113 __tmp2566)) +(let __tmp2568 (TCons __tmp0 __tmp2567)) +(let __tmp2569 (TupleT __tmp2568)) +(let __tmp2570 (Arg __tmp2569 __tmp6)) +(let __tmp2571 (Get __tmp2570 3)) +(let __tmp2572 (Get __tmp2570 9)) +(let __tmp2573 (Bop __tmp112 __tmp2571 __tmp2572)) +(let __tmp2574 (Get __tmp2570 0)) +(let __tmp2575 (Single __tmp2574)) +(let __tmp2576 (Get __tmp2570 1)) +(let __tmp2577 (Single __tmp2576)) +(let __tmp2578 (Get __tmp2570 2)) +(let __tmp2579 (Single __tmp2578)) +(let __tmp2580 (Single __tmp2571)) +(let __tmp2581 (Get __tmp2570 4)) +(let __tmp2582 (Single __tmp2581)) +(let __tmp2583 (Get __tmp2570 5)) +(let __tmp2584 (Single __tmp2583)) +(let __tmp2585 (Get __tmp2570 6)) +(let __tmp2586 (Single __tmp2585)) +(let __tmp2587 (Get __tmp2570 7)) +(let __tmp2588 (Single __tmp2587)) +(let __tmp2589 (Get __tmp2570 8)) +(let __tmp2590 (Single __tmp2589)) +(let __tmp2591 (Single __tmp2572)) +(let __tmp2592 (Concat __tmp2590 __tmp2591)) +(let __tmp2593 (Concat __tmp2588 __tmp2592)) +(let __tmp2594 (Concat __tmp2586 __tmp2593)) +(let __tmp2595 (Concat __tmp2584 __tmp2594)) +(let __tmp2596 (Concat __tmp2582 __tmp2595)) +(let __tmp2597 (Concat __tmp2580 __tmp2596)) +(let __tmp2598 (Concat __tmp2579 __tmp2597)) +(let __tmp2599 (Concat __tmp2577 __tmp2598)) +(let __tmp2600 (Concat __tmp2575 __tmp2599)) +(let __tmp2601 (Const __tmp95 __tmp2569 __tmp6)) +(let __tmp2602 (Single __tmp2601)) +(let __tmp2603 (Const __tmp83 __tmp2569 __tmp6)) +(let __tmp2604 (Single __tmp2603)) +(let __tmp2605 (Concat __tmp2604 __tmp2595)) +(let __tmp2606 (Concat __tmp2602 __tmp2605)) +(let __tmp2607 (Concat __tmp2582 __tmp2606)) +(let __tmp2608 (Concat __tmp2580 __tmp2607)) +(let __tmp2609 (Concat __tmp2579 __tmp2608)) +(let __tmp2610 (Concat __tmp2577 __tmp2609)) +(let __tmp2611 (Concat __tmp2575 __tmp2610)) +(let __tmp2612 (TCons __tmp113 __tmp2564)) +(let __tmp2613 (TCons __tmp115 __tmp2612)) +(let __tmp2614 (TCons __tmp115 __tmp2613)) +(let __tmp2615 (TCons __tmp113 __tmp2614)) +(let __tmp2616 (TCons __tmp113 __tmp2615)) +(let __tmp2617 (TCons __tmp0 __tmp2616)) +(let __tmp2618 (TupleT __tmp2617)) +(let __tmp2619 (Arg __tmp2618 __tmp6)) +(let __tmp2620 (Get __tmp2619 6)) +(let __tmp2621 (Get __tmp2619 8)) +(let __tmp2622 (Bop __tmp112 __tmp2620 __tmp2621)) +(let __tmp2623 (Get __tmp2619 0)) +(let __tmp2624 (Single __tmp2623)) +(let __tmp2625 (Get __tmp2619 1)) +(let __tmp2626 (Single __tmp2625)) +(let __tmp2627 (Get __tmp2619 2)) +(let __tmp2628 (Single __tmp2627)) +(let __tmp2629 (Get __tmp2619 3)) +(let __tmp2630 (Single __tmp2629)) +(let __tmp2631 (Get __tmp2619 4)) +(let __tmp2632 (Single __tmp2631)) +(let __tmp2633 (Get __tmp2619 5)) +(let __tmp2634 (Single __tmp2633)) +(let __tmp2635 (Single __tmp2620)) +(let __tmp2636 (Get __tmp2619 7)) +(let __tmp2637 (Single __tmp2636)) +(let __tmp2638 (Single __tmp2621)) +(let __tmp2639 (Get __tmp2619 9)) +(let __tmp2640 (Single __tmp2639)) +(let __tmp2641 (Get __tmp2619 10)) +(let __tmp2642 (Single __tmp2641)) +(let __tmp2643 (Get __tmp2619 11)) +(let __tmp2644 (Single __tmp2643)) +(let __tmp2645 (Concat __tmp2642 __tmp2644)) +(let __tmp2646 (Concat __tmp2640 __tmp2645)) +(let __tmp2647 (Concat __tmp2638 __tmp2646)) +(let __tmp2648 (Concat __tmp2637 __tmp2647)) +(let __tmp2649 (Concat __tmp2635 __tmp2648)) +(let __tmp2650 (Concat __tmp2634 __tmp2649)) +(let __tmp2651 (Concat __tmp2632 __tmp2650)) +(let __tmp2652 (Concat __tmp2630 __tmp2651)) +(let __tmp2653 (Concat __tmp2628 __tmp2652)) +(let __tmp2654 (Concat __tmp2626 __tmp2653)) +(let __tmp2655 (Concat __tmp2624 __tmp2654)) +(let __tmp2656 (Bop __tmp1449 __tmp2633 __tmp2641)) +(let __tmp2657 (Bop __tmp330 __tmp2625 __tmp2656)) +(let __tmp2658 (Single __tmp2657)) +(let __tmp2659 (Concat __tmp2640 __tmp2624)) +(let __tmp2660 (Concat __tmp2658 __tmp2659)) +(let __tmp2661 (Call "fmod" __tmp2660)) +(let __tmp2662 (Get __tmp2661 0)) +(let __tmp2663 (Bop __tmp1448 __tmp2662 __tmp2639)) +(let __tmp2664 (Single __tmp2663)) +(let __tmp2665 (Get __tmp2661 1)) +(let __tmp2666 (Single __tmp2665)) +(let __tmp2667 (Concat __tmp2664 __tmp2666)) +(let __tmp2668 (Concat __tmp2638 __tmp2667)) +(let __tmp2669 (Concat __tmp2635 __tmp2668)) +(let __tmp2670 (Concat __tmp2630 __tmp2669)) +(let __tmp2671 (Concat __tmp2637 __tmp2670)) +(let __tmp2672 (Call "matrix_set" __tmp2671)) +(let __tmp2673 (Get __tmp2672 0)) +(let __tmp2674 (Single __tmp2673)) +(let __tmp2675 (Const __tmp361 __tmp2618 __tmp6)) +(let __tmp2676 (Single __tmp2675)) +(let __tmp2677 (Bop __tmp1449 __tmp2633 __tmp2627)) +(let __tmp2678 (Single __tmp2677)) +(let __tmp2679 (Bop __tmp358 __tmp2620 __tmp2631)) +(let __tmp2680 (Single __tmp2679)) +(let __tmp2681 (Concat __tmp2680 __tmp2648)) +(let __tmp2682 (Concat __tmp2678 __tmp2681)) +(let __tmp2683 (Concat __tmp2676 __tmp2682)) +(let __tmp2684 (Concat __tmp2632 __tmp2683)) +(let __tmp2685 (Concat __tmp2630 __tmp2684)) +(let __tmp2686 (Concat __tmp2628 __tmp2685)) +(let __tmp2687 (Concat __tmp2626 __tmp2686)) +(let __tmp2688 (Concat __tmp2674 __tmp2687)) +(let __tmp2689 (Const __tmp379 __tmp2618 __tmp6)) +(let __tmp2690 (Single __tmp2689)) +(let __tmp2691 (Concat __tmp2690 __tmp2650)) +(let __tmp2692 (Concat __tmp2632 __tmp2691)) +(let __tmp2693 (Concat __tmp2630 __tmp2692)) +(let __tmp2694 (Concat __tmp2628 __tmp2693)) +(let __tmp2695 (Concat __tmp2626 __tmp2694)) +(let __tmp2696 (Concat __tmp2624 __tmp2695)) +(let __tmp2697 (If __tmp2622 __tmp2655 __tmp2688 __tmp2696)) +(let __tmp2698 (Get __tmp2697 5)) +(let __tmp2699 (Single __tmp2698)) +(let __tmp2700 (Get __tmp2697 0)) +(let __tmp2701 (Single __tmp2700)) +(let __tmp2702 (Get __tmp2697 1)) +(let __tmp2703 (Single __tmp2702)) +(let __tmp2704 (Get __tmp2697 2)) +(let __tmp2705 (Single __tmp2704)) +(let __tmp2706 (Get __tmp2697 3)) +(let __tmp2707 (Single __tmp2706)) +(let __tmp2708 (Get __tmp2697 4)) +(let __tmp2709 (Single __tmp2708)) +(let __tmp2710 (Get __tmp2697 6)) +(let __tmp2711 (Single __tmp2710)) +(let __tmp2712 (Get __tmp2697 7)) +(let __tmp2713 (Single __tmp2712)) +(let __tmp2714 (Get __tmp2697 8)) +(let __tmp2715 (Single __tmp2714)) +(let __tmp2716 (Get __tmp2697 9)) +(let __tmp2717 (Single __tmp2716)) +(let __tmp2718 (Get __tmp2697 10)) +(let __tmp2719 (Single __tmp2718)) +(let __tmp2720 (Get __tmp2697 11)) +(let __tmp2721 (Single __tmp2720)) +(let __tmp2722 (Get __tmp2697 12)) +(let __tmp2723 (Single __tmp2722)) +(let __tmp2724 (Concat __tmp2721 __tmp2723)) +(let __tmp2725 (Concat __tmp2719 __tmp2724)) +(let __tmp2726 (Concat __tmp2717 __tmp2725)) +(let __tmp2727 (Concat __tmp2715 __tmp2726)) +(let __tmp2728 (Concat __tmp2713 __tmp2727)) +(let __tmp2729 (Concat __tmp2711 __tmp2728)) +(let __tmp2730 (Concat __tmp2709 __tmp2729)) +(let __tmp2731 (Concat __tmp2707 __tmp2730)) +(let __tmp2732 (Concat __tmp2705 __tmp2731)) +(let __tmp2733 (Concat __tmp2703 __tmp2732)) +(let __tmp2734 (Concat __tmp2701 __tmp2733)) +(let __tmp2735 (Concat __tmp2699 __tmp2734)) +(let __tmp2736 (DoWhile __tmp2611 __tmp2735)) +(let __tmp2737 (Get __tmp2736 0)) +(let __tmp2738 (Single __tmp2737)) +(let __tmp2739 (Const __tmp361 __tmp2569 __tmp6)) +(let __tmp2740 (Single __tmp2739)) +(let __tmp2741 (Get __tmp2736 1)) +(let __tmp2742 (Get __tmp2736 2)) +(let __tmp2743 (Bop __tmp1449 __tmp2741 __tmp2742)) +(let __tmp2744 (Single __tmp2743)) +(let __tmp2745 (Single __tmp2742)) +(let __tmp2746 (Get __tmp2736 3)) +(let __tmp2747 (Get __tmp2736 4)) +(let __tmp2748 (Bop __tmp358 __tmp2746 __tmp2747)) +(let __tmp2749 (Single __tmp2748)) +(let __tmp2750 (Single __tmp2747)) +(let __tmp2751 (Get __tmp2736 7)) +(let __tmp2752 (Single __tmp2751)) +(let __tmp2753 (Get __tmp2736 8)) +(let __tmp2754 (Single __tmp2753)) +(let __tmp2755 (Get __tmp2736 9)) +(let __tmp2756 (Single __tmp2755)) +(let __tmp2757 (Get __tmp2736 10)) +(let __tmp2758 (Single __tmp2757)) +(let __tmp2759 (Get __tmp2736 11)) +(let __tmp2760 (Single __tmp2759)) +(let __tmp2761 (Concat __tmp2758 __tmp2760)) +(let __tmp2762 (Concat __tmp2756 __tmp2761)) +(let __tmp2763 (Concat __tmp2754 __tmp2762)) +(let __tmp2764 (Concat __tmp2752 __tmp2763)) +(let __tmp2765 (Concat __tmp2750 __tmp2764)) +(let __tmp2766 (Concat __tmp2749 __tmp2765)) +(let __tmp2767 (Concat __tmp2745 __tmp2766)) +(let __tmp2768 (Concat __tmp2744 __tmp2767)) +(let __tmp2769 (Concat __tmp2740 __tmp2768)) +(let __tmp2770 (Concat __tmp2738 __tmp2769)) +(let __tmp2771 (Const __tmp379 __tmp2569 __tmp6)) +(let __tmp2772 (Single __tmp2771)) +(let __tmp2773 (Concat __tmp2772 __tmp2599)) +(let __tmp2774 (Concat __tmp2575 __tmp2773)) +(let __tmp2775 (If __tmp2573 __tmp2600 __tmp2770 __tmp2774)) +(let __tmp2776 (Get __tmp2775 1)) +(let __tmp2777 (Single __tmp2776)) +(let __tmp2778 (Get __tmp2775 0)) +(let __tmp2779 (Single __tmp2778)) +(let __tmp2780 (Get __tmp2775 2)) +(let __tmp2781 (Single __tmp2780)) +(let __tmp2782 (Get __tmp2775 3)) +(let __tmp2783 (Single __tmp2782)) +(let __tmp2784 (Get __tmp2775 4)) +(let __tmp2785 (Single __tmp2784)) +(let __tmp2786 (Get __tmp2775 5)) +(let __tmp2787 (Single __tmp2786)) +(let __tmp2788 (Get __tmp2775 6)) +(let __tmp2789 (Single __tmp2788)) +(let __tmp2790 (Get __tmp2775 7)) +(let __tmp2791 (Single __tmp2790)) +(let __tmp2792 (Get __tmp2775 8)) +(let __tmp2793 (Single __tmp2792)) +(let __tmp2794 (Get __tmp2775 9)) +(let __tmp2795 (Single __tmp2794)) +(let __tmp2796 (Get __tmp2775 10)) +(let __tmp2797 (Single __tmp2796)) +(let __tmp2798 (Concat __tmp2795 __tmp2797)) +(let __tmp2799 (Concat __tmp2793 __tmp2798)) +(let __tmp2800 (Concat __tmp2791 __tmp2799)) +(let __tmp2801 (Concat __tmp2789 __tmp2800)) +(let __tmp2802 (Concat __tmp2787 __tmp2801)) +(let __tmp2803 (Concat __tmp2785 __tmp2802)) +(let __tmp2804 (Concat __tmp2783 __tmp2803)) +(let __tmp2805 (Concat __tmp2781 __tmp2804)) +(let __tmp2806 (Concat __tmp2779 __tmp2805)) +(let __tmp2807 (Concat __tmp2777 __tmp2806)) +(let __tmp2808 (DoWhile __tmp2561 __tmp2807)) +(let __tmp2809 (Get __tmp2808 0)) +(let __tmp2810 (Single __tmp2809)) +(let __tmp2811 (Function "init" __tmp1228 __tmp3 __tmp2810)) +(let __tmp2812 (TCons __tmp115 __tmp2)) +(let __tmp2813 (TCons __tmp115 __tmp2812)) +(let __tmp2814 (TupleT __tmp2813)) +(let __tmp2815 (TCons __tmp114 __tmp2)) +(let __tmp2816 (TupleT __tmp2815)) +(let __tmp2817 (Mul )) +(let __tmp2818 (Arg __tmp2814 __tmp6)) +(let __tmp2819 (Get __tmp2818 0)) +(let __tmp2820 (Get __tmp2818 1)) +(let __tmp2821 (Bop __tmp2817 __tmp2819 __tmp2820)) +(let __tmp2822 (Get __tmp2818 2)) +(let __tmp2823 (Alloc 0 __tmp2821 __tmp2822 __tmp114)) +(let __tmp2824 (Get __tmp2823 0)) +(let __tmp2825 (Single __tmp2824)) +(let __tmp2826 (Get __tmp2823 1)) +(let __tmp2827 (Single __tmp2826)) +(let __tmp2828 (Concat __tmp2825 __tmp2827)) +(let __tmp2829 (Function "matrix_new" __tmp2814 __tmp2816 __tmp2828)) +(let __tmp2830 (TCons __tmp115 __tmp2813)) +(let __tmp2831 (TCons __tmp114 __tmp2830)) +(let __tmp2832 (TupleT __tmp2831)) +(let __tmp2833 (PtrAdd )) +(let __tmp2834 (Arg __tmp2832 __tmp6)) +(let __tmp2835 (Get __tmp2834 0)) +(let __tmp2836 (Get __tmp2834 1)) +(let __tmp2837 (Get __tmp2834 3)) +(let __tmp2838 (Bop __tmp2817 __tmp2836 __tmp2837)) +(let __tmp2839 (Get __tmp2834 2)) +(let __tmp2840 (Bop __tmp358 __tmp2838 __tmp2839)) +(let __tmp2841 (Bop __tmp2833 __tmp2835 __tmp2840)) +(let __tmp2842 (Single __tmp2841)) +(let __tmp2843 (Get __tmp2834 4)) +(let __tmp2844 (Single __tmp2843)) +(let __tmp2845 (Concat __tmp2842 __tmp2844)) +(let __tmp2846 (Function "matrix_loc" __tmp2832 __tmp2816 __tmp2845)) +(let __tmp2847 (TupleT __tmp1216)) +(let __tmp2848 (Load )) +(let __tmp2849 (Single __tmp2835)) +(let __tmp2850 (Single __tmp2836)) +(let __tmp2851 (Single __tmp2839)) +(let __tmp2852 (Single __tmp2837)) +(let __tmp2853 (Concat __tmp2852 __tmp2844)) +(let __tmp2854 (Concat __tmp2851 __tmp2853)) +(let __tmp2855 (Concat __tmp2850 __tmp2854)) +(let __tmp2856 (Concat __tmp2849 __tmp2855)) +(let __tmp2857 (Call "matrix_loc" __tmp2856)) +(let __tmp2858 (Get __tmp2857 0)) +(let __tmp2859 (Get __tmp2857 1)) +(let __tmp2860 (Bop __tmp2848 __tmp2858 __tmp2859)) +(let __tmp2861 (Get __tmp2860 0)) +(let __tmp2862 (Single __tmp2861)) +(let __tmp2863 (Get __tmp2860 1)) +(let __tmp2864 (Single __tmp2863)) +(let __tmp2865 (Concat __tmp2862 __tmp2864)) +(let __tmp2866 (Function "matrix_get" __tmp2832 __tmp2847 __tmp2865)) +(let __tmp2867 (TCons __tmp115 __tmp1217)) +(let __tmp2868 (TCons __tmp115 __tmp2867)) +(let __tmp2869 (TCons __tmp114 __tmp2868)) +(let __tmp2870 (TupleT __tmp2869)) +(let __tmp2871 (Write )) +(let __tmp2872 (Arg __tmp2870 __tmp6)) +(let __tmp2873 (Get __tmp2872 0)) +(let __tmp2874 (Single __tmp2873)) +(let __tmp2875 (Get __tmp2872 1)) +(let __tmp2876 (Single __tmp2875)) +(let __tmp2877 (Get __tmp2872 2)) +(let __tmp2878 (Single __tmp2877)) +(let __tmp2879 (Get __tmp2872 3)) +(let __tmp2880 (Single __tmp2879)) +(let __tmp2881 (Get __tmp2872 5)) +(let __tmp2882 (Single __tmp2881)) +(let __tmp2883 (Concat __tmp2880 __tmp2882)) +(let __tmp2884 (Concat __tmp2878 __tmp2883)) +(let __tmp2885 (Concat __tmp2876 __tmp2884)) +(let __tmp2886 (Concat __tmp2874 __tmp2885)) +(let __tmp2887 (Call "matrix_loc" __tmp2886)) +(let __tmp2888 (Get __tmp2887 0)) +(let __tmp2889 (Get __tmp2872 4)) +(let __tmp2890 (Get __tmp2887 1)) +(let __tmp2891 (Top __tmp2871 __tmp2888 __tmp2889 __tmp2890)) +(let __tmp2892 (Single __tmp2891)) +(let __tmp2893 (Function "matrix_set" __tmp2870 __tmp3 __tmp2892)) +(let __tmp2894 (Bop __tmp2848 __tmp2888 __tmp2890)) +(let __tmp2895 (Get __tmp2894 0)) +(let __tmp2896 (Bop __tmp1449 __tmp2895 __tmp2889)) +(let __tmp2897 (Get __tmp2894 1)) +(let __tmp2898 (Top __tmp2871 __tmp2888 __tmp2896 __tmp2897)) +(let __tmp2899 (Single __tmp2898)) +(let __tmp2900 (Function "matrix_incr" __tmp2870 __tmp3 __tmp2899)) +(let __tmp2901 (Bop __tmp330 __tmp2895 __tmp2889)) +(let __tmp2902 (Top __tmp2871 __tmp2888 __tmp2901 __tmp2897)) +(let __tmp2903 (Single __tmp2902)) +(let __tmp2904 (Function "matrix_scale" __tmp2870 __tmp3 __tmp2903)) +(let __tmp2905 (TCons __tmp114 __tmp2813)) +(let __tmp2906 (TupleT __tmp2905)) +(let __tmp2907 (Arg __tmp2906 __tmp6)) +(let __tmp2908 (Get __tmp2907 3)) +(let __tmp2909 (Single __tmp2908)) +(let __tmp2910 (Const __tmp95 __tmp2906 __tmp6)) +(let __tmp2911 (Single __tmp2910)) +(let __tmp2912 (Const __tmp83 __tmp2906 __tmp6)) +(let __tmp2913 (Single __tmp2912)) +(let __tmp2914 (Const __tmp86 __tmp2906 __tmp6)) +(let __tmp2915 (Single __tmp2914)) +(let __tmp2916 (Get __tmp2907 0)) +(let __tmp2917 (Single __tmp2916)) +(let __tmp2918 (Get __tmp2907 1)) +(let __tmp2919 (Get __tmp2907 2)) +(let __tmp2920 (Bop __tmp2817 __tmp2918 __tmp2919)) +(let __tmp2921 (Single __tmp2920)) +(let __tmp2922 (Concat __tmp2917 __tmp2921)) +(let __tmp2923 (Concat __tmp2915 __tmp2922)) +(let __tmp2924 (Concat __tmp2913 __tmp2923)) +(let __tmp2925 (Concat __tmp2911 __tmp2924)) +(let __tmp2926 (Concat __tmp2909 __tmp2925)) +(let __tmp2927 (TCons __tmp114 __tmp1772)) +(let __tmp2928 (TCons __tmp115 __tmp2927)) +(let __tmp2929 (TCons __tmp115 __tmp2928)) +(let __tmp2930 (TCons __tmp113 __tmp2929)) +(let __tmp2931 (TCons __tmp0 __tmp2930)) +(let __tmp2932 (TupleT __tmp2931)) +(let __tmp2933 (Arg __tmp2932 __tmp6)) +(let __tmp2934 (Get __tmp2933 2)) +(let __tmp2935 (Get __tmp2933 5)) +(let __tmp2936 (Bop __tmp112 __tmp2934 __tmp2935)) +(let __tmp2937 (Get __tmp2933 0)) +(let __tmp2938 (Single __tmp2937)) +(let __tmp2939 (Get __tmp2933 1)) +(let __tmp2940 (Single __tmp2939)) +(let __tmp2941 (Single __tmp2934)) +(let __tmp2942 (Get __tmp2933 3)) +(let __tmp2943 (Single __tmp2942)) +(let __tmp2944 (Get __tmp2933 4)) +(let __tmp2945 (Single __tmp2944)) +(let __tmp2946 (Single __tmp2935)) +(let __tmp2947 (Concat __tmp2945 __tmp2946)) +(let __tmp2948 (Concat __tmp2943 __tmp2947)) +(let __tmp2949 (Concat __tmp2941 __tmp2948)) +(let __tmp2950 (Concat __tmp2940 __tmp2949)) +(let __tmp2951 (Concat __tmp2938 __tmp2950)) +(let __tmp2952 (Bop __tmp2833 __tmp2944 __tmp2934)) +(let __tmp2953 (Bop __tmp2848 __tmp2952 __tmp2937)) +(let __tmp2954 (Get __tmp2953 1)) +(let __tmp2955 (Single __tmp2954)) +(let __tmp2956 (Get __tmp2953 0)) +(let __tmp2957 (Bop __tmp1449 __tmp2939 __tmp2956)) +(let __tmp2958 (Single __tmp2957)) +(let __tmp2959 (Const __tmp361 __tmp2932 __tmp6)) +(let __tmp2960 (Single __tmp2959)) +(let __tmp2961 (Bop __tmp358 __tmp2934 __tmp2942)) +(let __tmp2962 (Single __tmp2961)) +(let __tmp2963 (Concat __tmp2962 __tmp2948)) +(let __tmp2964 (Concat __tmp2960 __tmp2963)) +(let __tmp2965 (Concat __tmp2958 __tmp2964)) +(let __tmp2966 (Concat __tmp2955 __tmp2965)) +(let __tmp2967 (Const __tmp379 __tmp2932 __tmp6)) +(let __tmp2968 (Single __tmp2967)) +(let __tmp2969 (Concat __tmp2968 __tmp2949)) +(let __tmp2970 (Concat __tmp2940 __tmp2969)) +(let __tmp2971 (Concat __tmp2938 __tmp2970)) +(let __tmp2972 (If __tmp2936 __tmp2951 __tmp2966 __tmp2971)) +(let __tmp2973 (Get __tmp2972 2)) +(let __tmp2974 (Single __tmp2973)) +(let __tmp2975 (Get __tmp2972 0)) +(let __tmp2976 (Single __tmp2975)) +(let __tmp2977 (Get __tmp2972 1)) +(let __tmp2978 (Single __tmp2977)) +(let __tmp2979 (Get __tmp2972 3)) +(let __tmp2980 (Single __tmp2979)) +(let __tmp2981 (Get __tmp2972 4)) +(let __tmp2982 (Single __tmp2981)) +(let __tmp2983 (Get __tmp2972 5)) +(let __tmp2984 (Single __tmp2983)) +(let __tmp2985 (Get __tmp2972 6)) +(let __tmp2986 (Single __tmp2985)) +(let __tmp2987 (Concat __tmp2984 __tmp2986)) +(let __tmp2988 (Concat __tmp2982 __tmp2987)) +(let __tmp2989 (Concat __tmp2980 __tmp2988)) +(let __tmp2990 (Concat __tmp2978 __tmp2989)) +(let __tmp2991 (Concat __tmp2976 __tmp2990)) +(let __tmp2992 (Concat __tmp2974 __tmp2991)) +(let __tmp2993 (DoWhile __tmp2926 __tmp2992)) +(let __tmp2994 (Get __tmp2993 1)) +(let __tmp2995 (Single __tmp2994)) +(let __tmp2996 (Get __tmp2993 0)) +(let __tmp2997 (Single __tmp2996)) +(let __tmp2998 (Concat __tmp2995 __tmp2997)) +(let __tmp2999 (Function "matrix_sum" __tmp2906 __tmp2847 __tmp2998)) +(let __tmp3000 (TCons __tmp113 __tmp1216)) +(let __tmp3001 (TupleT __tmp3000)) +(let __tmp3002 (Arg __tmp3001 __tmp6)) +(let __tmp3003 (Get __tmp3002 2)) +(let __tmp3004 (Single __tmp3003)) +(let __tmp3005 (Get __tmp3002 0)) +(let __tmp3006 (Single __tmp3005)) +(let __tmp3007 (Const __tmp1247 __tmp3001 __tmp6)) +(let __tmp3008 (Single __tmp3007)) +(let __tmp3009 (Const __tmp95 __tmp3001 __tmp6)) +(let __tmp3010 (Single __tmp3009)) +(let __tmp3011 (Get __tmp3002 1)) +(let __tmp3012 (Single __tmp3011)) +(let __tmp3013 (Concat __tmp3010 __tmp3012)) +(let __tmp3014 (Concat __tmp3008 __tmp3013)) +(let __tmp3015 (Concat __tmp3006 __tmp3014)) +(let __tmp3016 (Concat __tmp3004 __tmp3015)) +(let __tmp3017 (FGreaterEq )) +(let __tmp3018 (TCons __tmp113 __tmp116)) +(let __tmp3019 (TCons __tmp113 __tmp3018)) +(let __tmp3020 (TCons __tmp113 __tmp3019)) +(let __tmp3021 (TCons __tmp0 __tmp3020)) +(let __tmp3022 (TupleT __tmp3021)) +(let __tmp3023 (Arg __tmp3022 __tmp6)) +(let __tmp3024 (Get __tmp3023 1)) +(let __tmp3025 (Get __tmp3023 4)) +(let __tmp3026 (Bop __tmp3017 __tmp3024 __tmp3025)) +(let __tmp3027 (Get __tmp3023 0)) +(let __tmp3028 (Single __tmp3027)) +(let __tmp3029 (Single __tmp3024)) +(let __tmp3030 (Get __tmp3023 2)) +(let __tmp3031 (Single __tmp3030)) +(let __tmp3032 (Get __tmp3023 3)) +(let __tmp3033 (Single __tmp3032)) +(let __tmp3034 (Single __tmp3025)) +(let __tmp3035 (Concat __tmp3033 __tmp3034)) +(let __tmp3036 (Concat __tmp3031 __tmp3035)) +(let __tmp3037 (Concat __tmp3029 __tmp3036)) +(let __tmp3038 (Concat __tmp3028 __tmp3037)) +(let __tmp3039 (Concat __tmp3034 __tmp3036)) +(let __tmp3040 (Concat __tmp3029 __tmp3039)) +(let __tmp3041 (Concat __tmp3028 __tmp3040)) +(let __tmp3042 (FSub )) +(let __tmp3043 (TCons __tmp113 __tmp3020)) +(let __tmp3044 (TCons __tmp0 __tmp3043)) +(let __tmp3045 (TupleT __tmp3044)) +(let __tmp3046 (Arg __tmp3045 __tmp6)) +(let __tmp3047 (Get __tmp3046 1)) +(let __tmp3048 (Get __tmp3046 2)) +(let __tmp3049 (Bop __tmp3042 __tmp3047 __tmp3048)) +(let __tmp3050 (Get __tmp3046 4)) +(let __tmp3051 (Bop __tmp3017 __tmp3049 __tmp3050)) +(let __tmp3052 (Get __tmp3046 0)) +(let __tmp3053 (Single __tmp3052)) +(let __tmp3054 (Single __tmp3047)) +(let __tmp3055 (Single __tmp3048)) +(let __tmp3056 (Get __tmp3046 3)) +(let __tmp3057 (Single __tmp3056)) +(let __tmp3058 (Single __tmp3050)) +(let __tmp3059 (Get __tmp3046 5)) +(let __tmp3060 (Single __tmp3059)) +(let __tmp3061 (Concat __tmp3058 __tmp3060)) +(let __tmp3062 (Concat __tmp3057 __tmp3061)) +(let __tmp3063 (Concat __tmp3055 __tmp3062)) +(let __tmp3064 (Concat __tmp3054 __tmp3063)) +(let __tmp3065 (Concat __tmp3053 __tmp3064)) +(let __tmp3066 (Bop __tmp330 __tmp3048 __tmp3056)) +(let __tmp3067 (Single __tmp3066)) +(let __tmp3068 (Const __tmp361 __tmp3045 __tmp6)) +(let __tmp3069 (Single __tmp3068)) +(let __tmp3070 (Concat __tmp3069 __tmp3061)) +(let __tmp3071 (Concat __tmp3057 __tmp3070)) +(let __tmp3072 (Concat __tmp3067 __tmp3071)) +(let __tmp3073 (Concat __tmp3054 __tmp3072)) +(let __tmp3074 (Concat __tmp3053 __tmp3073)) +(let __tmp3075 (Const __tmp379 __tmp3045 __tmp6)) +(let __tmp3076 (Single __tmp3075)) +(let __tmp3077 (Concat __tmp3076 __tmp3061)) +(let __tmp3078 (Concat __tmp3057 __tmp3077)) +(let __tmp3079 (Concat __tmp3055 __tmp3078)) +(let __tmp3080 (Concat __tmp3054 __tmp3079)) +(let __tmp3081 (Concat __tmp3053 __tmp3080)) +(let __tmp3082 (If __tmp3051 __tmp3065 __tmp3074 __tmp3081)) +(let __tmp3083 (Get __tmp3082 4)) +(let __tmp3084 (Single __tmp3083)) +(let __tmp3085 (Get __tmp3082 0)) +(let __tmp3086 (Single __tmp3085)) +(let __tmp3087 (Get __tmp3082 1)) +(let __tmp3088 (Single __tmp3087)) +(let __tmp3089 (Get __tmp3082 2)) +(let __tmp3090 (Single __tmp3089)) +(let __tmp3091 (Get __tmp3082 3)) +(let __tmp3092 (Single __tmp3091)) +(let __tmp3093 (Get __tmp3082 5)) +(let __tmp3094 (Single __tmp3093)) +(let __tmp3095 (Get __tmp3082 6)) +(let __tmp3096 (Single __tmp3095)) +(let __tmp3097 (Concat __tmp3094 __tmp3096)) +(let __tmp3098 (Concat __tmp3092 __tmp3097)) +(let __tmp3099 (Concat __tmp3090 __tmp3098)) +(let __tmp3100 (Concat __tmp3088 __tmp3099)) +(let __tmp3101 (Concat __tmp3086 __tmp3100)) +(let __tmp3102 (Concat __tmp3084 __tmp3101)) +(let __tmp3103 (DoWhile __tmp3041 __tmp3102)) +(let __tmp3104 (Get __tmp3103 0)) +(let __tmp3105 (Single __tmp3104)) +(let __tmp3106 (Get __tmp3103 1)) +(let __tmp3107 (Get __tmp3103 2)) +(let __tmp3108 (Get __tmp3103 3)) +(let __tmp3109 (Bop __tmp1448 __tmp3107 __tmp3108)) +(let __tmp3110 (Bop __tmp3042 __tmp3106 __tmp3109)) +(let __tmp3111 (Single __tmp3110)) +(let __tmp3112 (Const __tmp361 __tmp3022 __tmp6)) +(let __tmp3113 (Single __tmp3112)) +(let __tmp3114 (Single __tmp3108)) +(let __tmp3115 (Get __tmp3103 4)) +(let __tmp3116 (Single __tmp3115)) +(let __tmp3117 (Get __tmp3103 5)) +(let __tmp3118 (Single __tmp3117)) +(let __tmp3119 (Concat __tmp3116 __tmp3118)) +(let __tmp3120 (Concat __tmp3114 __tmp3119)) +(let __tmp3121 (Concat __tmp3113 __tmp3120)) +(let __tmp3122 (Concat __tmp3111 __tmp3121)) +(let __tmp3123 (Concat __tmp3105 __tmp3122)) +(let __tmp3124 (Const __tmp379 __tmp3022 __tmp6)) +(let __tmp3125 (Single __tmp3124)) +(let __tmp3126 (Concat __tmp3125 __tmp3036)) +(let __tmp3127 (Concat __tmp3029 __tmp3126)) +(let __tmp3128 (Concat __tmp3028 __tmp3127)) +(let __tmp3129 (If __tmp3026 __tmp3038 __tmp3123 __tmp3128)) +(let __tmp3130 (Get __tmp3129 2)) +(let __tmp3131 (Single __tmp3130)) +(let __tmp3132 (Get __tmp3129 0)) +(let __tmp3133 (Single __tmp3132)) +(let __tmp3134 (Get __tmp3129 1)) +(let __tmp3135 (Single __tmp3134)) +(let __tmp3136 (Get __tmp3129 3)) +(let __tmp3137 (Single __tmp3136)) +(let __tmp3138 (Get __tmp3129 4)) +(let __tmp3139 (Single __tmp3138)) +(let __tmp3140 (Get __tmp3129 5)) +(let __tmp3141 (Single __tmp3140)) +(let __tmp3142 (Concat __tmp3139 __tmp3141)) +(let __tmp3143 (Concat __tmp3137 __tmp3142)) +(let __tmp3144 (Concat __tmp3135 __tmp3143)) +(let __tmp3145 (Concat __tmp3133 __tmp3144)) +(let __tmp3146 (Concat __tmp3131 __tmp3145)) +(let __tmp3147 (DoWhile __tmp3016 __tmp3146)) +(let __tmp3148 (Get __tmp3147 1)) +(let __tmp3149 (Single __tmp3148)) +(let __tmp3150 (Get __tmp3147 0)) +(let __tmp3151 (Single __tmp3150)) +(let __tmp3152 (Concat __tmp3149 __tmp3151)) +(let __tmp3153 (Function "fmod" __tmp3001 __tmp2847 __tmp3152)) +(FunctionHasType "main" (TupleT (TCons (StateT) (TNil))) (TupleT (TCons (StateT) (TNil)))) +(FunctionHasType "init" (TupleT (TCons (PointerT (FloatT)) (TCons (PointerT (FloatT)) (TCons (PointerT (FloatT)) (TCons (PointerT (FloatT)) (TCons (IntT) (TCons (FloatT) (TCons (IntT) (TCons (FloatT) (TCons (IntT) (TCons (FloatT) (TCons (IntT) (TCons (FloatT) (TCons (StateT) (TNil))))))))))))))) (TupleT (TCons (StateT) (TNil)))) +(FunctionHasType "matrix_new" (TupleT (TCons (IntT) (TCons (IntT) (TCons (StateT) (TNil))))) (TupleT (TCons (PointerT (FloatT)) (TCons (StateT) (TNil))))) +(FunctionHasType "matrix_loc" (TupleT (TCons (PointerT (FloatT)) (TCons (IntT) (TCons (IntT) (TCons (IntT) (TCons (StateT) (TNil))))))) (TupleT (TCons (PointerT (FloatT)) (TCons (StateT) (TNil))))) +(FunctionHasType "matrix_get" (TupleT (TCons (PointerT (FloatT)) (TCons (IntT) (TCons (IntT) (TCons (IntT) (TCons (StateT) (TNil))))))) (TupleT (TCons (FloatT) (TCons (StateT) (TNil))))) +(FunctionHasType "matrix_set" (TupleT (TCons (PointerT (FloatT)) (TCons (IntT) (TCons (IntT) (TCons (IntT) (TCons (FloatT) (TCons (StateT) (TNil)))))))) (TupleT (TCons (StateT) (TNil)))) +(FunctionHasType "matrix_incr" (TupleT (TCons (PointerT (FloatT)) (TCons (IntT) (TCons (IntT) (TCons (IntT) (TCons (FloatT) (TCons (StateT) (TNil)))))))) (TupleT (TCons (StateT) (TNil)))) +(FunctionHasType "matrix_scale" (TupleT (TCons (PointerT (FloatT)) (TCons (IntT) (TCons (IntT) (TCons (IntT) (TCons (FloatT) (TCons (StateT) (TNil)))))))) (TupleT (TCons (StateT) (TNil)))) +(FunctionHasType "matrix_sum" (TupleT (TCons (PointerT (FloatT)) (TCons (IntT) (TCons (IntT) (TCons (StateT) (TNil)))))) (TupleT (TCons (FloatT) (TCons (StateT) (TNil))))) +(FunctionHasType "fmod" (TupleT (TCons (FloatT) (TCons (FloatT) (TCons (StateT) (TNil))))) (TupleT (TCons (FloatT) (TCons (StateT) (TNil))))) + + + ; Loop context unions + + + ; Function inlining unions + +) :ruleset initialization) +(run initialization 1) + +; Schedule + +(run-schedule + (repeat 3 + + ;; optimization rules use always-run helpers like SubTuple + ;; These should be resolved before substitution + + (saturate + (saturate + (saturate type-helpers) + type-analysis) + (saturate + (saturate type-helpers) + always-run) + error-checking) + + ;; Substitution doesn't necessarily saturate if run multiple times, since + ;; dead code can enable infinite new substitutions. + ;; We run in 5 times, so no rules can do more than 5 substitutions. + (repeat 5 + (saturate + (saturate type-helpers) + type-analysis) + + ;; check which eclasses are resolved + (saturate is-resolved) + (saturate term-subst) + ;; do substutition for one round, subsuming as we go + (saturate subst) + ;; apply the equalities found + apply-subst-unions + + ;; add context + (saturate context) + (saturate drop) + apply-drop-unions + cleanup-drop + ) + + (saturate + (saturate type-helpers) + type-analysis) + (saturate is-resolved) + + ;; similar to substitution, run term-related things + (saturate + terms + (saturate + terms-helpers + (saturate terms-helpers-helpers))) + + ;; run type checking and indexing again + ;; for newly created terms from substitution + + (saturate + (saturate + (saturate type-helpers) + type-analysis) + (saturate + (saturate type-helpers) + always-run) + error-checking) + + ;; canonicalization and analysis + (saturate canon) + (saturate interval-analysis) + (saturate mem-simple) + + ;; cicm index + (saturate cicm-index) + + ;; TODO right now we don't run memory-helpers, we run mem-simple instead + + ;; finally, subsume now that helpers are done + subsume-after-helpers + + ;; do a boundary analysis for loop invariant code motion + boundary-analysis-prep + ;; set which expression to hoist (see evil hack in loop_invariant.egg) + boundary-analysis + + loop-iters-analysis + + passthrough + state-edge-passthrough) + (repeat 2 + + ;; optimization rules use always-run helpers like SubTuple + ;; These should be resolved before substitution + + (saturate + (saturate + (saturate type-helpers) + type-analysis) + (saturate + (saturate type-helpers) + always-run) + error-checking) + + ;; Substitution doesn't necessarily saturate if run multiple times, since + ;; dead code can enable infinite new substitutions. + ;; We run in 5 times, so no rules can do more than 5 substitutions. + (repeat 5 + (saturate + (saturate type-helpers) + type-analysis) + + ;; check which eclasses are resolved + (saturate is-resolved) + (saturate term-subst) + ;; do substutition for one round, subsuming as we go + (saturate subst) + ;; apply the equalities found + apply-subst-unions + + ;; add context + (saturate context) + (saturate drop) + apply-drop-unions + cleanup-drop + ) + + (saturate + (saturate type-helpers) + type-analysis) + (saturate is-resolved) + + ;; similar to substitution, run term-related things + (saturate + terms + (saturate + terms-helpers + (saturate terms-helpers-helpers))) + + ;; run type checking and indexing again + ;; for newly created terms from substitution + + (saturate + (saturate + (saturate type-helpers) + type-analysis) + (saturate + (saturate type-helpers) + always-run) + error-checking) + + ;; canonicalization and analysis + (saturate canon) + (saturate interval-analysis) + (saturate mem-simple) + + ;; cicm index + (saturate cicm-index) + + ;; TODO right now we don't run memory-helpers, we run mem-simple instead + + ;; finally, subsume now that helpers are done + subsume-after-helpers + + ;; do a boundary analysis for loop invariant code motion + boundary-analysis-prep + ;; set which expression to hoist (see evil hack in loop_invariant.egg) + boundary-analysis + + loop-iters-analysis + + swap-if) + + ;; optimization rules use always-run helpers like SubTuple + ;; These should be resolved before substitution + + (saturate + (saturate + (saturate type-helpers) + type-analysis) + (saturate + (saturate type-helpers) + always-run) + error-checking) + + ;; Substitution doesn't necessarily saturate if run multiple times, since + ;; dead code can enable infinite new substitutions. + ;; We run in 5 times, so no rules can do more than 5 substitutions. + (repeat 5 + (saturate + (saturate type-helpers) + type-analysis) + + ;; check which eclasses are resolved + (saturate is-resolved) + (saturate term-subst) + ;; do substutition for one round, subsuming as we go + (saturate subst) + ;; apply the equalities found + apply-subst-unions + + ;; add context + (saturate context) + (saturate drop) + apply-drop-unions + cleanup-drop + ) + + (saturate + (saturate type-helpers) + type-analysis) + (saturate is-resolved) + + ;; similar to substitution, run term-related things + (saturate + terms + (saturate + terms-helpers + (saturate terms-helpers-helpers))) + + ;; run type checking and indexing again + ;; for newly created terms from substitution + + (saturate + (saturate + (saturate type-helpers) + type-analysis) + (saturate + (saturate type-helpers) + always-run) + error-checking) + + ;; canonicalization and analysis + (saturate canon) + (saturate interval-analysis) + (saturate mem-simple) + + ;; cicm index + (saturate cicm-index) + + ;; TODO right now we don't run memory-helpers, we run mem-simple instead + + ;; finally, subsume now that helpers are done + subsume-after-helpers + + ;; do a boundary analysis for loop invariant code motion + boundary-analysis-prep + ;; set which expression to hoist (see evil hack in loop_invariant.egg) + boundary-analysis + + loop-iters-analysis + + rec-to-loop + + ;; optimization rules use always-run helpers like SubTuple + ;; These should be resolved before substitution + + (saturate + (saturate + (saturate type-helpers) + type-analysis) + (saturate + (saturate type-helpers) + always-run) + error-checking) + + ;; Substitution doesn't necessarily saturate if run multiple times, since + ;; dead code can enable infinite new substitutions. + ;; We run in 5 times, so no rules can do more than 5 substitutions. + (repeat 5 + (saturate + (saturate type-helpers) + type-analysis) + + ;; check which eclasses are resolved + (saturate is-resolved) + (saturate term-subst) + ;; do substutition for one round, subsuming as we go + (saturate subst) + ;; apply the equalities found + apply-subst-unions + + ;; add context + (saturate context) + (saturate drop) + apply-drop-unions + cleanup-drop + ) + + (saturate + (saturate type-helpers) + type-analysis) + (saturate is-resolved) + + ;; similar to substitution, run term-related things + (saturate + terms + (saturate + terms-helpers + (saturate terms-helpers-helpers))) + + ;; run type checking and indexing again + ;; for newly created terms from substitution + + (saturate + (saturate + (saturate type-helpers) + type-analysis) + (saturate + (saturate type-helpers) + always-run) + error-checking) + + ;; canonicalization and analysis + (saturate canon) + (saturate interval-analysis) + (saturate mem-simple) + + ;; cicm index + (saturate cicm-index) + + ;; TODO right now we don't run memory-helpers, we run mem-simple instead + + ;; finally, subsume now that helpers are done + subsume-after-helpers + + ;; do a boundary analysis for loop invariant code motion + boundary-analysis-prep + ;; set which expression to hoist (see evil hack in loop_invariant.egg) + boundary-analysis + + loop-iters-analysis +) + +; Benchmark-friendly query for the generated main function type fact. +; Proof snapshots are generated by running this fixture in proof-testing mode. +(check (FunctionHasType "main" (TupleT (TCons (StateT) (TNil))) (TupleT (TCons (StateT) (TNil))))) diff --git a/egglog-experimental/tests/proofs/unstable-fresh-proof.egg b/egglog-experimental/tests/proofs/unstable-fresh-proof.egg new file mode 100644 index 0000000..d391c9b --- /dev/null +++ b/egglog-experimental/tests/proofs/unstable-fresh-proof.egg @@ -0,0 +1,11 @@ +(datatype Math + (Let Math Math) + (Var String)) + +(rule ((Let a b)) + ((Let (unstable-fresh! Math) b))) + +(Let (Var "x") (Var "y")) +(run 1) + +(prove (Let ?a ?b)) diff --git a/egglog-experimental/tests/snapshots/files__proof_integration_eggcc_2mm_pass1_merge_old.snap b/egglog-experimental/tests/snapshots/files__proof_integration_eggcc_2mm_pass1_merge_old.snap new file mode 100644 index 0000000..ca1cc1f --- /dev/null +++ b/egglog-experimental/tests/snapshots/files__proof_integration_eggcc_2mm_pass1_merge_old.snap @@ -0,0 +1,3177 @@ +--- +source: egglog-experimental/tests/files.rs +expression: snapshot +--- +(let t0 (TupleT (TCons (StateT) (TNil)))) +(let t1 (FunctionHasType "main" t0 t0)) +(Rule + (= t1 t1) + (name + "(rule () + ((let __tmp0 (StateT)) + (let __tmp1 (TNil)) + (let __tmp2 (TCons __tmp0 __tmp1)) + (let __tmp3 (TupleT __tmp2)) + (let __tmp4 (Print)) + (let __tmp5 (Int 180)) + (let __tmp6 (InFunc 'dummy')) + (let __tmp7 (Const __tmp5 __tmp3 __tmp6)) + (let __tmp8 (Single __tmp7)) + (let __tmp9 (Int 190)) + (let __tmp10 (Const __tmp9 __tmp3 __tmp6)) + (let __tmp11 (Single __tmp10)) + (let __tmp12 (Int 210)) + (let __tmp13 (Const __tmp12 __tmp3 __tmp6)) + (let __tmp14 (Single __tmp13)) + (let __tmp15 (Arg __tmp3 __tmp6)) + (let __tmp16 (Get __tmp15 0)) + (let __tmp17 (Single __tmp16)) + (let __tmp18 (Concat __tmp14 __tmp17)) + (let __tmp19 (Concat __tmp8 __tmp18)) + (let __tmp20 (Call 'matrix_new' __tmp19)) + (let __tmp21 (Get __tmp20 0)) + (let __tmp22 (Single __tmp21)) + (let __tmp23 (Get __tmp20 1)) + (let __tmp24 (Single __tmp23)) + (let __tmp25 (Concat __tmp11 __tmp24)) + (let __tmp26 (Concat __tmp14 __tmp25)) + (let __tmp27 (Call 'matrix_new' __tmp26)) + (let __tmp28 (Get __tmp27 0)) + (let __tmp29 (Single __tmp28)) + (let __tmp30 (Int 220)) + (let __tmp31 (Const __tmp30 __tmp3 __tmp6)) + (let __tmp32 (Single __tmp31)) + (let __tmp33 (Get __tmp27 1)) + (let __tmp34 (Single __tmp33)) + (let __tmp35 (Concat __tmp32 __tmp34)) + (let __tmp36 (Concat __tmp11 __tmp35)) + (let __tmp37 (Call 'matrix_new' __tmp36)) + (let __tmp38 (Get __tmp37 0)) + (let __tmp39 (Single __tmp38)) + (let __tmp40 (Get __tmp37 1)) + (let __tmp41 (Single __tmp40)) + (let __tmp42 (Concat __tmp32 __tmp41)) + (let __tmp43 (Concat __tmp8 __tmp42)) + (let __tmp44 (Call 'matrix_new' __tmp43)) + (let __tmp45 (Get __tmp44 0)) + (let __tmp46 (Single __tmp45)) + (let __tmp47 (Float 180.0)) + (let __tmp48 (Const __tmp47 __tmp3 __tmp6)) + (let __tmp49 (Single __tmp48)) + (let __tmp50 (Float 190.0)) + (let __tmp51 (Const __tmp50 __tmp3 __tmp6)) + (let __tmp52 (Single __tmp51)) + (let __tmp53 (Float 210.0)) + (let __tmp54 (Const __tmp53 __tmp3 __tmp6)) + (let __tmp55 (Single __tmp54)) + (let __tmp56 (Float 220.0)) + (let __tmp57 (Const __tmp56 __tmp3 __tmp6)) + (let __tmp58 (Single __tmp57)) + (let __tmp59 (Get __tmp44 1)) + (let __tmp60 (Single __tmp59)) + (let __tmp61 (Concat __tmp58 __tmp60)) + (let __tmp62 (Concat __tmp32 __tmp61)) + (let __tmp63 (Concat __tmp55 __tmp62)) + (let __tmp64 (Concat __tmp14 __tmp63)) + (let __tmp65 (Concat __tmp52 __tmp64)) + (let __tmp66 (Concat __tmp11 __tmp65)) + (let __tmp67 (Concat __tmp49 __tmp66)) + (let __tmp68 (Concat __tmp8 __tmp67)) + (let __tmp69 (Concat __tmp46 __tmp68)) + (let __tmp70 (Concat __tmp39 __tmp69)) + (let __tmp71 (Concat __tmp29 __tmp70)) + (let __tmp72 (Concat __tmp22 __tmp71)) + (let __tmp73 (Call 'init' __tmp72)) + (let __tmp74 (Get __tmp73 0)) + (let __tmp75 (Single __tmp74)) + (let __tmp76 (Concat __tmp11 __tmp75)) + (let __tmp77 (Concat __tmp8 __tmp76)) + (let __tmp78 (Call 'matrix_new' __tmp77)) + (let __tmp79 (Get __tmp78 1)) + (let __tmp80 (Single __tmp79)) + (let __tmp81 (Get __tmp78 0)) + (let __tmp82 (Single __tmp81)) + (let __tmp83 (Int 0)) + (let __tmp84 (Const __tmp83 __tmp3 __tmp6)) + (let __tmp85 (Single __tmp84)) + (let __tmp86 (Int 1)) + (let __tmp87 (Const __tmp86 __tmp3 __tmp6)) + (let __tmp88 (Single __tmp87)) + (let __tmp89 (Float 1.2)) + (let __tmp90 (Const __tmp89 __tmp3 __tmp6)) + (let __tmp91 (Single __tmp90)) + (let __tmp92 (Float 1.5)) + (let __tmp93 (Const __tmp92 __tmp3 __tmp6)) + (let __tmp94 (Single __tmp93)) + (let __tmp95 (Float 0.0)) + (let __tmp96 (Const __tmp95 __tmp3 __tmp6)) + (let __tmp97 (Single __tmp96)) + (let __tmp98 (Concat __tmp14 __tmp97)) + (let __tmp99 (Concat __tmp94 __tmp98)) + (let __tmp100 (Concat __tmp91 __tmp99)) + (let __tmp101 (Concat __tmp11 __tmp100)) + (let __tmp102 (Concat __tmp88 __tmp101)) + (let __tmp103 (Concat __tmp85 __tmp102)) + (let __tmp104 (Concat __tmp32 __tmp103)) + (let __tmp105 (Concat __tmp8 __tmp104)) + (let __tmp106 (Concat __tmp22 __tmp105)) + (let __tmp107 (Concat __tmp29 __tmp106)) + (let __tmp108 (Concat __tmp39 __tmp107)) + (let __tmp109 (Concat __tmp46 __tmp108)) + (let __tmp110 (Concat __tmp82 __tmp109)) + (let __tmp111 (Concat __tmp80 __tmp110)) + (let __tmp112 (LessThan)) + (let __tmp113 (FloatT)) + (let __tmp114 (PointerT __tmp113)) + (let __tmp115 (IntT)) + (let __tmp116 (TCons __tmp113 __tmp1)) + (let __tmp117 (TCons __tmp115 __tmp116)) + (let __tmp118 (TCons __tmp113 __tmp117)) + (let __tmp119 (TCons __tmp113 __tmp118)) + (let __tmp120 (TCons __tmp115 __tmp119)) + (let __tmp121 (TCons __tmp115 __tmp120)) + (let __tmp122 (TCons __tmp115 __tmp121)) + (let __tmp123 (TCons __tmp115 __tmp122)) + (let __tmp124 (TCons __tmp115 __tmp123)) + (let __tmp125 (TCons __tmp114 __tmp124)) + (let __tmp126 (TCons __tmp114 __tmp125)) + (let __tmp127 (TCons __tmp114 __tmp126)) + (let __tmp128 (TCons __tmp114 __tmp127)) + (let __tmp129 (TCons __tmp114 __tmp128)) + (let __tmp130 (TCons __tmp0 __tmp129)) + (let __tmp131 (TupleT __tmp130)) + (let __tmp132 (Arg __tmp131 __tmp6)) + (let __tmp133 (Get __tmp132 8)) + (let __tmp134 (Get __tmp132 6)) + (let __tmp135 (Bop __tmp112 __tmp133 __tmp134)) + (let __tmp136 (Get __tmp132 0)) + (let __tmp137 (Single __tmp136)) + (let __tmp138 (Get __tmp132 1)) + (let __tmp139 (Single __tmp138)) + (let __tmp140 (Get __tmp132 2)) + (let __tmp141 (Single __tmp140)) + (let __tmp142 (Get __tmp132 3)) + (let __tmp143 (Single __tmp142)) + (let __tmp144 (Get __tmp132 4)) + (let __tmp145 (Single __tmp144)) + (let __tmp146 (Get __tmp132 5)) + (let __tmp147 (Single __tmp146)) + (let __tmp148 (Single __tmp134)) + (let __tmp149 (Get __tmp132 7)) + (let __tmp150 (Single __tmp149)) + (let __tmp151 (Single __tmp133)) + (let __tmp152 (Get __tmp132 9)) + (let __tmp153 (Single __tmp152)) + (let __tmp154 (Get __tmp132 10)) + (let __tmp155 (Single __tmp154)) + (let __tmp156 (Get __tmp132 11)) + (let __tmp157 (Single __tmp156)) + (let __tmp158 (Get __tmp132 12)) + (let __tmp159 (Single __tmp158)) + (let __tmp160 (Get __tmp132 13)) + (let __tmp161 (Single __tmp160)) + (let __tmp162 (Get __tmp132 14)) + (let __tmp163 (Single __tmp162)) + (let __tmp164 (Concat __tmp161 __tmp163)) + (let __tmp165 (Concat __tmp159 __tmp164)) + (let __tmp166 (Concat __tmp157 __tmp165)) + (let __tmp167 (Concat __tmp155 __tmp166)) + (let __tmp168 (Concat __tmp153 __tmp167)) + (let __tmp169 (Concat __tmp151 __tmp168)) + (let __tmp170 (Concat __tmp150 __tmp169)) + (let __tmp171 (Concat __tmp148 __tmp170)) + (let __tmp172 (Concat __tmp147 __tmp171)) + (let __tmp173 (Concat __tmp145 __tmp172)) + (let __tmp174 (Concat __tmp143 __tmp173)) + (let __tmp175 (Concat __tmp141 __tmp174)) + (let __tmp176 (Concat __tmp139 __tmp175)) + (let __tmp177 (Concat __tmp137 __tmp176)) + (let __tmp178 (Const __tmp83 __tmp131 __tmp6)) + (let __tmp179 (Single __tmp178)) + (let __tmp180 (Concat __tmp179 __tmp167)) + (let __tmp181 (Concat __tmp153 __tmp180)) + (let __tmp182 (Concat __tmp151 __tmp181)) + (let __tmp183 (Concat __tmp150 __tmp182)) + (let __tmp184 (Concat __tmp148 __tmp183)) + (let __tmp185 (Concat __tmp147 __tmp184)) + (let __tmp186 (Concat __tmp145 __tmp185)) + (let __tmp187 (Concat __tmp143 __tmp186)) + (let __tmp188 (Concat __tmp141 __tmp187)) + (let __tmp189 (Concat __tmp139 __tmp188)) + (let __tmp190 (Concat __tmp137 __tmp189)) + (let __tmp191 (TCons __tmp115 __tmp124)) + (let __tmp192 (TCons __tmp114 __tmp191)) + (let __tmp193 (TCons __tmp114 __tmp192)) + (let __tmp194 (TCons __tmp114 __tmp193)) + (let __tmp195 (TCons __tmp114 __tmp194)) + (let __tmp196 (TCons __tmp114 __tmp195)) + (let __tmp197 (TCons __tmp0 __tmp196)) + (let __tmp198 (TupleT __tmp197)) + (let __tmp199 (Arg __tmp198 __tmp6)) + (let __tmp200 (Get __tmp199 10)) + (let __tmp201 (Get __tmp199 11)) + (let __tmp202 (Bop __tmp112 __tmp200 __tmp201)) + (let __tmp203 (Get __tmp199 0)) + (let __tmp204 (Single __tmp203)) + (let __tmp205 (Get __tmp199 1)) + (let __tmp206 (Single __tmp205)) + (let __tmp207 (Get __tmp199 2)) + (let __tmp208 (Single __tmp207)) + (let __tmp209 (Get __tmp199 3)) + (let __tmp210 (Single __tmp209)) + (let __tmp211 (Get __tmp199 4)) + (let __tmp212 (Single __tmp211)) + (let __tmp213 (Get __tmp199 5)) + (let __tmp214 (Single __tmp213)) + (let __tmp215 (Get __tmp199 6)) + (let __tmp216 (Single __tmp215)) + (let __tmp217 (Get __tmp199 7)) + (let __tmp218 (Single __tmp217)) + (let __tmp219 (Get __tmp199 8)) + (let __tmp220 (Single __tmp219)) + (let __tmp221 (Get __tmp199 9)) + (let __tmp222 (Single __tmp221)) + (let __tmp223 (Single __tmp200)) + (let __tmp224 (Single __tmp201)) + (let __tmp225 (Get __tmp199 12)) + (let __tmp226 (Single __tmp225)) + (let __tmp227 (Get __tmp199 13)) + (let __tmp228 (Single __tmp227)) + (let __tmp229 (Get __tmp199 14)) + (let __tmp230 (Single __tmp229)) + (let __tmp231 (Get __tmp199 15)) + (let __tmp232 (Single __tmp231)) + (let __tmp233 (Concat __tmp230 __tmp232)) + (let __tmp234 (Concat __tmp228 __tmp233)) + (let __tmp235 (Concat __tmp226 __tmp234)) + (let __tmp236 (Concat __tmp224 __tmp235)) + (let __tmp237 (Concat __tmp223 __tmp236)) + (let __tmp238 (Concat __tmp222 __tmp237)) + (let __tmp239 (Concat __tmp220 __tmp238)) + (let __tmp240 (Concat __tmp218 __tmp239)) + (let __tmp241 (Concat __tmp216 __tmp240)) + (let __tmp242 (Concat __tmp214 __tmp241)) + (let __tmp243 (Concat __tmp212 __tmp242)) + (let __tmp244 (Concat __tmp210 __tmp243)) + (let __tmp245 (Concat __tmp208 __tmp244)) + (let __tmp246 (Concat __tmp206 __tmp245)) + (let __tmp247 (Concat __tmp204 __tmp246)) + (let __tmp248 (Concat __tmp232 __tmp204)) + (let __tmp249 (Concat __tmp224 __tmp248)) + (let __tmp250 (Concat __tmp223 __tmp249)) + (let __tmp251 (Concat __tmp220 __tmp250)) + (let __tmp252 (Concat __tmp206 __tmp251)) + (let __tmp253 (Call 'matrix_set' __tmp252)) + (let __tmp254 (Get __tmp253 0)) + (let __tmp255 (Single __tmp254)) + (let __tmp256 (Const __tmp83 __tmp198 __tmp6)) + (let __tmp257 (Single __tmp256)) + (let __tmp258 (Concat __tmp257 __tmp236)) + (let __tmp259 (Concat __tmp223 __tmp258)) + (let __tmp260 (Concat __tmp222 __tmp259)) + (let __tmp261 (Concat __tmp220 __tmp260)) + (let __tmp262 (Concat __tmp218 __tmp261)) + (let __tmp263 (Concat __tmp216 __tmp262)) + (let __tmp264 (Concat __tmp214 __tmp263)) + (let __tmp265 (Concat __tmp212 __tmp264)) + (let __tmp266 (Concat __tmp210 __tmp265)) + (let __tmp267 (Concat __tmp208 __tmp266)) + (let __tmp268 (Concat __tmp206 __tmp267)) + (let __tmp269 (Concat __tmp255 __tmp268)) + (let __tmp270 (TCons __tmp115 __tmp191)) + (let __tmp271 (TCons __tmp114 __tmp270)) + (let __tmp272 (TCons __tmp114 __tmp271)) + (let __tmp273 (TCons __tmp114 __tmp272)) + (let __tmp274 (TCons __tmp114 __tmp273)) + (let __tmp275 (TCons __tmp114 __tmp274)) + (let __tmp276 (TCons __tmp0 __tmp275)) + (let __tmp277 (TupleT __tmp276)) + (let __tmp278 (Arg __tmp277 __tmp6)) + (let __tmp279 (Get __tmp278 11)) + (let __tmp280 (Get __tmp278 15)) + (let __tmp281 (Bop __tmp112 __tmp279 __tmp280)) + (let __tmp282 (Get __tmp278 0)) + (let __tmp283 (Single __tmp282)) + (let __tmp284 (Get __tmp278 1)) + (let __tmp285 (Single __tmp284)) + (let __tmp286 (Get __tmp278 2)) + (let __tmp287 (Single __tmp286)) + (let __tmp288 (Get __tmp278 3)) + (let __tmp289 (Single __tmp288)) + (let __tmp290 (Get __tmp278 4)) + (let __tmp291 (Single __tmp290)) + (let __tmp292 (Get __tmp278 5)) + (let __tmp293 (Single __tmp292)) + (let __tmp294 (Get __tmp278 6)) + (let __tmp295 (Single __tmp294)) + (let __tmp296 (Get __tmp278 7)) + (let __tmp297 (Single __tmp296)) + (let __tmp298 (Get __tmp278 8)) + (let __tmp299 (Single __tmp298)) + (let __tmp300 (Get __tmp278 9)) + (let __tmp301 (Single __tmp300)) + (let __tmp302 (Get __tmp278 10)) + (let __tmp303 (Single __tmp302)) + (let __tmp304 (Single __tmp279)) + (let __tmp305 (Get __tmp278 12)) + (let __tmp306 (Single __tmp305)) + (let __tmp307 (Get __tmp278 13)) + (let __tmp308 (Single __tmp307)) + (let __tmp309 (Get __tmp278 14)) + (let __tmp310 (Single __tmp309)) + (let __tmp311 (Single __tmp280)) + (let __tmp312 (Get __tmp278 16)) + (let __tmp313 (Single __tmp312)) + (let __tmp314 (Concat __tmp311 __tmp313)) + (let __tmp315 (Concat __tmp310 __tmp314)) + (let __tmp316 (Concat __tmp308 __tmp315)) + (let __tmp317 (Concat __tmp306 __tmp316)) + (let __tmp318 (Concat __tmp304 __tmp317)) + (let __tmp319 (Concat __tmp303 __tmp318)) + (let __tmp320 (Concat __tmp301 __tmp319)) + (let __tmp321 (Concat __tmp299 __tmp320)) + (let __tmp322 (Concat __tmp297 __tmp321)) + (let __tmp323 (Concat __tmp295 __tmp322)) + (let __tmp324 (Concat __tmp293 __tmp323)) + (let __tmp325 (Concat __tmp291 __tmp324)) + (let __tmp326 (Concat __tmp289 __tmp325)) + (let __tmp327 (Concat __tmp287 __tmp326)) + (let __tmp328 (Concat __tmp285 __tmp327)) + (let __tmp329 (Concat __tmp283 __tmp328)) + (let __tmp330 (FMul)) + (let __tmp331 (Concat __tmp311 __tmp283)) + (let __tmp332 (Concat __tmp304 __tmp331)) + (let __tmp333 (Concat __tmp299 __tmp332)) + (let __tmp334 (Concat __tmp293 __tmp333)) + (let __tmp335 (Call 'matrix_get' __tmp334)) + (let __tmp336 (Get __tmp335 0)) + (let __tmp337 (Bop __tmp330 __tmp309 __tmp336)) + (let __tmp338 (Get __tmp335 1)) + (let __tmp339 (Single __tmp338)) + (let __tmp340 (Concat __tmp306 __tmp339)) + (let __tmp341 (Concat __tmp303 __tmp340)) + (let __tmp342 (Concat __tmp304 __tmp341)) + (let __tmp343 (Concat __tmp291 __tmp342)) + (let __tmp344 (Call 'matrix_get' __tmp343)) + (let __tmp345 (Get __tmp344 0)) + (let __tmp346 (Bop __tmp330 __tmp337 __tmp345)) + (let __tmp347 (Single __tmp346)) + (let __tmp348 (Get __tmp344 1)) + (let __tmp349 (Single __tmp348)) + (let __tmp350 (Concat __tmp347 __tmp349)) + (let __tmp351 (Concat __tmp306 __tmp350)) + (let __tmp352 (Concat __tmp303 __tmp351)) + (let __tmp353 (Concat __tmp299 __tmp352)) + (let __tmp354 (Concat __tmp285 __tmp353)) + (let __tmp355 (Call 'matrix_incr' __tmp354)) + (let __tmp356 (Get __tmp355 0)) + (let __tmp357 (Single __tmp356)) + (let __tmp358 (Add)) + (let __tmp359 (Bop __tmp358 __tmp279 __tmp300)) + (let __tmp360 (Single __tmp359)) + (let __tmp361 (Bool true)) + (let __tmp362 (Const __tmp361 __tmp277 __tmp6)) + (let __tmp363 (Single __tmp362)) + (let __tmp364 (Concat __tmp363 __tmp315)) + (let __tmp365 (Concat __tmp308 __tmp364)) + (let __tmp366 (Concat __tmp306 __tmp365)) + (let __tmp367 (Concat __tmp360 __tmp366)) + (let __tmp368 (Concat __tmp303 __tmp367)) + (let __tmp369 (Concat __tmp301 __tmp368)) + (let __tmp370 (Concat __tmp299 __tmp369)) + (let __tmp371 (Concat __tmp297 __tmp370)) + (let __tmp372 (Concat __tmp295 __tmp371)) + (let __tmp373 (Concat __tmp293 __tmp372)) + (let __tmp374 (Concat __tmp291 __tmp373)) + (let __tmp375 (Concat __tmp289 __tmp374)) + (let __tmp376 (Concat __tmp287 __tmp375)) + (let __tmp377 (Concat __tmp285 __tmp376)) + (let __tmp378 (Concat __tmp357 __tmp377)) + (let __tmp379 (Bool false)) + (let __tmp380 (Const __tmp379 __tmp277 __tmp6)) + (let __tmp381 (Single __tmp380)) + (let __tmp382 (Concat __tmp381 __tmp315)) + (let __tmp383 (Concat __tmp308 __tmp382)) + (let __tmp384 (Concat __tmp306 __tmp383)) + (let __tmp385 (Concat __tmp304 __tmp384)) + (let __tmp386 (Concat __tmp303 __tmp385)) + (let __tmp387 (Concat __tmp301 __tmp386)) + (let __tmp388 (Concat __tmp299 __tmp387)) + (let __tmp389 (Concat __tmp297 __tmp388)) + (let __tmp390 (Concat __tmp295 __tmp389)) + (let __tmp391 (Concat __tmp293 __tmp390)) + (let __tmp392 (Concat __tmp291 __tmp391)) + (let __tmp393 (Concat __tmp289 __tmp392)) + (let __tmp394 (Concat __tmp287 __tmp393)) + (let __tmp395 (Concat __tmp285 __tmp394)) + (let __tmp396 (Concat __tmp283 __tmp395)) + (let __tmp397 (If __tmp281 __tmp329 __tmp378 __tmp396)) + (let __tmp398 (Get __tmp397 14)) + (let __tmp399 (Single __tmp398)) + (let __tmp400 (Get __tmp397 0)) + (let __tmp401 (Single __tmp400)) + (let __tmp402 (Get __tmp397 1)) + (let __tmp403 (Single __tmp402)) + (let __tmp404 (Get __tmp397 2)) + (let __tmp405 (Single __tmp404)) + (let __tmp406 (Get __tmp397 3)) + (let __tmp407 (Single __tmp406)) + (let __tmp408 (Get __tmp397 4)) + (let __tmp409 (Single __tmp408)) + (let __tmp410 (Get __tmp397 5)) + (let __tmp411 (Single __tmp410)) + (let __tmp412 (Get __tmp397 6)) + (let __tmp413 (Single __tmp412)) + (let __tmp414 (Get __tmp397 7)) + (let __tmp415 (Single __tmp414)) + (let __tmp416 (Get __tmp397 8)) + (let __tmp417 (Single __tmp416)) + (let __tmp418 (Get __tmp397 9)) + (let __tmp419 (Single __tmp418)) + (let __tmp420 (Get __tmp397 10)) + (let __tmp421 (Single __tmp420)) + (let __tmp422 (Get __tmp397 11)) + (let __tmp423 (Single __tmp422)) + (let __tmp424 (Get __tmp397 12)) + (let __tmp425 (Single __tmp424)) + (let __tmp426 (Get __tmp397 13)) + (let __tmp427 (Single __tmp426)) + (let __tmp428 (Get __tmp397 15)) + (let __tmp429 (Single __tmp428)) + (let __tmp430 (Get __tmp397 16)) + (let __tmp431 (Single __tmp430)) + (let __tmp432 (Get __tmp397 17)) + (let __tmp433 (Single __tmp432)) + (let __tmp434 (Concat __tmp431 __tmp433)) + (let __tmp435 (Concat __tmp429 __tmp434)) + (let __tmp436 (Concat __tmp427 __tmp435)) + (let __tmp437 (Concat __tmp425 __tmp436)) + (let __tmp438 (Concat __tmp423 __tmp437)) + (let __tmp439 (Concat __tmp421 __tmp438)) + (let __tmp440 (Concat __tmp419 __tmp439)) + (let __tmp441 (Concat __tmp417 __tmp440)) + (let __tmp442 (Concat __tmp415 __tmp441)) + (let __tmp443 (Concat __tmp413 __tmp442)) + (let __tmp444 (Concat __tmp411 __tmp443)) + (let __tmp445 (Concat __tmp409 __tmp444)) + (let __tmp446 (Concat __tmp407 __tmp445)) + (let __tmp447 (Concat __tmp405 __tmp446)) + (let __tmp448 (Concat __tmp403 __tmp447)) + (let __tmp449 (Concat __tmp401 __tmp448)) + (let __tmp450 (Concat __tmp399 __tmp449)) + (let __tmp451 (DoWhile __tmp269 __tmp450)) + (let __tmp452 (Get __tmp451 0)) + (let __tmp453 (Single __tmp452)) + (let __tmp454 (Get __tmp451 1)) + (let __tmp455 (Single __tmp454)) + (let __tmp456 (Get __tmp451 2)) + (let __tmp457 (Single __tmp456)) + (let __tmp458 (Get __tmp451 3)) + (let __tmp459 (Single __tmp458)) + (let __tmp460 (Get __tmp451 4)) + (let __tmp461 (Single __tmp460)) + (let __tmp462 (Get __tmp451 5)) + (let __tmp463 (Single __tmp462)) + (let __tmp464 (Get __tmp451 6)) + (let __tmp465 (Single __tmp464)) + (let __tmp466 (Get __tmp451 7)) + (let __tmp467 (Single __tmp466)) + (let __tmp468 (Get __tmp451 8)) + (let __tmp469 (Single __tmp468)) + (let __tmp470 (Get __tmp451 9)) + (let __tmp471 (Single __tmp470)) + (let __tmp472 (Get __tmp451 10)) + (let __tmp473 (Bop __tmp358 __tmp472 __tmp470)) + (let __tmp474 (Single __tmp473)) + (let __tmp475 (Get __tmp451 12)) + (let __tmp476 (Single __tmp475)) + (let __tmp477 (Get __tmp451 13)) + (let __tmp478 (Single __tmp477)) + (let __tmp479 (Const __tmp361 __tmp198 __tmp6)) + (let __tmp480 (Single __tmp479)) + (let __tmp481 (Get __tmp451 14)) + (let __tmp482 (Single __tmp481)) + (let __tmp483 (Get __tmp451 15)) + (let __tmp484 (Single __tmp483)) + (let __tmp485 (Get __tmp451 16)) + (let __tmp486 (Single __tmp485)) + (let __tmp487 (Concat __tmp484 __tmp486)) + (let __tmp488 (Concat __tmp482 __tmp487)) + (let __tmp489 (Concat __tmp480 __tmp488)) + (let __tmp490 (Concat __tmp478 __tmp489)) + (let __tmp491 (Concat __tmp476 __tmp490)) + (let __tmp492 (Concat __tmp474 __tmp491)) + (let __tmp493 (Concat __tmp471 __tmp492)) + (let __tmp494 (Concat __tmp469 __tmp493)) + (let __tmp495 (Concat __tmp467 __tmp494)) + (let __tmp496 (Concat __tmp465 __tmp495)) + (let __tmp497 (Concat __tmp463 __tmp496)) + (let __tmp498 (Concat __tmp461 __tmp497)) + (let __tmp499 (Concat __tmp459 __tmp498)) + (let __tmp500 (Concat __tmp457 __tmp499)) + (let __tmp501 (Concat __tmp455 __tmp500)) + (let __tmp502 (Concat __tmp453 __tmp501)) + (let __tmp503 (Const __tmp379 __tmp198 __tmp6)) + (let __tmp504 (Single __tmp503)) + (let __tmp505 (Concat __tmp504 __tmp234)) + (let __tmp506 (Concat __tmp226 __tmp505)) + (let __tmp507 (Concat __tmp224 __tmp506)) + (let __tmp508 (Concat __tmp223 __tmp507)) + (let __tmp509 (Concat __tmp222 __tmp508)) + (let __tmp510 (Concat __tmp220 __tmp509)) + (let __tmp511 (Concat __tmp218 __tmp510)) + (let __tmp512 (Concat __tmp216 __tmp511)) + (let __tmp513 (Concat __tmp214 __tmp512)) + (let __tmp514 (Concat __tmp212 __tmp513)) + (let __tmp515 (Concat __tmp210 __tmp514)) + (let __tmp516 (Concat __tmp208 __tmp515)) + (let __tmp517 (Concat __tmp206 __tmp516)) + (let __tmp518 (Concat __tmp204 __tmp517)) + (let __tmp519 (If __tmp202 __tmp247 __tmp502 __tmp518)) + (let __tmp520 (Get __tmp519 13)) + (let __tmp521 (Single __tmp520)) + (let __tmp522 (Get __tmp519 0)) + (let __tmp523 (Single __tmp522)) + (let __tmp524 (Get __tmp519 1)) + (let __tmp525 (Single __tmp524)) + (let __tmp526 (Get __tmp519 2)) + (let __tmp527 (Single __tmp526)) + (let __tmp528 (Get __tmp519 3)) + (let __tmp529 (Single __tmp528)) + (let __tmp530 (Get __tmp519 4)) + (let __tmp531 (Single __tmp530)) + (let __tmp532 (Get __tmp519 5)) + (let __tmp533 (Single __tmp532)) + (let __tmp534 (Get __tmp519 6)) + (let __tmp535 (Single __tmp534)) + (let __tmp536 (Get __tmp519 7)) + (let __tmp537 (Single __tmp536)) + (let __tmp538 (Get __tmp519 8)) + (let __tmp539 (Single __tmp538)) + (let __tmp540 (Get __tmp519 9)) + (let __tmp541 (Single __tmp540)) + (let __tmp542 (Get __tmp519 10)) + (let __tmp543 (Single __tmp542)) + (let __tmp544 (Get __tmp519 11)) + (let __tmp545 (Single __tmp544)) + (let __tmp546 (Get __tmp519 12)) + (let __tmp547 (Single __tmp546)) + (let __tmp548 (Get __tmp519 14)) + (let __tmp549 (Single __tmp548)) + (let __tmp550 (Get __tmp519 15)) + (let __tmp551 (Single __tmp550)) + (let __tmp552 (Get __tmp519 16)) + (let __tmp553 (Single __tmp552)) + (let __tmp554 (Concat __tmp551 __tmp553)) + (let __tmp555 (Concat __tmp549 __tmp554)) + (let __tmp556 (Concat __tmp547 __tmp555)) + (let __tmp557 (Concat __tmp545 __tmp556)) + (let __tmp558 (Concat __tmp543 __tmp557)) + (let __tmp559 (Concat __tmp541 __tmp558)) + (let __tmp560 (Concat __tmp539 __tmp559)) + (let __tmp561 (Concat __tmp537 __tmp560)) + (let __tmp562 (Concat __tmp535 __tmp561)) + (let __tmp563 (Concat __tmp533 __tmp562)) + (let __tmp564 (Concat __tmp531 __tmp563)) + (let __tmp565 (Concat __tmp529 __tmp564)) + (let __tmp566 (Concat __tmp527 __tmp565)) + (let __tmp567 (Concat __tmp525 __tmp566)) + (let __tmp568 (Concat __tmp523 __tmp567)) + (let __tmp569 (Concat __tmp521 __tmp568)) + (let __tmp570 (DoWhile __tmp190 __tmp569)) + (let __tmp571 (Get __tmp570 0)) + (let __tmp572 (Single __tmp571)) + (let __tmp573 (Get __tmp570 1)) + (let __tmp574 (Single __tmp573)) + (let __tmp575 (Get __tmp570 2)) + (let __tmp576 (Single __tmp575)) + (let __tmp577 (Get __tmp570 3)) + (let __tmp578 (Single __tmp577)) + (let __tmp579 (Get __tmp570 4)) + (let __tmp580 (Single __tmp579)) + (let __tmp581 (Get __tmp570 5)) + (let __tmp582 (Single __tmp581)) + (let __tmp583 (Get __tmp570 6)) + (let __tmp584 (Single __tmp583)) + (let __tmp585 (Get __tmp570 7)) + (let __tmp586 (Single __tmp585)) + (let __tmp587 (Get __tmp570 8)) + (let __tmp588 (Get __tmp570 9)) + (let __tmp589 (Bop __tmp358 __tmp587 __tmp588)) + (let __tmp590 (Single __tmp589)) + (let __tmp591 (Single __tmp588)) + (let __tmp592 (Get __tmp570 11)) + (let __tmp593 (Single __tmp592)) + (let __tmp594 (Get __tmp570 12)) + (let __tmp595 (Single __tmp594)) + (let __tmp596 (Const __tmp361 __tmp131 __tmp6)) + (let __tmp597 (Single __tmp596)) + (let __tmp598 (Get __tmp570 13)) + (let __tmp599 (Single __tmp598)) + (let __tmp600 (Get __tmp570 14)) + (let __tmp601 (Single __tmp600)) + (let __tmp602 (Get __tmp570 15)) + (let __tmp603 (Single __tmp602)) + (let __tmp604 (Concat __tmp601 __tmp603)) + (let __tmp605 (Concat __tmp599 __tmp604)) + (let __tmp606 (Concat __tmp597 __tmp605)) + (let __tmp607 (Concat __tmp595 __tmp606)) + (let __tmp608 (Concat __tmp593 __tmp607)) + (let __tmp609 (Concat __tmp591 __tmp608)) + (let __tmp610 (Concat __tmp590 __tmp609)) + (let __tmp611 (Concat __tmp586 __tmp610)) + (let __tmp612 (Concat __tmp584 __tmp611)) + (let __tmp613 (Concat __tmp582 __tmp612)) + (let __tmp614 (Concat __tmp580 __tmp613)) + (let __tmp615 (Concat __tmp578 __tmp614)) + (let __tmp616 (Concat __tmp576 __tmp615)) + (let __tmp617 (Concat __tmp574 __tmp616)) + (let __tmp618 (Concat __tmp572 __tmp617)) + (let __tmp619 (Const __tmp379 __tmp131 __tmp6)) + (let __tmp620 (Single __tmp619)) + (let __tmp621 (Concat __tmp620 __tmp165)) + (let __tmp622 (Concat __tmp157 __tmp621)) + (let __tmp623 (Concat __tmp155 __tmp622)) + (let __tmp624 (Concat __tmp153 __tmp623)) + (let __tmp625 (Concat __tmp151 __tmp624)) + (let __tmp626 (Concat __tmp150 __tmp625)) + (let __tmp627 (Concat __tmp148 __tmp626)) + (let __tmp628 (Concat __tmp147 __tmp627)) + (let __tmp629 (Concat __tmp145 __tmp628)) + (let __tmp630 (Concat __tmp143 __tmp629)) + (let __tmp631 (Concat __tmp141 __tmp630)) + (let __tmp632 (Concat __tmp139 __tmp631)) + (let __tmp633 (Concat __tmp137 __tmp632)) + (let __tmp634 (If __tmp135 __tmp177 __tmp618 __tmp633)) + (let __tmp635 (Get __tmp634 12)) + (let __tmp636 (Single __tmp635)) + (let __tmp637 (Get __tmp634 0)) + (let __tmp638 (Single __tmp637)) + (let __tmp639 (Get __tmp634 1)) + (let __tmp640 (Single __tmp639)) + (let __tmp641 (Get __tmp634 2)) + (let __tmp642 (Single __tmp641)) + (let __tmp643 (Get __tmp634 3)) + (let __tmp644 (Single __tmp643)) + (let __tmp645 (Get __tmp634 4)) + (let __tmp646 (Single __tmp645)) + (let __tmp647 (Get __tmp634 5)) + (let __tmp648 (Single __tmp647)) + (let __tmp649 (Get __tmp634 6)) + (let __tmp650 (Single __tmp649)) + (let __tmp651 (Get __tmp634 7)) + (let __tmp652 (Single __tmp651)) + (let __tmp653 (Get __tmp634 8)) + (let __tmp654 (Single __tmp653)) + (let __tmp655 (Get __tmp634 9)) + (let __tmp656 (Single __tmp655)) + (let __tmp657 (Get __tmp634 10)) + (let __tmp658 (Single __tmp657)) + (let __tmp659 (Get __tmp634 11)) + (let __tmp660 (Single __tmp659)) + (let __tmp661 (Get __tmp634 13)) + (let __tmp662 (Single __tmp661)) + (let __tmp663 (Get __tmp634 14)) + (let __tmp664 (Single __tmp663)) + (let __tmp665 (Get __tmp634 15)) + (let __tmp666 (Single __tmp665)) + (let __tmp667 (Concat __tmp664 __tmp666)) + (let __tmp668 (Concat __tmp662 __tmp667)) + (let __tmp669 (Concat __tmp660 __tmp668)) + (let __tmp670 (Concat __tmp658 __tmp669)) + (let __tmp671 (Concat __tmp656 __tmp670)) + (let __tmp672 (Concat __tmp654 __tmp671)) + (let __tmp673 (Concat __tmp652 __tmp672)) + (let __tmp674 (Concat __tmp650 __tmp673)) + (let __tmp675 (Concat __tmp648 __tmp674)) + (let __tmp676 (Concat __tmp646 __tmp675)) + (let __tmp677 (Concat __tmp644 __tmp676)) + (let __tmp678 (Concat __tmp642 __tmp677)) + (let __tmp679 (Concat __tmp640 __tmp678)) + (let __tmp680 (Concat __tmp638 __tmp679)) + (let __tmp681 (Concat __tmp636 __tmp680)) + (let __tmp682 (DoWhile __tmp111 __tmp681)) + (let __tmp683 (Get __tmp682 0)) + (let __tmp684 (Single __tmp683)) + (let __tmp685 (Get __tmp682 1)) + (let __tmp686 (Single __tmp685)) + (let __tmp687 (Get __tmp682 2)) + (let __tmp688 (Single __tmp687)) + (let __tmp689 (Get __tmp682 3)) + (let __tmp690 (Single __tmp689)) + (let __tmp691 (Get __tmp682 4)) + (let __tmp692 (Single __tmp691)) + (let __tmp693 (Get __tmp682 5)) + (let __tmp694 (Single __tmp693)) + (let __tmp695 (Get __tmp682 6)) + (let __tmp696 (Single __tmp695)) + (let __tmp697 (Get __tmp682 7)) + (let __tmp698 (Single __tmp697)) + (let __tmp699 (Get __tmp682 9)) + (let __tmp700 (Single __tmp699)) + (let __tmp701 (Get __tmp682 10)) + (let __tmp702 (Single __tmp701)) + (let __tmp703 (Get __tmp682 11)) + (let __tmp704 (Single __tmp703)) + (let __tmp705 (Concat __tmp702 __tmp704)) + (let __tmp706 (Concat __tmp700 __tmp705)) + (let __tmp707 (Concat __tmp85 __tmp706)) + (let __tmp708 (Concat __tmp698 __tmp707)) + (let __tmp709 (Concat __tmp696 __tmp708)) + (let __tmp710 (Concat __tmp694 __tmp709)) + (let __tmp711 (Concat __tmp692 __tmp710)) + (let __tmp712 (Concat __tmp690 __tmp711)) + (let __tmp713 (Concat __tmp688 __tmp712)) + (let __tmp714 (Concat __tmp686 __tmp713)) + (let __tmp715 (Concat __tmp684 __tmp714)) + (let __tmp716 (TCons __tmp115 __tmp117)) + (let __tmp717 (TCons __tmp115 __tmp716)) + (let __tmp718 (TCons __tmp115 __tmp717)) + (let __tmp719 (TCons __tmp115 __tmp718)) + (let __tmp720 (TCons __tmp114 __tmp719)) + (let __tmp721 (TCons __tmp114 __tmp720)) + (let __tmp722 (TCons __tmp114 __tmp721)) + (let __tmp723 (TCons __tmp114 __tmp722)) + (let __tmp724 (TCons __tmp114 __tmp723)) + (let __tmp725 (TCons __tmp0 __tmp724)) + (let __tmp726 (TupleT __tmp725)) + (let __tmp727 (Arg __tmp726 __tmp6)) + (let __tmp728 (Get __tmp727 8)) + (let __tmp729 (Get __tmp727 6)) + (let __tmp730 (Bop __tmp112 __tmp728 __tmp729)) + (let __tmp731 (Get __tmp727 0)) + (let __tmp732 (Single __tmp731)) + (let __tmp733 (Get __tmp727 1)) + (let __tmp734 (Single __tmp733)) + (let __tmp735 (Get __tmp727 2)) + (let __tmp736 (Single __tmp735)) + (let __tmp737 (Get __tmp727 3)) + (let __tmp738 (Single __tmp737)) + (let __tmp739 (Get __tmp727 4)) + (let __tmp740 (Single __tmp739)) + (let __tmp741 (Get __tmp727 5)) + (let __tmp742 (Single __tmp741)) + (let __tmp743 (Single __tmp729)) + (let __tmp744 (Get __tmp727 7)) + (let __tmp745 (Single __tmp744)) + (let __tmp746 (Single __tmp728)) + (let __tmp747 (Get __tmp727 9)) + (let __tmp748 (Single __tmp747)) + (let __tmp749 (Get __tmp727 10)) + (let __tmp750 (Single __tmp749)) + (let __tmp751 (Get __tmp727 11)) + (let __tmp752 (Single __tmp751)) + (let __tmp753 (Concat __tmp750 __tmp752)) + (let __tmp754 (Concat __tmp748 __tmp753)) + (let __tmp755 (Concat __tmp746 __tmp754)) + (let __tmp756 (Concat __tmp745 __tmp755)) + (let __tmp757 (Concat __tmp743 __tmp756)) + (let __tmp758 (Concat __tmp742 __tmp757)) + (let __tmp759 (Concat __tmp740 __tmp758)) + (let __tmp760 (Concat __tmp738 __tmp759)) + (let __tmp761 (Concat __tmp736 __tmp760)) + (let __tmp762 (Concat __tmp734 __tmp761)) + (let __tmp763 (Concat __tmp732 __tmp762)) + (let __tmp764 (Const __tmp83 __tmp726 __tmp6)) + (let __tmp765 (Single __tmp764)) + (let __tmp766 (Concat __tmp765 __tmp753)) + (let __tmp767 (Concat __tmp748 __tmp766)) + (let __tmp768 (Concat __tmp746 __tmp767)) + (let __tmp769 (Concat __tmp745 __tmp768)) + (let __tmp770 (Concat __tmp743 __tmp769)) + (let __tmp771 (Concat __tmp742 __tmp770)) + (let __tmp772 (Concat __tmp740 __tmp771)) + (let __tmp773 (Concat __tmp738 __tmp772)) + (let __tmp774 (Concat __tmp736 __tmp773)) + (let __tmp775 (Concat __tmp734 __tmp774)) + (let __tmp776 (Concat __tmp732 __tmp775)) + (let __tmp777 (TCons __tmp115 __tmp719)) + (let __tmp778 (TCons __tmp114 __tmp777)) + (let __tmp779 (TCons __tmp114 __tmp778)) + (let __tmp780 (TCons __tmp114 __tmp779)) + (let __tmp781 (TCons __tmp114 __tmp780)) + (let __tmp782 (TCons __tmp114 __tmp781)) + (let __tmp783 (TCons __tmp0 __tmp782)) + (let __tmp784 (TupleT __tmp783)) + (let __tmp785 (Arg __tmp784 __tmp6)) + (let __tmp786 (Get __tmp785 10)) + (let __tmp787 (Get __tmp785 7)) + (let __tmp788 (Bop __tmp112 __tmp786 __tmp787)) + (let __tmp789 (Get __tmp785 0)) + (let __tmp790 (Single __tmp789)) + (let __tmp791 (Get __tmp785 1)) + (let __tmp792 (Single __tmp791)) + (let __tmp793 (Get __tmp785 2)) + (let __tmp794 (Single __tmp793)) + (let __tmp795 (Get __tmp785 3)) + (let __tmp796 (Single __tmp795)) + (let __tmp797 (Get __tmp785 4)) + (let __tmp798 (Single __tmp797)) + (let __tmp799 (Get __tmp785 5)) + (let __tmp800 (Single __tmp799)) + (let __tmp801 (Get __tmp785 6)) + (let __tmp802 (Single __tmp801)) + (let __tmp803 (Single __tmp787)) + (let __tmp804 (Get __tmp785 8)) + (let __tmp805 (Single __tmp804)) + (let __tmp806 (Get __tmp785 9)) + (let __tmp807 (Single __tmp806)) + (let __tmp808 (Single __tmp786)) + (let __tmp809 (Get __tmp785 11)) + (let __tmp810 (Single __tmp809)) + (let __tmp811 (Get __tmp785 12)) + (let __tmp812 (Single __tmp811)) + (let __tmp813 (Concat __tmp810 __tmp812)) + (let __tmp814 (Concat __tmp808 __tmp813)) + (let __tmp815 (Concat __tmp807 __tmp814)) + (let __tmp816 (Concat __tmp805 __tmp815)) + (let __tmp817 (Concat __tmp803 __tmp816)) + (let __tmp818 (Concat __tmp802 __tmp817)) + (let __tmp819 (Concat __tmp800 __tmp818)) + (let __tmp820 (Concat __tmp798 __tmp819)) + (let __tmp821 (Concat __tmp796 __tmp820)) + (let __tmp822 (Concat __tmp794 __tmp821)) + (let __tmp823 (Concat __tmp792 __tmp822)) + (let __tmp824 (Concat __tmp790 __tmp823)) + (let __tmp825 (Concat __tmp812 __tmp790)) + (let __tmp826 (Concat __tmp803 __tmp825)) + (let __tmp827 (Concat __tmp808 __tmp826)) + (let __tmp828 (Concat __tmp805 __tmp827)) + (let __tmp829 (Concat __tmp794 __tmp828)) + (let __tmp830 (Call 'matrix_scale' __tmp829)) + (let __tmp831 (Get __tmp830 0)) + (let __tmp832 (Single __tmp831)) + (let __tmp833 (Const __tmp83 __tmp784 __tmp6)) + (let __tmp834 (Single __tmp833)) + (let __tmp835 (Concat __tmp834 __tmp813)) + (let __tmp836 (Concat __tmp808 __tmp835)) + (let __tmp837 (Concat __tmp807 __tmp836)) + (let __tmp838 (Concat __tmp805 __tmp837)) + (let __tmp839 (Concat __tmp803 __tmp838)) + (let __tmp840 (Concat __tmp802 __tmp839)) + (let __tmp841 (Concat __tmp800 __tmp840)) + (let __tmp842 (Concat __tmp798 __tmp841)) + (let __tmp843 (Concat __tmp796 __tmp842)) + (let __tmp844 (Concat __tmp794 __tmp843)) + (let __tmp845 (Concat __tmp792 __tmp844)) + (let __tmp846 (Concat __tmp832 __tmp845)) + (let __tmp847 (TCons __tmp115 __tmp777)) + (let __tmp848 (TCons __tmp114 __tmp847)) + (let __tmp849 (TCons __tmp114 __tmp848)) + (let __tmp850 (TCons __tmp114 __tmp849)) + (let __tmp851 (TCons __tmp114 __tmp850)) + (let __tmp852 (TCons __tmp114 __tmp851)) + (let __tmp853 (TCons __tmp0 __tmp852)) + (let __tmp854 (TupleT __tmp853)) + (let __tmp855 (Arg __tmp854 __tmp6)) + (let __tmp856 (Get __tmp855 11)) + (let __tmp857 (Get __tmp855 12)) + (let __tmp858 (Bop __tmp112 __tmp856 __tmp857)) + (let __tmp859 (Get __tmp855 0)) + (let __tmp860 (Single __tmp859)) + (let __tmp861 (Get __tmp855 1)) + (let __tmp862 (Single __tmp861)) + (let __tmp863 (Get __tmp855 2)) + (let __tmp864 (Single __tmp863)) + (let __tmp865 (Get __tmp855 3)) + (let __tmp866 (Single __tmp865)) + (let __tmp867 (Get __tmp855 4)) + (let __tmp868 (Single __tmp867)) + (let __tmp869 (Get __tmp855 5)) + (let __tmp870 (Single __tmp869)) + (let __tmp871 (Get __tmp855 6)) + (let __tmp872 (Single __tmp871)) + (let __tmp873 (Get __tmp855 7)) + (let __tmp874 (Single __tmp873)) + (let __tmp875 (Get __tmp855 8)) + (let __tmp876 (Single __tmp875)) + (let __tmp877 (Get __tmp855 9)) + (let __tmp878 (Single __tmp877)) + (let __tmp879 (Get __tmp855 10)) + (let __tmp880 (Single __tmp879)) + (let __tmp881 (Single __tmp856)) + (let __tmp882 (Single __tmp857)) + (let __tmp883 (Get __tmp855 13)) + (let __tmp884 (Single __tmp883)) + (let __tmp885 (Concat __tmp882 __tmp884)) + (let __tmp886 (Concat __tmp881 __tmp885)) + (let __tmp887 (Concat __tmp880 __tmp886)) + (let __tmp888 (Concat __tmp878 __tmp887)) + (let __tmp889 (Concat __tmp876 __tmp888)) + (let __tmp890 (Concat __tmp874 __tmp889)) + (let __tmp891 (Concat __tmp872 __tmp890)) + (let __tmp892 (Concat __tmp870 __tmp891)) + (let __tmp893 (Concat __tmp868 __tmp892)) + (let __tmp894 (Concat __tmp866 __tmp893)) + (let __tmp895 (Concat __tmp864 __tmp894)) + (let __tmp896 (Concat __tmp862 __tmp895)) + (let __tmp897 (Concat __tmp860 __tmp896)) + (let __tmp898 (Concat __tmp882 __tmp860)) + (let __tmp899 (Concat __tmp881 __tmp898)) + (let __tmp900 (Concat __tmp876 __tmp899)) + (let __tmp901 (Concat __tmp862 __tmp900)) + (let __tmp902 (Call 'matrix_get' __tmp901)) + (let __tmp903 (Get __tmp902 0)) + (let __tmp904 (Get __tmp902 1)) + (let __tmp905 (Single __tmp904)) + (let __tmp906 (Concat __tmp874 __tmp905)) + (let __tmp907 (Concat __tmp880 __tmp906)) + (let __tmp908 (Concat __tmp881 __tmp907)) + (let __tmp909 (Concat __tmp866 __tmp908)) + (let __tmp910 (Call 'matrix_get' __tmp909)) + (let __tmp911 (Get __tmp910 0)) + (let __tmp912 (Bop __tmp330 __tmp903 __tmp911)) + (let __tmp913 (Single __tmp912)) + (let __tmp914 (Get __tmp910 1)) + (let __tmp915 (Single __tmp914)) + (let __tmp916 (Concat __tmp913 __tmp915)) + (let __tmp917 (Concat __tmp874 __tmp916)) + (let __tmp918 (Concat __tmp880 __tmp917)) + (let __tmp919 (Concat __tmp876 __tmp918)) + (let __tmp920 (Concat __tmp864 __tmp919)) + (let __tmp921 (Call 'matrix_incr' __tmp920)) + (let __tmp922 (Get __tmp921 0)) + (let __tmp923 (Single __tmp922)) + (let __tmp924 (Const __tmp361 __tmp854 __tmp6)) + (let __tmp925 (Single __tmp924)) + (let __tmp926 (Bop __tmp358 __tmp856 __tmp877)) + (let __tmp927 (Single __tmp926)) + (let __tmp928 (Concat __tmp927 __tmp885)) + (let __tmp929 (Concat __tmp925 __tmp928)) + (let __tmp930 (Concat __tmp880 __tmp929)) + (let __tmp931 (Concat __tmp878 __tmp930)) + (let __tmp932 (Concat __tmp876 __tmp931)) + (let __tmp933 (Concat __tmp874 __tmp932)) + (let __tmp934 (Concat __tmp872 __tmp933)) + (let __tmp935 (Concat __tmp870 __tmp934)) + (let __tmp936 (Concat __tmp868 __tmp935)) + (let __tmp937 (Concat __tmp866 __tmp936)) + (let __tmp938 (Concat __tmp864 __tmp937)) + (let __tmp939 (Concat __tmp862 __tmp938)) + (let __tmp940 (Concat __tmp923 __tmp939)) + (let __tmp941 (Const __tmp379 __tmp854 __tmp6)) + (let __tmp942 (Single __tmp941)) + (let __tmp943 (Concat __tmp942 __tmp886)) + (let __tmp944 (Concat __tmp880 __tmp943)) + (let __tmp945 (Concat __tmp878 __tmp944)) + (let __tmp946 (Concat __tmp876 __tmp945)) + (let __tmp947 (Concat __tmp874 __tmp946)) + (let __tmp948 (Concat __tmp872 __tmp947)) + (let __tmp949 (Concat __tmp870 __tmp948)) + (let __tmp950 (Concat __tmp868 __tmp949)) + (let __tmp951 (Concat __tmp866 __tmp950)) + (let __tmp952 (Concat __tmp864 __tmp951)) + (let __tmp953 (Concat __tmp862 __tmp952)) + (let __tmp954 (Concat __tmp860 __tmp953)) + (let __tmp955 (If __tmp858 __tmp897 __tmp940 __tmp954)) + (let __tmp956 (Get __tmp955 11)) + (let __tmp957 (Single __tmp956)) + (let __tmp958 (Get __tmp955 0)) + (let __tmp959 (Single __tmp958)) + (let __tmp960 (Get __tmp955 1)) + (let __tmp961 (Single __tmp960)) + (let __tmp962 (Get __tmp955 2)) + (let __tmp963 (Single __tmp962)) + (let __tmp964 (Get __tmp955 3)) + (let __tmp965 (Single __tmp964)) + (let __tmp966 (Get __tmp955 4)) + (let __tmp967 (Single __tmp966)) + (let __tmp968 (Get __tmp955 5)) + (let __tmp969 (Single __tmp968)) + (let __tmp970 (Get __tmp955 6)) + (let __tmp971 (Single __tmp970)) + (let __tmp972 (Get __tmp955 7)) + (let __tmp973 (Single __tmp972)) + (let __tmp974 (Get __tmp955 8)) + (let __tmp975 (Single __tmp974)) + (let __tmp976 (Get __tmp955 9)) + (let __tmp977 (Single __tmp976)) + (let __tmp978 (Get __tmp955 10)) + (let __tmp979 (Single __tmp978)) + (let __tmp980 (Get __tmp955 12)) + (let __tmp981 (Single __tmp980)) + (let __tmp982 (Get __tmp955 13)) + (let __tmp983 (Single __tmp982)) + (let __tmp984 (Get __tmp955 14)) + (let __tmp985 (Single __tmp984)) + (let __tmp986 (Concat __tmp983 __tmp985)) + (let __tmp987 (Concat __tmp981 __tmp986)) + (let __tmp988 (Concat __tmp979 __tmp987)) + (let __tmp989 (Concat __tmp977 __tmp988)) + (let __tmp990 (Concat __tmp975 __tmp989)) + (let __tmp991 (Concat __tmp973 __tmp990)) + (let __tmp992 (Concat __tmp971 __tmp991)) + (let __tmp993 (Concat __tmp969 __tmp992)) + (let __tmp994 (Concat __tmp967 __tmp993)) + (let __tmp995 (Concat __tmp965 __tmp994)) + (let __tmp996 (Concat __tmp963 __tmp995)) + (let __tmp997 (Concat __tmp961 __tmp996)) + (let __tmp998 (Concat __tmp959 __tmp997)) + (let __tmp999 (Concat __tmp957 __tmp998)) + (let __tmp1000 (DoWhile __tmp846 __tmp999)) + (let __tmp1001 (Get __tmp1000 0)) + (let __tmp1002 (Single __tmp1001)) + (let __tmp1003 (Get __tmp1000 1)) + (let __tmp1004 (Single __tmp1003)) + (let __tmp1005 (Get __tmp1000 2)) + (let __tmp1006 (Single __tmp1005)) + (let __tmp1007 (Get __tmp1000 3)) + (let __tmp1008 (Single __tmp1007)) + (let __tmp1009 (Get __tmp1000 4)) + (let __tmp1010 (Single __tmp1009)) + (let __tmp1011 (Get __tmp1000 5)) + (let __tmp1012 (Single __tmp1011)) + (let __tmp1013 (Get __tmp1000 6)) + (let __tmp1014 (Single __tmp1013)) + (let __tmp1015 (Get __tmp1000 7)) + (let __tmp1016 (Single __tmp1015)) + (let __tmp1017 (Get __tmp1000 8)) + (let __tmp1018 (Single __tmp1017)) + (let __tmp1019 (Get __tmp1000 9)) + (let __tmp1020 (Single __tmp1019)) + (let __tmp1021 (Const __tmp361 __tmp784 __tmp6)) + (let __tmp1022 (Single __tmp1021)) + (let __tmp1023 (Get __tmp1000 10)) + (let __tmp1024 (Bop __tmp358 __tmp1023 __tmp1019)) + (let __tmp1025 (Single __tmp1024)) + (let __tmp1026 (Get __tmp1000 12)) + (let __tmp1027 (Single __tmp1026)) + (let __tmp1028 (Get __tmp1000 13)) + (let __tmp1029 (Single __tmp1028)) + (let __tmp1030 (Concat __tmp1027 __tmp1029)) + (let __tmp1031 (Concat __tmp1025 __tmp1030)) + (let __tmp1032 (Concat __tmp1022 __tmp1031)) + (let __tmp1033 (Concat __tmp1020 __tmp1032)) + (let __tmp1034 (Concat __tmp1018 __tmp1033)) + (let __tmp1035 (Concat __tmp1016 __tmp1034)) + (let __tmp1036 (Concat __tmp1014 __tmp1035)) + (let __tmp1037 (Concat __tmp1012 __tmp1036)) + (let __tmp1038 (Concat __tmp1010 __tmp1037)) + (let __tmp1039 (Concat __tmp1008 __tmp1038)) + (let __tmp1040 (Concat __tmp1006 __tmp1039)) + (let __tmp1041 (Concat __tmp1004 __tmp1040)) + (let __tmp1042 (Concat __tmp1002 __tmp1041)) + (let __tmp1043 (Const __tmp379 __tmp784 __tmp6)) + (let __tmp1044 (Single __tmp1043)) + (let __tmp1045 (Concat __tmp1044 __tmp814)) + (let __tmp1046 (Concat __tmp807 __tmp1045)) + (let __tmp1047 (Concat __tmp805 __tmp1046)) + (let __tmp1048 (Concat __tmp803 __tmp1047)) + (let __tmp1049 (Concat __tmp802 __tmp1048)) + (let __tmp1050 (Concat __tmp800 __tmp1049)) + (let __tmp1051 (Concat __tmp798 __tmp1050)) + (let __tmp1052 (Concat __tmp796 __tmp1051)) + (let __tmp1053 (Concat __tmp794 __tmp1052)) + (let __tmp1054 (Concat __tmp792 __tmp1053)) + (let __tmp1055 (Concat __tmp790 __tmp1054)) + (let __tmp1056 (If __tmp788 __tmp824 __tmp1042 __tmp1055)) + (let __tmp1057 (Get __tmp1056 10)) + (let __tmp1058 (Single __tmp1057)) + (let __tmp1059 (Get __tmp1056 0)) + (let __tmp1060 (Single __tmp1059)) + (let __tmp1061 (Get __tmp1056 1)) + (let __tmp1062 (Single __tmp1061)) + (let __tmp1063 (Get __tmp1056 2)) + (let __tmp1064 (Single __tmp1063)) + (let __tmp1065 (Get __tmp1056 3)) + (let __tmp1066 (Single __tmp1065)) + (let __tmp1067 (Get __tmp1056 4)) + (let __tmp1068 (Single __tmp1067)) + (let __tmp1069 (Get __tmp1056 5)) + (let __tmp1070 (Single __tmp1069)) + (let __tmp1071 (Get __tmp1056 6)) + (let __tmp1072 (Single __tmp1071)) + (let __tmp1073 (Get __tmp1056 7)) + (let __tmp1074 (Single __tmp1073)) + (let __tmp1075 (Get __tmp1056 8)) + (let __tmp1076 (Single __tmp1075)) + (let __tmp1077 (Get __tmp1056 9)) + (let __tmp1078 (Single __tmp1077)) + (let __tmp1079 (Get __tmp1056 11)) + (let __tmp1080 (Single __tmp1079)) + (let __tmp1081 (Get __tmp1056 12)) + (let __tmp1082 (Single __tmp1081)) + (let __tmp1083 (Get __tmp1056 13)) + (let __tmp1084 (Single __tmp1083)) + (let __tmp1085 (Concat __tmp1082 __tmp1084)) + (let __tmp1086 (Concat __tmp1080 __tmp1085)) + (let __tmp1087 (Concat __tmp1078 __tmp1086)) + (let __tmp1088 (Concat __tmp1076 __tmp1087)) + (let __tmp1089 (Concat __tmp1074 __tmp1088)) + (let __tmp1090 (Concat __tmp1072 __tmp1089)) + (let __tmp1091 (Concat __tmp1070 __tmp1090)) + (let __tmp1092 (Concat __tmp1068 __tmp1091)) + (let __tmp1093 (Concat __tmp1066 __tmp1092)) + (let __tmp1094 (Concat __tmp1064 __tmp1093)) + (let __tmp1095 (Concat __tmp1062 __tmp1094)) + (let __tmp1096 (Concat __tmp1060 __tmp1095)) + (let __tmp1097 (Concat __tmp1058 __tmp1096)) + (let __tmp1098 (DoWhile __tmp776 __tmp1097)) + (let __tmp1099 (Get __tmp1098 0)) + (let __tmp1100 (Single __tmp1099)) + (let __tmp1101 (Get __tmp1098 1)) + (let __tmp1102 (Single __tmp1101)) + (let __tmp1103 (Get __tmp1098 2)) + (let __tmp1104 (Single __tmp1103)) + (let __tmp1105 (Get __tmp1098 3)) + (let __tmp1106 (Single __tmp1105)) + (let __tmp1107 (Get __tmp1098 4)) + (let __tmp1108 (Single __tmp1107)) + (let __tmp1109 (Get __tmp1098 5)) + (let __tmp1110 (Single __tmp1109)) + (let __tmp1111 (Get __tmp1098 6)) + (let __tmp1112 (Single __tmp1111)) + (let __tmp1113 (Get __tmp1098 7)) + (let __tmp1114 (Single __tmp1113)) + (let __tmp1115 (Const __tmp361 __tmp726 __tmp6)) + (let __tmp1116 (Single __tmp1115)) + (let __tmp1117 (Get __tmp1098 8)) + (let __tmp1118 (Get __tmp1098 9)) + (let __tmp1119 (Bop __tmp358 __tmp1117 __tmp1118)) + (let __tmp1120 (Single __tmp1119)) + (let __tmp1121 (Single __tmp1118)) + (let __tmp1122 (Get __tmp1098 11)) + (let __tmp1123 (Single __tmp1122)) + (let __tmp1124 (Get __tmp1098 12)) + (let __tmp1125 (Single __tmp1124)) + (let __tmp1126 (Concat __tmp1123 __tmp1125)) + (let __tmp1127 (Concat __tmp1121 __tmp1126)) + (let __tmp1128 (Concat __tmp1120 __tmp1127)) + (let __tmp1129 (Concat __tmp1116 __tmp1128)) + (let __tmp1130 (Concat __tmp1114 __tmp1129)) + (let __tmp1131 (Concat __tmp1112 __tmp1130)) + (let __tmp1132 (Concat __tmp1110 __tmp1131)) + (let __tmp1133 (Concat __tmp1108 __tmp1132)) + (let __tmp1134 (Concat __tmp1106 __tmp1133)) + (let __tmp1135 (Concat __tmp1104 __tmp1134)) + (let __tmp1136 (Concat __tmp1102 __tmp1135)) + (let __tmp1137 (Concat __tmp1100 __tmp1136)) + (let __tmp1138 (Const __tmp379 __tmp726 __tmp6)) + (let __tmp1139 (Single __tmp1138)) + (let __tmp1140 (Concat __tmp1139 __tmp755)) + (let __tmp1141 (Concat __tmp745 __tmp1140)) + (let __tmp1142 (Concat __tmp743 __tmp1141)) + (let __tmp1143 (Concat __tmp742 __tmp1142)) + (let __tmp1144 (Concat __tmp740 __tmp1143)) + (let __tmp1145 (Concat __tmp738 __tmp1144)) + (let __tmp1146 (Concat __tmp736 __tmp1145)) + (let __tmp1147 (Concat __tmp734 __tmp1146)) + (let __tmp1148 (Concat __tmp732 __tmp1147)) + (let __tmp1149 (If __tmp730 __tmp763 __tmp1137 __tmp1148)) + (let __tmp1150 (Get __tmp1149 8)) + (let __tmp1151 (Single __tmp1150)) + (let __tmp1152 (Get __tmp1149 0)) + (let __tmp1153 (Single __tmp1152)) + (let __tmp1154 (Get __tmp1149 1)) + (let __tmp1155 (Single __tmp1154)) + (let __tmp1156 (Get __tmp1149 2)) + (let __tmp1157 (Single __tmp1156)) + (let __tmp1158 (Get __tmp1149 3)) + (let __tmp1159 (Single __tmp1158)) + (let __tmp1160 (Get __tmp1149 4)) + (let __tmp1161 (Single __tmp1160)) + (let __tmp1162 (Get __tmp1149 5)) + (let __tmp1163 (Single __tmp1162)) + (let __tmp1164 (Get __tmp1149 6)) + (let __tmp1165 (Single __tmp1164)) + (let __tmp1166 (Get __tmp1149 7)) + (let __tmp1167 (Single __tmp1166)) + (let __tmp1168 (Get __tmp1149 9)) + (let __tmp1169 (Single __tmp1168)) + (let __tmp1170 (Get __tmp1149 10)) + (let __tmp1171 (Single __tmp1170)) + (let __tmp1172 (Get __tmp1149 11)) + (let __tmp1173 (Single __tmp1172)) + (let __tmp1174 (Get __tmp1149 12)) + (let __tmp1175 (Single __tmp1174)) + (let __tmp1176 (Concat __tmp1173 __tmp1175)) + (let __tmp1177 (Concat __tmp1171 __tmp1176)) + (let __tmp1178 (Concat __tmp1169 __tmp1177)) + (let __tmp1179 (Concat __tmp1167 __tmp1178)) + (let __tmp1180 (Concat __tmp1165 __tmp1179)) + (let __tmp1181 (Concat __tmp1163 __tmp1180)) + (let __tmp1182 (Concat __tmp1161 __tmp1181)) + (let __tmp1183 (Concat __tmp1159 __tmp1182)) + (let __tmp1184 (Concat __tmp1157 __tmp1183)) + (let __tmp1185 (Concat __tmp1155 __tmp1184)) + (let __tmp1186 (Concat __tmp1153 __tmp1185)) + (let __tmp1187 (Concat __tmp1151 __tmp1186)) + (let __tmp1188 (DoWhile __tmp715 __tmp1187)) + (let __tmp1189 (Get __tmp1188 2)) + (let __tmp1190 (Single __tmp1189)) + (let __tmp1191 (Get __tmp1188 6)) + (let __tmp1192 (Single __tmp1191)) + (let __tmp1193 (Get __tmp1188 7)) + (let __tmp1194 (Single __tmp1193)) + (let __tmp1195 (Get __tmp1188 0)) + (let __tmp1196 (Single __tmp1195)) + (let __tmp1197 (Concat __tmp1194 __tmp1196)) + (let __tmp1198 (Concat __tmp1192 __tmp1197)) + (let __tmp1199 (Concat __tmp1190 __tmp1198)) + (let __tmp1200 (Call 'matrix_sum' __tmp1199)) + (let __tmp1201 (Get __tmp1200 0)) + (let __tmp1202 (Free)) + (let __tmp1203 (Get __tmp1188 1)) + (let __tmp1204 (Get __tmp1188 3)) + (let __tmp1205 (Get __tmp1188 4)) + (let __tmp1206 (Get __tmp1188 5)) + (let __tmp1207 (Get __tmp1200 1)) + (let __tmp1208 (Bop __tmp1202 __tmp1206 __tmp1207)) + (let __tmp1209 (Bop __tmp1202 __tmp1205 __tmp1208)) + (let __tmp1210 (Bop __tmp1202 __tmp1204 __tmp1209)) + (let __tmp1211 (Bop __tmp1202 __tmp1189 __tmp1210)) + (let __tmp1212 (Bop __tmp1202 __tmp1203 __tmp1211)) + (let __tmp1213 (Bop __tmp4 __tmp1201 __tmp1212)) + (let __tmp1214 (Single __tmp1213)) + (let __tmp1215 (Function 'main' __tmp3 __tmp3 __tmp1214)) + (let __tmp1216 (TCons __tmp113 __tmp2)) + (let __tmp1217 (TCons __tmp115 __tmp1216)) + (let __tmp1218 (TCons __tmp113 __tmp1217)) + (let __tmp1219 (TCons __tmp115 __tmp1218)) + (let __tmp1220 (TCons __tmp113 __tmp1219)) + (let __tmp1221 (TCons __tmp115 __tmp1220)) + (let __tmp1222 (TCons __tmp113 __tmp1221)) + (let __tmp1223 (TCons __tmp115 __tmp1222)) + (let __tmp1224 (TCons __tmp114 __tmp1223)) + (let __tmp1225 (TCons __tmp114 __tmp1224)) + (let __tmp1226 (TCons __tmp114 __tmp1225)) + (let __tmp1227 (TCons __tmp114 __tmp1226)) + (let __tmp1228 (TupleT __tmp1227)) + (let __tmp1229 (Arg __tmp1228 __tmp6)) + (let __tmp1230 (Get __tmp1229 12)) + (let __tmp1231 (Single __tmp1230)) + (let __tmp1232 (Const __tmp95 __tmp1228 __tmp6)) + (let __tmp1233 (Single __tmp1232)) + (let __tmp1234 (Float 1.0)) + (let __tmp1235 (Const __tmp1234 __tmp1228 __tmp6)) + (let __tmp1236 (Single __tmp1235)) + (let __tmp1237 (Const __tmp83 __tmp1228 __tmp6)) + (let __tmp1238 (Single __tmp1237)) + (let __tmp1239 (Const __tmp86 __tmp1228 __tmp6)) + (let __tmp1240 (Single __tmp1239)) + (let __tmp1241 (Get __tmp1229 3)) + (let __tmp1242 (Single __tmp1241)) + (let __tmp1243 (Get __tmp1229 10)) + (let __tmp1244 (Single __tmp1243)) + (let __tmp1245 (Get __tmp1229 9)) + (let __tmp1246 (Single __tmp1245)) + (let __tmp1247 (Float 2.0)) + (let __tmp1248 (Const __tmp1247 __tmp1228 __tmp6)) + (let __tmp1249 (Single __tmp1248)) + (let __tmp1250 (Get __tmp1229 4)) + (let __tmp1251 (Single __tmp1250)) + (let __tmp1252 (Get __tmp1229 2)) + (let __tmp1253 (Single __tmp1252)) + (let __tmp1254 (Get __tmp1229 11)) + (let __tmp1255 (Single __tmp1254)) + (let __tmp1256 (Float 3.0)) + (let __tmp1257 (Const __tmp1256 __tmp1228 __tmp6)) + (let __tmp1258 (Single __tmp1257)) + (let __tmp1259 (Get __tmp1229 6)) + (let __tmp1260 (Single __tmp1259)) + (let __tmp1261 (Get __tmp1229 1)) + (let __tmp1262 (Single __tmp1261)) + (let __tmp1263 (Get __tmp1229 7)) + (let __tmp1264 (Single __tmp1263)) + (let __tmp1265 (Get __tmp1229 8)) + (let __tmp1266 (Single __tmp1265)) + (let __tmp1267 (Get __tmp1229 0)) + (let __tmp1268 (Single __tmp1267)) + (let __tmp1269 (Get __tmp1229 5)) + (let __tmp1270 (Single __tmp1269)) + (let __tmp1271 (Concat __tmp1268 __tmp1270)) + (let __tmp1272 (Concat __tmp1266 __tmp1271)) + (let __tmp1273 (Concat __tmp1264 __tmp1272)) + (let __tmp1274 (Concat __tmp1262 __tmp1273)) + (let __tmp1275 (Concat __tmp1260 __tmp1274)) + (let __tmp1276 (Concat __tmp1258 __tmp1275)) + (let __tmp1277 (Concat __tmp1255 __tmp1276)) + (let __tmp1278 (Concat __tmp1253 __tmp1277)) + (let __tmp1279 (Concat __tmp1251 __tmp1278)) + (let __tmp1280 (Concat __tmp1249 __tmp1279)) + (let __tmp1281 (Concat __tmp1246 __tmp1280)) + (let __tmp1282 (Concat __tmp1244 __tmp1281)) + (let __tmp1283 (Concat __tmp1242 __tmp1282)) + (let __tmp1284 (Concat __tmp1240 __tmp1283)) + (let __tmp1285 (Concat __tmp1238 __tmp1284)) + (let __tmp1286 (Concat __tmp1236 __tmp1285)) + (let __tmp1287 (Concat __tmp1233 __tmp1286)) + (let __tmp1288 (Concat __tmp1231 __tmp1287)) + (let __tmp1289 (TCons __tmp114 __tmp116)) + (let __tmp1290 (TCons __tmp115 __tmp1289)) + (let __tmp1291 (TCons __tmp113 __tmp1290)) + (let __tmp1292 (TCons __tmp114 __tmp1291)) + (let __tmp1293 (TCons __tmp115 __tmp1292)) + (let __tmp1294 (TCons __tmp113 __tmp1293)) + (let __tmp1295 (TCons __tmp113 __tmp1294)) + (let __tmp1296 (TCons __tmp114 __tmp1295)) + (let __tmp1297 (TCons __tmp115 __tmp1296)) + (let __tmp1298 (TCons __tmp113 __tmp1297)) + (let __tmp1299 (TCons __tmp113 __tmp1298)) + (let __tmp1300 (TCons __tmp115 __tmp1299)) + (let __tmp1301 (TCons __tmp114 __tmp1300)) + (let __tmp1302 (TCons __tmp115 __tmp1301)) + (let __tmp1303 (TCons __tmp115 __tmp1302)) + (let __tmp1304 (TCons __tmp113 __tmp1303)) + (let __tmp1305 (TCons __tmp113 __tmp1304)) + (let __tmp1306 (TCons __tmp0 __tmp1305)) + (let __tmp1307 (TupleT __tmp1306)) + (let __tmp1308 (Arg __tmp1307 __tmp6)) + (let __tmp1309 (Get __tmp1308 3)) + (let __tmp1310 (Get __tmp1308 9)) + (let __tmp1311 (Bop __tmp112 __tmp1309 __tmp1310)) + (let __tmp1312 (Get __tmp1308 0)) + (let __tmp1313 (Single __tmp1312)) + (let __tmp1314 (Get __tmp1308 1)) + (let __tmp1315 (Single __tmp1314)) + (let __tmp1316 (Get __tmp1308 2)) + (let __tmp1317 (Single __tmp1316)) + (let __tmp1318 (Single __tmp1309)) + (let __tmp1319 (Get __tmp1308 4)) + (let __tmp1320 (Single __tmp1319)) + (let __tmp1321 (Get __tmp1308 5)) + (let __tmp1322 (Single __tmp1321)) + (let __tmp1323 (Get __tmp1308 6)) + (let __tmp1324 (Single __tmp1323)) + (let __tmp1325 (Get __tmp1308 7)) + (let __tmp1326 (Single __tmp1325)) + (let __tmp1327 (Get __tmp1308 8)) + (let __tmp1328 (Single __tmp1327)) + (let __tmp1329 (Single __tmp1310)) + (let __tmp1330 (Get __tmp1308 10)) + (let __tmp1331 (Single __tmp1330)) + (let __tmp1332 (Get __tmp1308 11)) + (let __tmp1333 (Single __tmp1332)) + (let __tmp1334 (Get __tmp1308 12)) + (let __tmp1335 (Single __tmp1334)) + (let __tmp1336 (Get __tmp1308 13)) + (let __tmp1337 (Single __tmp1336)) + (let __tmp1338 (Get __tmp1308 14)) + (let __tmp1339 (Single __tmp1338)) + (let __tmp1340 (Get __tmp1308 15)) + (let __tmp1341 (Single __tmp1340)) + (let __tmp1342 (Get __tmp1308 16)) + (let __tmp1343 (Single __tmp1342)) + (let __tmp1344 (Get __tmp1308 17)) + (let __tmp1345 (Single __tmp1344)) + (let __tmp1346 (Get __tmp1308 18)) + (let __tmp1347 (Single __tmp1346)) + (let __tmp1348 (Concat __tmp1345 __tmp1347)) + (let __tmp1349 (Concat __tmp1343 __tmp1348)) + (let __tmp1350 (Concat __tmp1341 __tmp1349)) + (let __tmp1351 (Concat __tmp1339 __tmp1350)) + (let __tmp1352 (Concat __tmp1337 __tmp1351)) + (let __tmp1353 (Concat __tmp1335 __tmp1352)) + (let __tmp1354 (Concat __tmp1333 __tmp1353)) + (let __tmp1355 (Concat __tmp1331 __tmp1354)) + (let __tmp1356 (Concat __tmp1329 __tmp1355)) + (let __tmp1357 (Concat __tmp1328 __tmp1356)) + (let __tmp1358 (Concat __tmp1326 __tmp1357)) + (let __tmp1359 (Concat __tmp1324 __tmp1358)) + (let __tmp1360 (Concat __tmp1322 __tmp1359)) + (let __tmp1361 (Concat __tmp1320 __tmp1360)) + (let __tmp1362 (Concat __tmp1318 __tmp1361)) + (let __tmp1363 (Concat __tmp1317 __tmp1362)) + (let __tmp1364 (Concat __tmp1315 __tmp1363)) + (let __tmp1365 (Concat __tmp1313 __tmp1364)) + (let __tmp1366 (Const __tmp95 __tmp1307 __tmp6)) + (let __tmp1367 (Single __tmp1366)) + (let __tmp1368 (Const __tmp83 __tmp1307 __tmp6)) + (let __tmp1369 (Single __tmp1368)) + (let __tmp1370 (Concat __tmp1369 __tmp1360)) + (let __tmp1371 (Concat __tmp1367 __tmp1370)) + (let __tmp1372 (Concat __tmp1320 __tmp1371)) + (let __tmp1373 (Concat __tmp1318 __tmp1372)) + (let __tmp1374 (Concat __tmp1317 __tmp1373)) + (let __tmp1375 (Concat __tmp1315 __tmp1374)) + (let __tmp1376 (Concat __tmp1313 __tmp1375)) + (let __tmp1377 (TCons __tmp113 __tmp1302)) + (let __tmp1378 (TCons __tmp115 __tmp1377)) + (let __tmp1379 (TCons __tmp115 __tmp1378)) + (let __tmp1380 (TCons __tmp113 __tmp1379)) + (let __tmp1381 (TCons __tmp113 __tmp1380)) + (let __tmp1382 (TCons __tmp0 __tmp1381)) + (let __tmp1383 (TupleT __tmp1382)) + (let __tmp1384 (Arg __tmp1383 __tmp6)) + (let __tmp1385 (Get __tmp1384 6)) + (let __tmp1386 (Get __tmp1384 18)) + (let __tmp1387 (Bop __tmp112 __tmp1385 __tmp1386)) + (let __tmp1388 (Get __tmp1384 0)) + (let __tmp1389 (Single __tmp1388)) + (let __tmp1390 (Get __tmp1384 1)) + (let __tmp1391 (Single __tmp1390)) + (let __tmp1392 (Get __tmp1384 2)) + (let __tmp1393 (Single __tmp1392)) + (let __tmp1394 (Get __tmp1384 3)) + (let __tmp1395 (Single __tmp1394)) + (let __tmp1396 (Get __tmp1384 4)) + (let __tmp1397 (Single __tmp1396)) + (let __tmp1398 (Get __tmp1384 5)) + (let __tmp1399 (Single __tmp1398)) + (let __tmp1400 (Single __tmp1385)) + (let __tmp1401 (Get __tmp1384 7)) + (let __tmp1402 (Single __tmp1401)) + (let __tmp1403 (Get __tmp1384 8)) + (let __tmp1404 (Single __tmp1403)) + (let __tmp1405 (Get __tmp1384 9)) + (let __tmp1406 (Single __tmp1405)) + (let __tmp1407 (Get __tmp1384 10)) + (let __tmp1408 (Single __tmp1407)) + (let __tmp1409 (Get __tmp1384 11)) + (let __tmp1410 (Single __tmp1409)) + (let __tmp1411 (Get __tmp1384 12)) + (let __tmp1412 (Single __tmp1411)) + (let __tmp1413 (Get __tmp1384 13)) + (let __tmp1414 (Single __tmp1413)) + (let __tmp1415 (Get __tmp1384 14)) + (let __tmp1416 (Single __tmp1415)) + (let __tmp1417 (Get __tmp1384 15)) + (let __tmp1418 (Single __tmp1417)) + (let __tmp1419 (Get __tmp1384 16)) + (let __tmp1420 (Single __tmp1419)) + (let __tmp1421 (Get __tmp1384 17)) + (let __tmp1422 (Single __tmp1421)) + (let __tmp1423 (Single __tmp1386)) + (let __tmp1424 (Get __tmp1384 19)) + (let __tmp1425 (Single __tmp1424)) + (let __tmp1426 (Get __tmp1384 20)) + (let __tmp1427 (Single __tmp1426)) + (let __tmp1428 (Concat __tmp1425 __tmp1427)) + (let __tmp1429 (Concat __tmp1423 __tmp1428)) + (let __tmp1430 (Concat __tmp1422 __tmp1429)) + (let __tmp1431 (Concat __tmp1420 __tmp1430)) + (let __tmp1432 (Concat __tmp1418 __tmp1431)) + (let __tmp1433 (Concat __tmp1416 __tmp1432)) + (let __tmp1434 (Concat __tmp1414 __tmp1433)) + (let __tmp1435 (Concat __tmp1412 __tmp1434)) + (let __tmp1436 (Concat __tmp1410 __tmp1435)) + (let __tmp1437 (Concat __tmp1408 __tmp1436)) + (let __tmp1438 (Concat __tmp1406 __tmp1437)) + (let __tmp1439 (Concat __tmp1404 __tmp1438)) + (let __tmp1440 (Concat __tmp1402 __tmp1439)) + (let __tmp1441 (Concat __tmp1400 __tmp1440)) + (let __tmp1442 (Concat __tmp1399 __tmp1441)) + (let __tmp1443 (Concat __tmp1397 __tmp1442)) + (let __tmp1444 (Concat __tmp1395 __tmp1443)) + (let __tmp1445 (Concat __tmp1393 __tmp1444)) + (let __tmp1446 (Concat __tmp1391 __tmp1445)) + (let __tmp1447 (Concat __tmp1389 __tmp1446)) + (let __tmp1448 (FDiv)) + (let __tmp1449 (FAdd)) + (let __tmp1450 (Bop __tmp330 __tmp1390 __tmp1398)) + (let __tmp1451 (Bop __tmp1449 __tmp1450 __tmp1392)) + (let __tmp1452 (Single __tmp1451)) + (let __tmp1453 (Concat __tmp1427 __tmp1389)) + (let __tmp1454 (Concat __tmp1452 __tmp1453)) + (let __tmp1455 (Call 'fmod' __tmp1454)) + (let __tmp1456 (Get __tmp1455 0)) + (let __tmp1457 (Bop __tmp1448 __tmp1456 __tmp1426)) + (let __tmp1458 (Single __tmp1457)) + (let __tmp1459 (Get __tmp1455 1)) + (let __tmp1460 (Single __tmp1459)) + (let __tmp1461 (Concat __tmp1458 __tmp1460)) + (let __tmp1462 (Concat __tmp1423 __tmp1461)) + (let __tmp1463 (Concat __tmp1400 __tmp1462)) + (let __tmp1464 (Concat __tmp1395 __tmp1463)) + (let __tmp1465 (Concat __tmp1425 __tmp1464)) + (let __tmp1466 (Call 'matrix_set' __tmp1465)) + (let __tmp1467 (Get __tmp1466 0)) + (let __tmp1468 (Single __tmp1467)) + (let __tmp1469 (Bop __tmp1449 __tmp1398 __tmp1392)) + (let __tmp1470 (Single __tmp1469)) + (let __tmp1471 (Bop __tmp358 __tmp1385 __tmp1396)) + (let __tmp1472 (Single __tmp1471)) + (let __tmp1473 (Const __tmp361 __tmp1383 __tmp6)) + (let __tmp1474 (Single __tmp1473)) + (let __tmp1475 (Concat __tmp1474 __tmp1428)) + (let __tmp1476 (Concat __tmp1423 __tmp1475)) + (let __tmp1477 (Concat __tmp1422 __tmp1476)) + (let __tmp1478 (Concat __tmp1420 __tmp1477)) + (let __tmp1479 (Concat __tmp1418 __tmp1478)) + (let __tmp1480 (Concat __tmp1416 __tmp1479)) + (let __tmp1481 (Concat __tmp1414 __tmp1480)) + (let __tmp1482 (Concat __tmp1412 __tmp1481)) + (let __tmp1483 (Concat __tmp1410 __tmp1482)) + (let __tmp1484 (Concat __tmp1408 __tmp1483)) + (let __tmp1485 (Concat __tmp1406 __tmp1484)) + (let __tmp1486 (Concat __tmp1404 __tmp1485)) + (let __tmp1487 (Concat __tmp1402 __tmp1486)) + (let __tmp1488 (Concat __tmp1472 __tmp1487)) + (let __tmp1489 (Concat __tmp1470 __tmp1488)) + (let __tmp1490 (Concat __tmp1397 __tmp1489)) + (let __tmp1491 (Concat __tmp1395 __tmp1490)) + (let __tmp1492 (Concat __tmp1393 __tmp1491)) + (let __tmp1493 (Concat __tmp1391 __tmp1492)) + (let __tmp1494 (Concat __tmp1468 __tmp1493)) + (let __tmp1495 (Const __tmp379 __tmp1383 __tmp6)) + (let __tmp1496 (Single __tmp1495)) + (let __tmp1497 (Concat __tmp1496 __tmp1428)) + (let __tmp1498 (Concat __tmp1423 __tmp1497)) + (let __tmp1499 (Concat __tmp1422 __tmp1498)) + (let __tmp1500 (Concat __tmp1420 __tmp1499)) + (let __tmp1501 (Concat __tmp1418 __tmp1500)) + (let __tmp1502 (Concat __tmp1416 __tmp1501)) + (let __tmp1503 (Concat __tmp1414 __tmp1502)) + (let __tmp1504 (Concat __tmp1412 __tmp1503)) + (let __tmp1505 (Concat __tmp1410 __tmp1504)) + (let __tmp1506 (Concat __tmp1408 __tmp1505)) + (let __tmp1507 (Concat __tmp1406 __tmp1506)) + (let __tmp1508 (Concat __tmp1404 __tmp1507)) + (let __tmp1509 (Concat __tmp1402 __tmp1508)) + (let __tmp1510 (Concat __tmp1400 __tmp1509)) + (let __tmp1511 (Concat __tmp1399 __tmp1510)) + (let __tmp1512 (Concat __tmp1397 __tmp1511)) + (let __tmp1513 (Concat __tmp1395 __tmp1512)) + (let __tmp1514 (Concat __tmp1393 __tmp1513)) + (let __tmp1515 (Concat __tmp1391 __tmp1514)) + (let __tmp1516 (Concat __tmp1389 __tmp1515)) + (let __tmp1517 (If __tmp1387 __tmp1447 __tmp1494 __tmp1516)) + (let __tmp1518 (Get __tmp1517 19)) + (let __tmp1519 (Single __tmp1518)) + (let __tmp1520 (Get __tmp1517 0)) + (let __tmp1521 (Single __tmp1520)) + (let __tmp1522 (Get __tmp1517 1)) + (let __tmp1523 (Single __tmp1522)) + (let __tmp1524 (Get __tmp1517 2)) + (let __tmp1525 (Single __tmp1524)) + (let __tmp1526 (Get __tmp1517 3)) + (let __tmp1527 (Single __tmp1526)) + (let __tmp1528 (Get __tmp1517 4)) + (let __tmp1529 (Single __tmp1528)) + (let __tmp1530 (Get __tmp1517 5)) + (let __tmp1531 (Single __tmp1530)) + (let __tmp1532 (Get __tmp1517 6)) + (let __tmp1533 (Single __tmp1532)) + (let __tmp1534 (Get __tmp1517 7)) + (let __tmp1535 (Single __tmp1534)) + (let __tmp1536 (Get __tmp1517 8)) + (let __tmp1537 (Single __tmp1536)) + (let __tmp1538 (Get __tmp1517 9)) + (let __tmp1539 (Single __tmp1538)) + (let __tmp1540 (Get __tmp1517 10)) + (let __tmp1541 (Single __tmp1540)) + (let __tmp1542 (Get __tmp1517 11)) + (let __tmp1543 (Single __tmp1542)) + (let __tmp1544 (Get __tmp1517 12)) + (let __tmp1545 (Single __tmp1544)) + (let __tmp1546 (Get __tmp1517 13)) + (let __tmp1547 (Single __tmp1546)) + (let __tmp1548 (Get __tmp1517 14)) + (let __tmp1549 (Single __tmp1548)) + (let __tmp1550 (Get __tmp1517 15)) + (let __tmp1551 (Single __tmp1550)) + (let __tmp1552 (Get __tmp1517 16)) + (let __tmp1553 (Single __tmp1552)) + (let __tmp1554 (Get __tmp1517 17)) + (let __tmp1555 (Single __tmp1554)) + (let __tmp1556 (Get __tmp1517 18)) + (let __tmp1557 (Single __tmp1556)) + (let __tmp1558 (Get __tmp1517 20)) + (let __tmp1559 (Single __tmp1558)) + (let __tmp1560 (Get __tmp1517 21)) + (let __tmp1561 (Single __tmp1560)) + (let __tmp1562 (Concat __tmp1559 __tmp1561)) + (let __tmp1563 (Concat __tmp1557 __tmp1562)) + (let __tmp1564 (Concat __tmp1555 __tmp1563)) + (let __tmp1565 (Concat __tmp1553 __tmp1564)) + (let __tmp1566 (Concat __tmp1551 __tmp1565)) + (let __tmp1567 (Concat __tmp1549 __tmp1566)) + (let __tmp1568 (Concat __tmp1547 __tmp1567)) + (let __tmp1569 (Concat __tmp1545 __tmp1568)) + (let __tmp1570 (Concat __tmp1543 __tmp1569)) + (let __tmp1571 (Concat __tmp1541 __tmp1570)) + (let __tmp1572 (Concat __tmp1539 __tmp1571)) + (let __tmp1573 (Concat __tmp1537 __tmp1572)) + (let __tmp1574 (Concat __tmp1535 __tmp1573)) + (let __tmp1575 (Concat __tmp1533 __tmp1574)) + (let __tmp1576 (Concat __tmp1531 __tmp1575)) + (let __tmp1577 (Concat __tmp1529 __tmp1576)) + (let __tmp1578 (Concat __tmp1527 __tmp1577)) + (let __tmp1579 (Concat __tmp1525 __tmp1578)) + (let __tmp1580 (Concat __tmp1523 __tmp1579)) + (let __tmp1581 (Concat __tmp1521 __tmp1580)) + (let __tmp1582 (Concat __tmp1519 __tmp1581)) + (let __tmp1583 (DoWhile __tmp1376 __tmp1582)) + (let __tmp1584 (Get __tmp1583 0)) + (let __tmp1585 (Single __tmp1584)) + (let __tmp1586 (Get __tmp1583 1)) + (let __tmp1587 (Get __tmp1583 2)) + (let __tmp1588 (Bop __tmp1449 __tmp1586 __tmp1587)) + (let __tmp1589 (Single __tmp1588)) + (let __tmp1590 (Single __tmp1587)) + (let __tmp1591 (Get __tmp1583 3)) + (let __tmp1592 (Get __tmp1583 4)) + (let __tmp1593 (Bop __tmp358 __tmp1591 __tmp1592)) + (let __tmp1594 (Single __tmp1593)) + (let __tmp1595 (Single __tmp1592)) + (let __tmp1596 (Get __tmp1583 7)) + (let __tmp1597 (Single __tmp1596)) + (let __tmp1598 (Get __tmp1583 8)) + (let __tmp1599 (Single __tmp1598)) + (let __tmp1600 (Get __tmp1583 9)) + (let __tmp1601 (Single __tmp1600)) + (let __tmp1602 (Get __tmp1583 10)) + (let __tmp1603 (Single __tmp1602)) + (let __tmp1604 (Get __tmp1583 11)) + (let __tmp1605 (Single __tmp1604)) + (let __tmp1606 (Get __tmp1583 12)) + (let __tmp1607 (Single __tmp1606)) + (let __tmp1608 (Get __tmp1583 13)) + (let __tmp1609 (Single __tmp1608)) + (let __tmp1610 (Get __tmp1583 14)) + (let __tmp1611 (Single __tmp1610)) + (let __tmp1612 (Get __tmp1583 15)) + (let __tmp1613 (Single __tmp1612)) + (let __tmp1614 (Get __tmp1583 16)) + (let __tmp1615 (Single __tmp1614)) + (let __tmp1616 (Get __tmp1583 17)) + (let __tmp1617 (Single __tmp1616)) + (let __tmp1618 (Get __tmp1583 18)) + (let __tmp1619 (Single __tmp1618)) + (let __tmp1620 (Const __tmp361 __tmp1307 __tmp6)) + (let __tmp1621 (Single __tmp1620)) + (let __tmp1622 (Get __tmp1583 19)) + (let __tmp1623 (Single __tmp1622)) + (let __tmp1624 (Get __tmp1583 20)) + (let __tmp1625 (Single __tmp1624)) + (let __tmp1626 (Concat __tmp1623 __tmp1625)) + (let __tmp1627 (Concat __tmp1621 __tmp1626)) + (let __tmp1628 (Concat __tmp1619 __tmp1627)) + (let __tmp1629 (Concat __tmp1617 __tmp1628)) + (let __tmp1630 (Concat __tmp1615 __tmp1629)) + (let __tmp1631 (Concat __tmp1613 __tmp1630)) + (let __tmp1632 (Concat __tmp1611 __tmp1631)) + (let __tmp1633 (Concat __tmp1609 __tmp1632)) + (let __tmp1634 (Concat __tmp1607 __tmp1633)) + (let __tmp1635 (Concat __tmp1605 __tmp1634)) + (let __tmp1636 (Concat __tmp1603 __tmp1635)) + (let __tmp1637 (Concat __tmp1601 __tmp1636)) + (let __tmp1638 (Concat __tmp1599 __tmp1637)) + (let __tmp1639 (Concat __tmp1597 __tmp1638)) + (let __tmp1640 (Concat __tmp1595 __tmp1639)) + (let __tmp1641 (Concat __tmp1594 __tmp1640)) + (let __tmp1642 (Concat __tmp1590 __tmp1641)) + (let __tmp1643 (Concat __tmp1589 __tmp1642)) + (let __tmp1644 (Concat __tmp1585 __tmp1643)) + (let __tmp1645 (Const __tmp379 __tmp1307 __tmp6)) + (let __tmp1646 (Single __tmp1645)) + (let __tmp1647 (Concat __tmp1646 __tmp1348)) + (let __tmp1648 (Concat __tmp1343 __tmp1647)) + (let __tmp1649 (Concat __tmp1341 __tmp1648)) + (let __tmp1650 (Concat __tmp1339 __tmp1649)) + (let __tmp1651 (Concat __tmp1337 __tmp1650)) + (let __tmp1652 (Concat __tmp1335 __tmp1651)) + (let __tmp1653 (Concat __tmp1333 __tmp1652)) + (let __tmp1654 (Concat __tmp1331 __tmp1653)) + (let __tmp1655 (Concat __tmp1329 __tmp1654)) + (let __tmp1656 (Concat __tmp1328 __tmp1655)) + (let __tmp1657 (Concat __tmp1326 __tmp1656)) + (let __tmp1658 (Concat __tmp1324 __tmp1657)) + (let __tmp1659 (Concat __tmp1322 __tmp1658)) + (let __tmp1660 (Concat __tmp1320 __tmp1659)) + (let __tmp1661 (Concat __tmp1318 __tmp1660)) + (let __tmp1662 (Concat __tmp1317 __tmp1661)) + (let __tmp1663 (Concat __tmp1315 __tmp1662)) + (let __tmp1664 (Concat __tmp1313 __tmp1663)) + (let __tmp1665 (If __tmp1311 __tmp1365 __tmp1644 __tmp1664)) + (let __tmp1666 (Get __tmp1665 17)) + (let __tmp1667 (Single __tmp1666)) + (let __tmp1668 (Get __tmp1665 0)) + (let __tmp1669 (Single __tmp1668)) + (let __tmp1670 (Get __tmp1665 1)) + (let __tmp1671 (Single __tmp1670)) + (let __tmp1672 (Get __tmp1665 2)) + (let __tmp1673 (Single __tmp1672)) + (let __tmp1674 (Get __tmp1665 3)) + (let __tmp1675 (Single __tmp1674)) + (let __tmp1676 (Get __tmp1665 4)) + (let __tmp1677 (Single __tmp1676)) + (let __tmp1678 (Get __tmp1665 5)) + (let __tmp1679 (Single __tmp1678)) + (let __tmp1680 (Get __tmp1665 6)) + (let __tmp1681 (Single __tmp1680)) + (let __tmp1682 (Get __tmp1665 7)) + (let __tmp1683 (Single __tmp1682)) + (let __tmp1684 (Get __tmp1665 8)) + (let __tmp1685 (Single __tmp1684)) + (let __tmp1686 (Get __tmp1665 9)) + (let __tmp1687 (Single __tmp1686)) + (let __tmp1688 (Get __tmp1665 10)) + (let __tmp1689 (Single __tmp1688)) + (let __tmp1690 (Get __tmp1665 11)) + (let __tmp1691 (Single __tmp1690)) + (let __tmp1692 (Get __tmp1665 12)) + (let __tmp1693 (Single __tmp1692)) + (let __tmp1694 (Get __tmp1665 13)) + (let __tmp1695 (Single __tmp1694)) + (let __tmp1696 (Get __tmp1665 14)) + (let __tmp1697 (Single __tmp1696)) + (let __tmp1698 (Get __tmp1665 15)) + (let __tmp1699 (Single __tmp1698)) + (let __tmp1700 (Get __tmp1665 16)) + (let __tmp1701 (Single __tmp1700)) + (let __tmp1702 (Get __tmp1665 18)) + (let __tmp1703 (Single __tmp1702)) + (let __tmp1704 (Get __tmp1665 19)) + (let __tmp1705 (Single __tmp1704)) + (let __tmp1706 (Concat __tmp1703 __tmp1705)) + (let __tmp1707 (Concat __tmp1701 __tmp1706)) + (let __tmp1708 (Concat __tmp1699 __tmp1707)) + (let __tmp1709 (Concat __tmp1697 __tmp1708)) + (let __tmp1710 (Concat __tmp1695 __tmp1709)) + (let __tmp1711 (Concat __tmp1693 __tmp1710)) + (let __tmp1712 (Concat __tmp1691 __tmp1711)) + (let __tmp1713 (Concat __tmp1689 __tmp1712)) + (let __tmp1714 (Concat __tmp1687 __tmp1713)) + (let __tmp1715 (Concat __tmp1685 __tmp1714)) + (let __tmp1716 (Concat __tmp1683 __tmp1715)) + (let __tmp1717 (Concat __tmp1681 __tmp1716)) + (let __tmp1718 (Concat __tmp1679 __tmp1717)) + (let __tmp1719 (Concat __tmp1677 __tmp1718)) + (let __tmp1720 (Concat __tmp1675 __tmp1719)) + (let __tmp1721 (Concat __tmp1673 __tmp1720)) + (let __tmp1722 (Concat __tmp1671 __tmp1721)) + (let __tmp1723 (Concat __tmp1669 __tmp1722)) + (let __tmp1724 (Concat __tmp1667 __tmp1723)) + (let __tmp1725 (DoWhile __tmp1288 __tmp1724)) + (let __tmp1726 (Get __tmp1725 0)) + (let __tmp1727 (Single __tmp1726)) + (let __tmp1728 (Get __tmp1725 2)) + (let __tmp1729 (Single __tmp1728)) + (let __tmp1730 (Get __tmp1725 4)) + (let __tmp1731 (Single __tmp1730)) + (let __tmp1732 (Get __tmp1725 5)) + (let __tmp1733 (Single __tmp1732)) + (let __tmp1734 (Get __tmp1725 6)) + (let __tmp1735 (Single __tmp1734)) + (let __tmp1736 (Get __tmp1725 7)) + (let __tmp1737 (Single __tmp1736)) + (let __tmp1738 (Get __tmp1725 8)) + (let __tmp1739 (Single __tmp1738)) + (let __tmp1740 (Get __tmp1725 9)) + (let __tmp1741 (Single __tmp1740)) + (let __tmp1742 (Get __tmp1725 10)) + (let __tmp1743 (Single __tmp1742)) + (let __tmp1744 (Get __tmp1725 11)) + (let __tmp1745 (Single __tmp1744)) + (let __tmp1746 (Get __tmp1725 12)) + (let __tmp1747 (Single __tmp1746)) + (let __tmp1748 (Get __tmp1725 13)) + (let __tmp1749 (Single __tmp1748)) + (let __tmp1750 (Get __tmp1725 14)) + (let __tmp1751 (Single __tmp1750)) + (let __tmp1752 (Get __tmp1725 15)) + (let __tmp1753 (Single __tmp1752)) + (let __tmp1754 (Get __tmp1725 16)) + (let __tmp1755 (Single __tmp1754)) + (let __tmp1756 (Concat __tmp1753 __tmp1755)) + (let __tmp1757 (Concat __tmp1751 __tmp1756)) + (let __tmp1758 (Concat __tmp1749 __tmp1757)) + (let __tmp1759 (Concat __tmp1747 __tmp1758)) + (let __tmp1760 (Concat __tmp1745 __tmp1759)) + (let __tmp1761 (Concat __tmp1743 __tmp1760)) + (let __tmp1762 (Concat __tmp1741 __tmp1761)) + (let __tmp1763 (Concat __tmp1739 __tmp1762)) + (let __tmp1764 (Concat __tmp1737 __tmp1763)) + (let __tmp1765 (Concat __tmp1735 __tmp1764)) + (let __tmp1766 (Concat __tmp1733 __tmp1765)) + (let __tmp1767 (Concat __tmp1731 __tmp1766)) + (let __tmp1768 (Concat __tmp1238 __tmp1767)) + (let __tmp1769 (Concat __tmp1729 __tmp1768)) + (let __tmp1770 (Concat __tmp1233 __tmp1769)) + (let __tmp1771 (Concat __tmp1727 __tmp1770)) + (let __tmp1772 (TCons __tmp115 __tmp1)) + (let __tmp1773 (TCons __tmp113 __tmp1772)) + (let __tmp1774 (TCons __tmp114 __tmp1773)) + (let __tmp1775 (TCons __tmp115 __tmp1774)) + (let __tmp1776 (TCons __tmp113 __tmp1775)) + (let __tmp1777 (TCons __tmp113 __tmp1776)) + (let __tmp1778 (TCons __tmp114 __tmp1777)) + (let __tmp1779 (TCons __tmp115 __tmp1778)) + (let __tmp1780 (TCons __tmp113 __tmp1779)) + (let __tmp1781 (TCons __tmp113 __tmp1780)) + (let __tmp1782 (TCons __tmp115 __tmp1781)) + (let __tmp1783 (TCons __tmp114 __tmp1782)) + (let __tmp1784 (TCons __tmp115 __tmp1783)) + (let __tmp1785 (TCons __tmp115 __tmp1784)) + (let __tmp1786 (TCons __tmp113 __tmp1785)) + (let __tmp1787 (TCons __tmp113 __tmp1786)) + (let __tmp1788 (TCons __tmp0 __tmp1787)) + (let __tmp1789 (TupleT __tmp1788)) + (let __tmp1790 (Arg __tmp1789 __tmp6)) + (let __tmp1791 (Get __tmp1790 3)) + (let __tmp1792 (Get __tmp1790 16)) + (let __tmp1793 (Bop __tmp112 __tmp1791 __tmp1792)) + (let __tmp1794 (Get __tmp1790 0)) + (let __tmp1795 (Single __tmp1794)) + (let __tmp1796 (Get __tmp1790 1)) + (let __tmp1797 (Single __tmp1796)) + (let __tmp1798 (Get __tmp1790 2)) + (let __tmp1799 (Single __tmp1798)) + (let __tmp1800 (Single __tmp1791)) + (let __tmp1801 (Get __tmp1790 4)) + (let __tmp1802 (Single __tmp1801)) + (let __tmp1803 (Get __tmp1790 5)) + (let __tmp1804 (Single __tmp1803)) + (let __tmp1805 (Get __tmp1790 6)) + (let __tmp1806 (Single __tmp1805)) + (let __tmp1807 (Get __tmp1790 7)) + (let __tmp1808 (Single __tmp1807)) + (let __tmp1809 (Get __tmp1790 8)) + (let __tmp1810 (Single __tmp1809)) + (let __tmp1811 (Get __tmp1790 9)) + (let __tmp1812 (Single __tmp1811)) + (let __tmp1813 (Get __tmp1790 10)) + (let __tmp1814 (Single __tmp1813)) + (let __tmp1815 (Get __tmp1790 11)) + (let __tmp1816 (Single __tmp1815)) + (let __tmp1817 (Get __tmp1790 12)) + (let __tmp1818 (Single __tmp1817)) + (let __tmp1819 (Get __tmp1790 13)) + (let __tmp1820 (Single __tmp1819)) + (let __tmp1821 (Get __tmp1790 14)) + (let __tmp1822 (Single __tmp1821)) + (let __tmp1823 (Get __tmp1790 15)) + (let __tmp1824 (Single __tmp1823)) + (let __tmp1825 (Single __tmp1792)) + (let __tmp1826 (Concat __tmp1824 __tmp1825)) + (let __tmp1827 (Concat __tmp1822 __tmp1826)) + (let __tmp1828 (Concat __tmp1820 __tmp1827)) + (let __tmp1829 (Concat __tmp1818 __tmp1828)) + (let __tmp1830 (Concat __tmp1816 __tmp1829)) + (let __tmp1831 (Concat __tmp1814 __tmp1830)) + (let __tmp1832 (Concat __tmp1812 __tmp1831)) + (let __tmp1833 (Concat __tmp1810 __tmp1832)) + (let __tmp1834 (Concat __tmp1808 __tmp1833)) + (let __tmp1835 (Concat __tmp1806 __tmp1834)) + (let __tmp1836 (Concat __tmp1804 __tmp1835)) + (let __tmp1837 (Concat __tmp1802 __tmp1836)) + (let __tmp1838 (Concat __tmp1800 __tmp1837)) + (let __tmp1839 (Concat __tmp1799 __tmp1838)) + (let __tmp1840 (Concat __tmp1797 __tmp1839)) + (let __tmp1841 (Concat __tmp1795 __tmp1840)) + (let __tmp1842 (Const __tmp95 __tmp1789 __tmp6)) + (let __tmp1843 (Single __tmp1842)) + (let __tmp1844 (Const __tmp83 __tmp1789 __tmp6)) + (let __tmp1845 (Single __tmp1844)) + (let __tmp1846 (Concat __tmp1845 __tmp1836)) + (let __tmp1847 (Concat __tmp1843 __tmp1846)) + (let __tmp1848 (Concat __tmp1802 __tmp1847)) + (let __tmp1849 (Concat __tmp1800 __tmp1848)) + (let __tmp1850 (Concat __tmp1799 __tmp1849)) + (let __tmp1851 (Concat __tmp1797 __tmp1850)) + (let __tmp1852 (Concat __tmp1795 __tmp1851)) + (let __tmp1853 (TCons __tmp113 __tmp1784)) + (let __tmp1854 (TCons __tmp115 __tmp1853)) + (let __tmp1855 (TCons __tmp115 __tmp1854)) + (let __tmp1856 (TCons __tmp113 __tmp1855)) + (let __tmp1857 (TCons __tmp113 __tmp1856)) + (let __tmp1858 (TCons __tmp0 __tmp1857)) + (let __tmp1859 (TupleT __tmp1858)) + (let __tmp1860 (Arg __tmp1859 __tmp6)) + (let __tmp1861 (Get __tmp1860 6)) + (let __tmp1862 (Get __tmp1860 15)) + (let __tmp1863 (Bop __tmp112 __tmp1861 __tmp1862)) + (let __tmp1864 (Get __tmp1860 0)) + (let __tmp1865 (Single __tmp1864)) + (let __tmp1866 (Get __tmp1860 1)) + (let __tmp1867 (Single __tmp1866)) + (let __tmp1868 (Get __tmp1860 2)) + (let __tmp1869 (Single __tmp1868)) + (let __tmp1870 (Get __tmp1860 3)) + (let __tmp1871 (Single __tmp1870)) + (let __tmp1872 (Get __tmp1860 4)) + (let __tmp1873 (Single __tmp1872)) + (let __tmp1874 (Get __tmp1860 5)) + (let __tmp1875 (Single __tmp1874)) + (let __tmp1876 (Single __tmp1861)) + (let __tmp1877 (Get __tmp1860 7)) + (let __tmp1878 (Single __tmp1877)) + (let __tmp1879 (Get __tmp1860 8)) + (let __tmp1880 (Single __tmp1879)) + (let __tmp1881 (Get __tmp1860 9)) + (let __tmp1882 (Single __tmp1881)) + (let __tmp1883 (Get __tmp1860 10)) + (let __tmp1884 (Single __tmp1883)) + (let __tmp1885 (Get __tmp1860 11)) + (let __tmp1886 (Single __tmp1885)) + (let __tmp1887 (Get __tmp1860 12)) + (let __tmp1888 (Single __tmp1887)) + (let __tmp1889 (Get __tmp1860 13)) + (let __tmp1890 (Single __tmp1889)) + (let __tmp1891 (Get __tmp1860 14)) + (let __tmp1892 (Single __tmp1891)) + (let __tmp1893 (Single __tmp1862)) + (let __tmp1894 (Get __tmp1860 16)) + (let __tmp1895 (Single __tmp1894)) + (let __tmp1896 (Get __tmp1860 17)) + (let __tmp1897 (Single __tmp1896)) + (let __tmp1898 (Get __tmp1860 18)) + (let __tmp1899 (Single __tmp1898)) + (let __tmp1900 (Concat __tmp1897 __tmp1899)) + (let __tmp1901 (Concat __tmp1895 __tmp1900)) + (let __tmp1902 (Concat __tmp1893 __tmp1901)) + (let __tmp1903 (Concat __tmp1892 __tmp1902)) + (let __tmp1904 (Concat __tmp1890 __tmp1903)) + (let __tmp1905 (Concat __tmp1888 __tmp1904)) + (let __tmp1906 (Concat __tmp1886 __tmp1905)) + (let __tmp1907 (Concat __tmp1884 __tmp1906)) + (let __tmp1908 (Concat __tmp1882 __tmp1907)) + (let __tmp1909 (Concat __tmp1880 __tmp1908)) + (let __tmp1910 (Concat __tmp1878 __tmp1909)) + (let __tmp1911 (Concat __tmp1876 __tmp1910)) + (let __tmp1912 (Concat __tmp1875 __tmp1911)) + (let __tmp1913 (Concat __tmp1873 __tmp1912)) + (let __tmp1914 (Concat __tmp1871 __tmp1913)) + (let __tmp1915 (Concat __tmp1869 __tmp1914)) + (let __tmp1916 (Concat __tmp1867 __tmp1915)) + (let __tmp1917 (Concat __tmp1865 __tmp1916)) + (let __tmp1918 (Bop __tmp1449 __tmp1874 __tmp1868)) + (let __tmp1919 (Bop __tmp330 __tmp1866 __tmp1918)) + (let __tmp1920 (Single __tmp1919)) + (let __tmp1921 (Concat __tmp1897 __tmp1865)) + (let __tmp1922 (Concat __tmp1920 __tmp1921)) + (let __tmp1923 (Call 'fmod' __tmp1922)) + (let __tmp1924 (Get __tmp1923 0)) + (let __tmp1925 (Bop __tmp1448 __tmp1924 __tmp1896)) + (let __tmp1926 (Single __tmp1925)) + (let __tmp1927 (Get __tmp1923 1)) + (let __tmp1928 (Single __tmp1927)) + (let __tmp1929 (Concat __tmp1926 __tmp1928)) + (let __tmp1930 (Concat __tmp1893 __tmp1929)) + (let __tmp1931 (Concat __tmp1876 __tmp1930)) + (let __tmp1932 (Concat __tmp1871 __tmp1931)) + (let __tmp1933 (Concat __tmp1895 __tmp1932)) + (let __tmp1934 (Call 'matrix_set' __tmp1933)) + (let __tmp1935 (Get __tmp1934 0)) + (let __tmp1936 (Single __tmp1935)) + (let __tmp1937 (Single __tmp1918)) + (let __tmp1938 (Bop __tmp358 __tmp1861 __tmp1872)) + (let __tmp1939 (Single __tmp1938)) + (let __tmp1940 (Const __tmp361 __tmp1859 __tmp6)) + (let __tmp1941 (Single __tmp1940)) + (let __tmp1942 (Concat __tmp1941 __tmp1901)) + (let __tmp1943 (Concat __tmp1893 __tmp1942)) + (let __tmp1944 (Concat __tmp1892 __tmp1943)) + (let __tmp1945 (Concat __tmp1890 __tmp1944)) + (let __tmp1946 (Concat __tmp1888 __tmp1945)) + (let __tmp1947 (Concat __tmp1886 __tmp1946)) + (let __tmp1948 (Concat __tmp1884 __tmp1947)) + (let __tmp1949 (Concat __tmp1882 __tmp1948)) + (let __tmp1950 (Concat __tmp1880 __tmp1949)) + (let __tmp1951 (Concat __tmp1878 __tmp1950)) + (let __tmp1952 (Concat __tmp1939 __tmp1951)) + (let __tmp1953 (Concat __tmp1937 __tmp1952)) + (let __tmp1954 (Concat __tmp1873 __tmp1953)) + (let __tmp1955 (Concat __tmp1871 __tmp1954)) + (let __tmp1956 (Concat __tmp1869 __tmp1955)) + (let __tmp1957 (Concat __tmp1867 __tmp1956)) + (let __tmp1958 (Concat __tmp1936 __tmp1957)) + (let __tmp1959 (Const __tmp379 __tmp1859 __tmp6)) + (let __tmp1960 (Single __tmp1959)) + (let __tmp1961 (Concat __tmp1960 __tmp1901)) + (let __tmp1962 (Concat __tmp1893 __tmp1961)) + (let __tmp1963 (Concat __tmp1892 __tmp1962)) + (let __tmp1964 (Concat __tmp1890 __tmp1963)) + (let __tmp1965 (Concat __tmp1888 __tmp1964)) + (let __tmp1966 (Concat __tmp1886 __tmp1965)) + (let __tmp1967 (Concat __tmp1884 __tmp1966)) + (let __tmp1968 (Concat __tmp1882 __tmp1967)) + (let __tmp1969 (Concat __tmp1880 __tmp1968)) + (let __tmp1970 (Concat __tmp1878 __tmp1969)) + (let __tmp1971 (Concat __tmp1876 __tmp1970)) + (let __tmp1972 (Concat __tmp1875 __tmp1971)) + (let __tmp1973 (Concat __tmp1873 __tmp1972)) + (let __tmp1974 (Concat __tmp1871 __tmp1973)) + (let __tmp1975 (Concat __tmp1869 __tmp1974)) + (let __tmp1976 (Concat __tmp1867 __tmp1975)) + (let __tmp1977 (Concat __tmp1865 __tmp1976)) + (let __tmp1978 (If __tmp1863 __tmp1917 __tmp1958 __tmp1977)) + (let __tmp1979 (Get __tmp1978 16)) + (let __tmp1980 (Single __tmp1979)) + (let __tmp1981 (Get __tmp1978 0)) + (let __tmp1982 (Single __tmp1981)) + (let __tmp1983 (Get __tmp1978 1)) + (let __tmp1984 (Single __tmp1983)) + (let __tmp1985 (Get __tmp1978 2)) + (let __tmp1986 (Single __tmp1985)) + (let __tmp1987 (Get __tmp1978 3)) + (let __tmp1988 (Single __tmp1987)) + (let __tmp1989 (Get __tmp1978 4)) + (let __tmp1990 (Single __tmp1989)) + (let __tmp1991 (Get __tmp1978 5)) + (let __tmp1992 (Single __tmp1991)) + (let __tmp1993 (Get __tmp1978 6)) + (let __tmp1994 (Single __tmp1993)) + (let __tmp1995 (Get __tmp1978 7)) + (let __tmp1996 (Single __tmp1995)) + (let __tmp1997 (Get __tmp1978 8)) + (let __tmp1998 (Single __tmp1997)) + (let __tmp1999 (Get __tmp1978 9)) + (let __tmp2000 (Single __tmp1999)) + (let __tmp2001 (Get __tmp1978 10)) + (let __tmp2002 (Single __tmp2001)) + (let __tmp2003 (Get __tmp1978 11)) + (let __tmp2004 (Single __tmp2003)) + (let __tmp2005 (Get __tmp1978 12)) + (let __tmp2006 (Single __tmp2005)) + (let __tmp2007 (Get __tmp1978 13)) + (let __tmp2008 (Single __tmp2007)) + (let __tmp2009 (Get __tmp1978 14)) + (let __tmp2010 (Single __tmp2009)) + (let __tmp2011 (Get __tmp1978 15)) + (let __tmp2012 (Single __tmp2011)) + (let __tmp2013 (Get __tmp1978 17)) + (let __tmp2014 (Single __tmp2013)) + (let __tmp2015 (Get __tmp1978 18)) + (let __tmp2016 (Single __tmp2015)) + (let __tmp2017 (Get __tmp1978 19)) + (let __tmp2018 (Single __tmp2017)) + (let __tmp2019 (Concat __tmp2016 __tmp2018)) + (let __tmp2020 (Concat __tmp2014 __tmp2019)) + (let __tmp2021 (Concat __tmp2012 __tmp2020)) + (let __tmp2022 (Concat __tmp2010 __tmp2021)) + (let __tmp2023 (Concat __tmp2008 __tmp2022)) + (let __tmp2024 (Concat __tmp2006 __tmp2023)) + (let __tmp2025 (Concat __tmp2004 __tmp2024)) + (let __tmp2026 (Concat __tmp2002 __tmp2025)) + (let __tmp2027 (Concat __tmp2000 __tmp2026)) + (let __tmp2028 (Concat __tmp1998 __tmp2027)) + (let __tmp2029 (Concat __tmp1996 __tmp2028)) + (let __tmp2030 (Concat __tmp1994 __tmp2029)) + (let __tmp2031 (Concat __tmp1992 __tmp2030)) + (let __tmp2032 (Concat __tmp1990 __tmp2031)) + (let __tmp2033 (Concat __tmp1988 __tmp2032)) + (let __tmp2034 (Concat __tmp1986 __tmp2033)) + (let __tmp2035 (Concat __tmp1984 __tmp2034)) + (let __tmp2036 (Concat __tmp1982 __tmp2035)) + (let __tmp2037 (Concat __tmp1980 __tmp2036)) + (let __tmp2038 (DoWhile __tmp1852 __tmp2037)) + (let __tmp2039 (Get __tmp2038 0)) + (let __tmp2040 (Single __tmp2039)) + (let __tmp2041 (Get __tmp2038 1)) + (let __tmp2042 (Get __tmp2038 2)) + (let __tmp2043 (Bop __tmp1449 __tmp2041 __tmp2042)) + (let __tmp2044 (Single __tmp2043)) + (let __tmp2045 (Single __tmp2042)) + (let __tmp2046 (Get __tmp2038 3)) + (let __tmp2047 (Get __tmp2038 4)) + (let __tmp2048 (Bop __tmp358 __tmp2046 __tmp2047)) + (let __tmp2049 (Single __tmp2048)) + (let __tmp2050 (Single __tmp2047)) + (let __tmp2051 (Get __tmp2038 7)) + (let __tmp2052 (Single __tmp2051)) + (let __tmp2053 (Get __tmp2038 8)) + (let __tmp2054 (Single __tmp2053)) + (let __tmp2055 (Get __tmp2038 9)) + (let __tmp2056 (Single __tmp2055)) + (let __tmp2057 (Get __tmp2038 10)) + (let __tmp2058 (Single __tmp2057)) + (let __tmp2059 (Get __tmp2038 11)) + (let __tmp2060 (Single __tmp2059)) + (let __tmp2061 (Get __tmp2038 12)) + (let __tmp2062 (Single __tmp2061)) + (let __tmp2063 (Get __tmp2038 13)) + (let __tmp2064 (Single __tmp2063)) + (let __tmp2065 (Get __tmp2038 14)) + (let __tmp2066 (Single __tmp2065)) + (let __tmp2067 (Get __tmp2038 15)) + (let __tmp2068 (Single __tmp2067)) + (let __tmp2069 (Const __tmp361 __tmp1789 __tmp6)) + (let __tmp2070 (Single __tmp2069)) + (let __tmp2071 (Get __tmp2038 16)) + (let __tmp2072 (Single __tmp2071)) + (let __tmp2073 (Get __tmp2038 17)) + (let __tmp2074 (Single __tmp2073)) + (let __tmp2075 (Get __tmp2038 18)) + (let __tmp2076 (Single __tmp2075)) + (let __tmp2077 (Concat __tmp2074 __tmp2076)) + (let __tmp2078 (Concat __tmp2072 __tmp2077)) + (let __tmp2079 (Concat __tmp2070 __tmp2078)) + (let __tmp2080 (Concat __tmp2068 __tmp2079)) + (let __tmp2081 (Concat __tmp2066 __tmp2080)) + (let __tmp2082 (Concat __tmp2064 __tmp2081)) + (let __tmp2083 (Concat __tmp2062 __tmp2082)) + (let __tmp2084 (Concat __tmp2060 __tmp2083)) + (let __tmp2085 (Concat __tmp2058 __tmp2084)) + (let __tmp2086 (Concat __tmp2056 __tmp2085)) + (let __tmp2087 (Concat __tmp2054 __tmp2086)) + (let __tmp2088 (Concat __tmp2052 __tmp2087)) + (let __tmp2089 (Concat __tmp2050 __tmp2088)) + (let __tmp2090 (Concat __tmp2049 __tmp2089)) + (let __tmp2091 (Concat __tmp2045 __tmp2090)) + (let __tmp2092 (Concat __tmp2044 __tmp2091)) + (let __tmp2093 (Concat __tmp2040 __tmp2092)) + (let __tmp2094 (Const __tmp379 __tmp1789 __tmp6)) + (let __tmp2095 (Single __tmp2094)) + (let __tmp2096 (Concat __tmp2095 __tmp1827)) + (let __tmp2097 (Concat __tmp1820 __tmp2096)) + (let __tmp2098 (Concat __tmp1818 __tmp2097)) + (let __tmp2099 (Concat __tmp1816 __tmp2098)) + (let __tmp2100 (Concat __tmp1814 __tmp2099)) + (let __tmp2101 (Concat __tmp1812 __tmp2100)) + (let __tmp2102 (Concat __tmp1810 __tmp2101)) + (let __tmp2103 (Concat __tmp1808 __tmp2102)) + (let __tmp2104 (Concat __tmp1806 __tmp2103)) + (let __tmp2105 (Concat __tmp1804 __tmp2104)) + (let __tmp2106 (Concat __tmp1802 __tmp2105)) + (let __tmp2107 (Concat __tmp1800 __tmp2106)) + (let __tmp2108 (Concat __tmp1799 __tmp2107)) + (let __tmp2109 (Concat __tmp1797 __tmp2108)) + (let __tmp2110 (Concat __tmp1795 __tmp2109)) + (let __tmp2111 (If __tmp1793 __tmp1841 __tmp2093 __tmp2110)) + (let __tmp2112 (Get __tmp2111 14)) + (let __tmp2113 (Single __tmp2112)) + (let __tmp2114 (Get __tmp2111 0)) + (let __tmp2115 (Single __tmp2114)) + (let __tmp2116 (Get __tmp2111 1)) + (let __tmp2117 (Single __tmp2116)) + (let __tmp2118 (Get __tmp2111 2)) + (let __tmp2119 (Single __tmp2118)) + (let __tmp2120 (Get __tmp2111 3)) + (let __tmp2121 (Single __tmp2120)) + (let __tmp2122 (Get __tmp2111 4)) + (let __tmp2123 (Single __tmp2122)) + (let __tmp2124 (Get __tmp2111 5)) + (let __tmp2125 (Single __tmp2124)) + (let __tmp2126 (Get __tmp2111 6)) + (let __tmp2127 (Single __tmp2126)) + (let __tmp2128 (Get __tmp2111 7)) + (let __tmp2129 (Single __tmp2128)) + (let __tmp2130 (Get __tmp2111 8)) + (let __tmp2131 (Single __tmp2130)) + (let __tmp2132 (Get __tmp2111 9)) + (let __tmp2133 (Single __tmp2132)) + (let __tmp2134 (Get __tmp2111 10)) + (let __tmp2135 (Single __tmp2134)) + (let __tmp2136 (Get __tmp2111 11)) + (let __tmp2137 (Single __tmp2136)) + (let __tmp2138 (Get __tmp2111 12)) + (let __tmp2139 (Single __tmp2138)) + (let __tmp2140 (Get __tmp2111 13)) + (let __tmp2141 (Single __tmp2140)) + (let __tmp2142 (Get __tmp2111 15)) + (let __tmp2143 (Single __tmp2142)) + (let __tmp2144 (Get __tmp2111 16)) + (let __tmp2145 (Single __tmp2144)) + (let __tmp2146 (Get __tmp2111 17)) + (let __tmp2147 (Single __tmp2146)) + (let __tmp2148 (Concat __tmp2145 __tmp2147)) + (let __tmp2149 (Concat __tmp2143 __tmp2148)) + (let __tmp2150 (Concat __tmp2141 __tmp2149)) + (let __tmp2151 (Concat __tmp2139 __tmp2150)) + (let __tmp2152 (Concat __tmp2137 __tmp2151)) + (let __tmp2153 (Concat __tmp2135 __tmp2152)) + (let __tmp2154 (Concat __tmp2133 __tmp2153)) + (let __tmp2155 (Concat __tmp2131 __tmp2154)) + (let __tmp2156 (Concat __tmp2129 __tmp2155)) + (let __tmp2157 (Concat __tmp2127 __tmp2156)) + (let __tmp2158 (Concat __tmp2125 __tmp2157)) + (let __tmp2159 (Concat __tmp2123 __tmp2158)) + (let __tmp2160 (Concat __tmp2121 __tmp2159)) + (let __tmp2161 (Concat __tmp2119 __tmp2160)) + (let __tmp2162 (Concat __tmp2117 __tmp2161)) + (let __tmp2163 (Concat __tmp2115 __tmp2162)) + (let __tmp2164 (Concat __tmp2113 __tmp2163)) + (let __tmp2165 (DoWhile __tmp1771 __tmp2164)) + (let __tmp2166 (Get __tmp2165 0)) + (let __tmp2167 (Single __tmp2166)) + (let __tmp2168 (Get __tmp2165 2)) + (let __tmp2169 (Single __tmp2168)) + (let __tmp2170 (Get __tmp2165 4)) + (let __tmp2171 (Single __tmp2170)) + (let __tmp2172 (Get __tmp2165 5)) + (let __tmp2173 (Single __tmp2172)) + (let __tmp2174 (Get __tmp2165 6)) + (let __tmp2175 (Single __tmp2174)) + (let __tmp2176 (Get __tmp2165 7)) + (let __tmp2177 (Single __tmp2176)) + (let __tmp2178 (Get __tmp2165 8)) + (let __tmp2179 (Single __tmp2178)) + (let __tmp2180 (Get __tmp2165 9)) + (let __tmp2181 (Single __tmp2180)) + (let __tmp2182 (Get __tmp2165 10)) + (let __tmp2183 (Single __tmp2182)) + (let __tmp2184 (Get __tmp2165 11)) + (let __tmp2185 (Single __tmp2184)) + (let __tmp2186 (Get __tmp2165 12)) + (let __tmp2187 (Single __tmp2186)) + (let __tmp2188 (Get __tmp2165 13)) + (let __tmp2189 (Single __tmp2188)) + (let __tmp2190 (Concat __tmp2187 __tmp2189)) + (let __tmp2191 (Concat __tmp2185 __tmp2190)) + (let __tmp2192 (Concat __tmp2183 __tmp2191)) + (let __tmp2193 (Concat __tmp2181 __tmp2192)) + (let __tmp2194 (Concat __tmp2179 __tmp2193)) + (let __tmp2195 (Concat __tmp2177 __tmp2194)) + (let __tmp2196 (Concat __tmp2175 __tmp2195)) + (let __tmp2197 (Concat __tmp2173 __tmp2196)) + (let __tmp2198 (Concat __tmp2171 __tmp2197)) + (let __tmp2199 (Concat __tmp1238 __tmp2198)) + (let __tmp2200 (Concat __tmp2169 __tmp2199)) + (let __tmp2201 (Concat __tmp1233 __tmp2200)) + (let __tmp2202 (Concat __tmp2167 __tmp2201)) + (let __tmp2203 (TCons __tmp113 __tmp1773)) + (let __tmp2204 (TCons __tmp114 __tmp2203)) + (let __tmp2205 (TCons __tmp115 __tmp2204)) + (let __tmp2206 (TCons __tmp113 __tmp2205)) + (let __tmp2207 (TCons __tmp113 __tmp2206)) + (let __tmp2208 (TCons __tmp115 __tmp2207)) + (let __tmp2209 (TCons __tmp114 __tmp2208)) + (let __tmp2210 (TCons __tmp115 __tmp2209)) + (let __tmp2211 (TCons __tmp115 __tmp2210)) + (let __tmp2212 (TCons __tmp113 __tmp2211)) + (let __tmp2213 (TCons __tmp113 __tmp2212)) + (let __tmp2214 (TCons __tmp0 __tmp2213)) + (let __tmp2215 (TupleT __tmp2214)) + (let __tmp2216 (Arg __tmp2215 __tmp6)) + (let __tmp2217 (Get __tmp2216 3)) + (let __tmp2218 (Get __tmp2216 13)) + (let __tmp2219 (Bop __tmp112 __tmp2217 __tmp2218)) + (let __tmp2220 (Get __tmp2216 0)) + (let __tmp2221 (Single __tmp2220)) + (let __tmp2222 (Get __tmp2216 1)) + (let __tmp2223 (Single __tmp2222)) + (let __tmp2224 (Get __tmp2216 2)) + (let __tmp2225 (Single __tmp2224)) + (let __tmp2226 (Single __tmp2217)) + (let __tmp2227 (Get __tmp2216 4)) + (let __tmp2228 (Single __tmp2227)) + (let __tmp2229 (Get __tmp2216 5)) + (let __tmp2230 (Single __tmp2229)) + (let __tmp2231 (Get __tmp2216 6)) + (let __tmp2232 (Single __tmp2231)) + (let __tmp2233 (Get __tmp2216 7)) + (let __tmp2234 (Single __tmp2233)) + (let __tmp2235 (Get __tmp2216 8)) + (let __tmp2236 (Single __tmp2235)) + (let __tmp2237 (Get __tmp2216 9)) + (let __tmp2238 (Single __tmp2237)) + (let __tmp2239 (Get __tmp2216 10)) + (let __tmp2240 (Single __tmp2239)) + (let __tmp2241 (Get __tmp2216 11)) + (let __tmp2242 (Single __tmp2241)) + (let __tmp2243 (Get __tmp2216 12)) + (let __tmp2244 (Single __tmp2243)) + (let __tmp2245 (Single __tmp2218)) + (let __tmp2246 (Concat __tmp2244 __tmp2245)) + (let __tmp2247 (Concat __tmp2242 __tmp2246)) + (let __tmp2248 (Concat __tmp2240 __tmp2247)) + (let __tmp2249 (Concat __tmp2238 __tmp2248)) + (let __tmp2250 (Concat __tmp2236 __tmp2249)) + (let __tmp2251 (Concat __tmp2234 __tmp2250)) + (let __tmp2252 (Concat __tmp2232 __tmp2251)) + (let __tmp2253 (Concat __tmp2230 __tmp2252)) + (let __tmp2254 (Concat __tmp2228 __tmp2253)) + (let __tmp2255 (Concat __tmp2226 __tmp2254)) + (let __tmp2256 (Concat __tmp2225 __tmp2255)) + (let __tmp2257 (Concat __tmp2223 __tmp2256)) + (let __tmp2258 (Concat __tmp2221 __tmp2257)) + (let __tmp2259 (Const __tmp95 __tmp2215 __tmp6)) + (let __tmp2260 (Single __tmp2259)) + (let __tmp2261 (Const __tmp83 __tmp2215 __tmp6)) + (let __tmp2262 (Single __tmp2261)) + (let __tmp2263 (Concat __tmp2262 __tmp2253)) + (let __tmp2264 (Concat __tmp2260 __tmp2263)) + (let __tmp2265 (Concat __tmp2228 __tmp2264)) + (let __tmp2266 (Concat __tmp2226 __tmp2265)) + (let __tmp2267 (Concat __tmp2225 __tmp2266)) + (let __tmp2268 (Concat __tmp2223 __tmp2267)) + (let __tmp2269 (Concat __tmp2221 __tmp2268)) + (let __tmp2270 (TCons __tmp113 __tmp2210)) + (let __tmp2271 (TCons __tmp115 __tmp2270)) + (let __tmp2272 (TCons __tmp115 __tmp2271)) + (let __tmp2273 (TCons __tmp113 __tmp2272)) + (let __tmp2274 (TCons __tmp113 __tmp2273)) + (let __tmp2275 (TCons __tmp0 __tmp2274)) + (let __tmp2276 (TupleT __tmp2275)) + (let __tmp2277 (Arg __tmp2276 __tmp6)) + (let __tmp2278 (Get __tmp2277 6)) + (let __tmp2279 (Get __tmp2277 8)) + (let __tmp2280 (Bop __tmp112 __tmp2278 __tmp2279)) + (let __tmp2281 (Get __tmp2277 0)) + (let __tmp2282 (Single __tmp2281)) + (let __tmp2283 (Get __tmp2277 1)) + (let __tmp2284 (Single __tmp2283)) + (let __tmp2285 (Get __tmp2277 2)) + (let __tmp2286 (Single __tmp2285)) + (let __tmp2287 (Get __tmp2277 3)) + (let __tmp2288 (Single __tmp2287)) + (let __tmp2289 (Get __tmp2277 4)) + (let __tmp2290 (Single __tmp2289)) + (let __tmp2291 (Get __tmp2277 5)) + (let __tmp2292 (Single __tmp2291)) + (let __tmp2293 (Single __tmp2278)) + (let __tmp2294 (Get __tmp2277 7)) + (let __tmp2295 (Single __tmp2294)) + (let __tmp2296 (Single __tmp2279)) + (let __tmp2297 (Get __tmp2277 9)) + (let __tmp2298 (Single __tmp2297)) + (let __tmp2299 (Get __tmp2277 10)) + (let __tmp2300 (Single __tmp2299)) + (let __tmp2301 (Get __tmp2277 11)) + (let __tmp2302 (Single __tmp2301)) + (let __tmp2303 (Get __tmp2277 12)) + (let __tmp2304 (Single __tmp2303)) + (let __tmp2305 (Get __tmp2277 13)) + (let __tmp2306 (Single __tmp2305)) + (let __tmp2307 (Get __tmp2277 14)) + (let __tmp2308 (Single __tmp2307)) + (let __tmp2309 (Get __tmp2277 15)) + (let __tmp2310 (Single __tmp2309)) + (let __tmp2311 (Concat __tmp2308 __tmp2310)) + (let __tmp2312 (Concat __tmp2306 __tmp2311)) + (let __tmp2313 (Concat __tmp2304 __tmp2312)) + (let __tmp2314 (Concat __tmp2302 __tmp2313)) + (let __tmp2315 (Concat __tmp2300 __tmp2314)) + (let __tmp2316 (Concat __tmp2298 __tmp2315)) + (let __tmp2317 (Concat __tmp2296 __tmp2316)) + (let __tmp2318 (Concat __tmp2295 __tmp2317)) + (let __tmp2319 (Concat __tmp2293 __tmp2318)) + (let __tmp2320 (Concat __tmp2292 __tmp2319)) + (let __tmp2321 (Concat __tmp2290 __tmp2320)) + (let __tmp2322 (Concat __tmp2288 __tmp2321)) + (let __tmp2323 (Concat __tmp2286 __tmp2322)) + (let __tmp2324 (Concat __tmp2284 __tmp2323)) + (let __tmp2325 (Concat __tmp2282 __tmp2324)) + (let __tmp2326 (Bop __tmp1449 __tmp2291 __tmp2307)) + (let __tmp2327 (Bop __tmp330 __tmp2283 __tmp2326)) + (let __tmp2328 (Bop __tmp1449 __tmp2327 __tmp2285)) + (let __tmp2329 (Single __tmp2328)) + (let __tmp2330 (Concat __tmp2306 __tmp2282)) + (let __tmp2331 (Concat __tmp2329 __tmp2330)) + (let __tmp2332 (Call 'fmod' __tmp2331)) + (let __tmp2333 (Get __tmp2332 0)) + (let __tmp2334 (Bop __tmp1448 __tmp2333 __tmp2305)) + (let __tmp2335 (Single __tmp2334)) + (let __tmp2336 (Get __tmp2332 1)) + (let __tmp2337 (Single __tmp2336)) + (let __tmp2338 (Concat __tmp2335 __tmp2337)) + (let __tmp2339 (Concat __tmp2296 __tmp2338)) + (let __tmp2340 (Concat __tmp2293 __tmp2339)) + (let __tmp2341 (Concat __tmp2288 __tmp2340)) + (let __tmp2342 (Concat __tmp2304 __tmp2341)) + (let __tmp2343 (Call 'matrix_set' __tmp2342)) + (let __tmp2344 (Get __tmp2343 0)) + (let __tmp2345 (Single __tmp2344)) + (let __tmp2346 (Bop __tmp1449 __tmp2291 __tmp2285)) + (let __tmp2347 (Single __tmp2346)) + (let __tmp2348 (Bop __tmp358 __tmp2278 __tmp2289)) + (let __tmp2349 (Single __tmp2348)) + (let __tmp2350 (Const __tmp361 __tmp2276 __tmp6)) + (let __tmp2351 (Single __tmp2350)) + (let __tmp2352 (Concat __tmp2351 __tmp2313)) + (let __tmp2353 (Concat __tmp2302 __tmp2352)) + (let __tmp2354 (Concat __tmp2300 __tmp2353)) + (let __tmp2355 (Concat __tmp2298 __tmp2354)) + (let __tmp2356 (Concat __tmp2296 __tmp2355)) + (let __tmp2357 (Concat __tmp2295 __tmp2356)) + (let __tmp2358 (Concat __tmp2349 __tmp2357)) + (let __tmp2359 (Concat __tmp2347 __tmp2358)) + (let __tmp2360 (Concat __tmp2290 __tmp2359)) + (let __tmp2361 (Concat __tmp2288 __tmp2360)) + (let __tmp2362 (Concat __tmp2286 __tmp2361)) + (let __tmp2363 (Concat __tmp2284 __tmp2362)) + (let __tmp2364 (Concat __tmp2345 __tmp2363)) + (let __tmp2365 (Const __tmp379 __tmp2276 __tmp6)) + (let __tmp2366 (Single __tmp2365)) + (let __tmp2367 (Concat __tmp2366 __tmp2313)) + (let __tmp2368 (Concat __tmp2302 __tmp2367)) + (let __tmp2369 (Concat __tmp2300 __tmp2368)) + (let __tmp2370 (Concat __tmp2298 __tmp2369)) + (let __tmp2371 (Concat __tmp2296 __tmp2370)) + (let __tmp2372 (Concat __tmp2295 __tmp2371)) + (let __tmp2373 (Concat __tmp2293 __tmp2372)) + (let __tmp2374 (Concat __tmp2292 __tmp2373)) + (let __tmp2375 (Concat __tmp2290 __tmp2374)) + (let __tmp2376 (Concat __tmp2288 __tmp2375)) + (let __tmp2377 (Concat __tmp2286 __tmp2376)) + (let __tmp2378 (Concat __tmp2284 __tmp2377)) + (let __tmp2379 (Concat __tmp2282 __tmp2378)) + (let __tmp2380 (If __tmp2280 __tmp2325 __tmp2364 __tmp2379)) + (let __tmp2381 (Get __tmp2380 12)) + (let __tmp2382 (Single __tmp2381)) + (let __tmp2383 (Get __tmp2380 0)) + (let __tmp2384 (Single __tmp2383)) + (let __tmp2385 (Get __tmp2380 1)) + (let __tmp2386 (Single __tmp2385)) + (let __tmp2387 (Get __tmp2380 2)) + (let __tmp2388 (Single __tmp2387)) + (let __tmp2389 (Get __tmp2380 3)) + (let __tmp2390 (Single __tmp2389)) + (let __tmp2391 (Get __tmp2380 4)) + (let __tmp2392 (Single __tmp2391)) + (let __tmp2393 (Get __tmp2380 5)) + (let __tmp2394 (Single __tmp2393)) + (let __tmp2395 (Get __tmp2380 6)) + (let __tmp2396 (Single __tmp2395)) + (let __tmp2397 (Get __tmp2380 7)) + (let __tmp2398 (Single __tmp2397)) + (let __tmp2399 (Get __tmp2380 8)) + (let __tmp2400 (Single __tmp2399)) + (let __tmp2401 (Get __tmp2380 9)) + (let __tmp2402 (Single __tmp2401)) + (let __tmp2403 (Get __tmp2380 10)) + (let __tmp2404 (Single __tmp2403)) + (let __tmp2405 (Get __tmp2380 11)) + (let __tmp2406 (Single __tmp2405)) + (let __tmp2407 (Get __tmp2380 13)) + (let __tmp2408 (Single __tmp2407)) + (let __tmp2409 (Get __tmp2380 14)) + (let __tmp2410 (Single __tmp2409)) + (let __tmp2411 (Get __tmp2380 15)) + (let __tmp2412 (Single __tmp2411)) + (let __tmp2413 (Get __tmp2380 16)) + (let __tmp2414 (Single __tmp2413)) + (let __tmp2415 (Concat __tmp2412 __tmp2414)) + (let __tmp2416 (Concat __tmp2410 __tmp2415)) + (let __tmp2417 (Concat __tmp2408 __tmp2416)) + (let __tmp2418 (Concat __tmp2406 __tmp2417)) + (let __tmp2419 (Concat __tmp2404 __tmp2418)) + (let __tmp2420 (Concat __tmp2402 __tmp2419)) + (let __tmp2421 (Concat __tmp2400 __tmp2420)) + (let __tmp2422 (Concat __tmp2398 __tmp2421)) + (let __tmp2423 (Concat __tmp2396 __tmp2422)) + (let __tmp2424 (Concat __tmp2394 __tmp2423)) + (let __tmp2425 (Concat __tmp2392 __tmp2424)) + (let __tmp2426 (Concat __tmp2390 __tmp2425)) + (let __tmp2427 (Concat __tmp2388 __tmp2426)) + (let __tmp2428 (Concat __tmp2386 __tmp2427)) + (let __tmp2429 (Concat __tmp2384 __tmp2428)) + (let __tmp2430 (Concat __tmp2382 __tmp2429)) + (let __tmp2431 (DoWhile __tmp2269 __tmp2430)) + (let __tmp2432 (Get __tmp2431 0)) + (let __tmp2433 (Single __tmp2432)) + (let __tmp2434 (Get __tmp2431 1)) + (let __tmp2435 (Get __tmp2431 2)) + (let __tmp2436 (Bop __tmp1449 __tmp2434 __tmp2435)) + (let __tmp2437 (Single __tmp2436)) + (let __tmp2438 (Single __tmp2435)) + (let __tmp2439 (Get __tmp2431 3)) + (let __tmp2440 (Get __tmp2431 4)) + (let __tmp2441 (Bop __tmp358 __tmp2439 __tmp2440)) + (let __tmp2442 (Single __tmp2441)) + (let __tmp2443 (Single __tmp2440)) + (let __tmp2444 (Get __tmp2431 7)) + (let __tmp2445 (Single __tmp2444)) + (let __tmp2446 (Get __tmp2431 8)) + (let __tmp2447 (Single __tmp2446)) + (let __tmp2448 (Get __tmp2431 9)) + (let __tmp2449 (Single __tmp2448)) + (let __tmp2450 (Get __tmp2431 10)) + (let __tmp2451 (Single __tmp2450)) + (let __tmp2452 (Get __tmp2431 11)) + (let __tmp2453 (Single __tmp2452)) + (let __tmp2454 (Const __tmp361 __tmp2215 __tmp6)) + (let __tmp2455 (Single __tmp2454)) + (let __tmp2456 (Get __tmp2431 12)) + (let __tmp2457 (Single __tmp2456)) + (let __tmp2458 (Get __tmp2431 13)) + (let __tmp2459 (Single __tmp2458)) + (let __tmp2460 (Get __tmp2431 14)) + (let __tmp2461 (Single __tmp2460)) + (let __tmp2462 (Get __tmp2431 15)) + (let __tmp2463 (Single __tmp2462)) + (let __tmp2464 (Concat __tmp2461 __tmp2463)) + (let __tmp2465 (Concat __tmp2459 __tmp2464)) + (let __tmp2466 (Concat __tmp2457 __tmp2465)) + (let __tmp2467 (Concat __tmp2455 __tmp2466)) + (let __tmp2468 (Concat __tmp2453 __tmp2467)) + (let __tmp2469 (Concat __tmp2451 __tmp2468)) + (let __tmp2470 (Concat __tmp2449 __tmp2469)) + (let __tmp2471 (Concat __tmp2447 __tmp2470)) + (let __tmp2472 (Concat __tmp2445 __tmp2471)) + (let __tmp2473 (Concat __tmp2443 __tmp2472)) + (let __tmp2474 (Concat __tmp2442 __tmp2473)) + (let __tmp2475 (Concat __tmp2438 __tmp2474)) + (let __tmp2476 (Concat __tmp2437 __tmp2475)) + (let __tmp2477 (Concat __tmp2433 __tmp2476)) + (let __tmp2478 (Const __tmp379 __tmp2215 __tmp6)) + (let __tmp2479 (Single __tmp2478)) + (let __tmp2480 (Concat __tmp2479 __tmp2248)) + (let __tmp2481 (Concat __tmp2238 __tmp2480)) + (let __tmp2482 (Concat __tmp2236 __tmp2481)) + (let __tmp2483 (Concat __tmp2234 __tmp2482)) + (let __tmp2484 (Concat __tmp2232 __tmp2483)) + (let __tmp2485 (Concat __tmp2230 __tmp2484)) + (let __tmp2486 (Concat __tmp2228 __tmp2485)) + (let __tmp2487 (Concat __tmp2226 __tmp2486)) + (let __tmp2488 (Concat __tmp2225 __tmp2487)) + (let __tmp2489 (Concat __tmp2223 __tmp2488)) + (let __tmp2490 (Concat __tmp2221 __tmp2489)) + (let __tmp2491 (If __tmp2219 __tmp2258 __tmp2477 __tmp2490)) + (let __tmp2492 (Get __tmp2491 10)) + (let __tmp2493 (Single __tmp2492)) + (let __tmp2494 (Get __tmp2491 0)) + (let __tmp2495 (Single __tmp2494)) + (let __tmp2496 (Get __tmp2491 1)) + (let __tmp2497 (Single __tmp2496)) + (let __tmp2498 (Get __tmp2491 2)) + (let __tmp2499 (Single __tmp2498)) + (let __tmp2500 (Get __tmp2491 3)) + (let __tmp2501 (Single __tmp2500)) + (let __tmp2502 (Get __tmp2491 4)) + (let __tmp2503 (Single __tmp2502)) + (let __tmp2504 (Get __tmp2491 5)) + (let __tmp2505 (Single __tmp2504)) + (let __tmp2506 (Get __tmp2491 6)) + (let __tmp2507 (Single __tmp2506)) + (let __tmp2508 (Get __tmp2491 7)) + (let __tmp2509 (Single __tmp2508)) + (let __tmp2510 (Get __tmp2491 8)) + (let __tmp2511 (Single __tmp2510)) + (let __tmp2512 (Get __tmp2491 9)) + (let __tmp2513 (Single __tmp2512)) + (let __tmp2514 (Get __tmp2491 11)) + (let __tmp2515 (Single __tmp2514)) + (let __tmp2516 (Get __tmp2491 12)) + (let __tmp2517 (Single __tmp2516)) + (let __tmp2518 (Get __tmp2491 13)) + (let __tmp2519 (Single __tmp2518)) + (let __tmp2520 (Get __tmp2491 14)) + (let __tmp2521 (Single __tmp2520)) + (let __tmp2522 (Concat __tmp2519 __tmp2521)) + (let __tmp2523 (Concat __tmp2517 __tmp2522)) + (let __tmp2524 (Concat __tmp2515 __tmp2523)) + (let __tmp2525 (Concat __tmp2513 __tmp2524)) + (let __tmp2526 (Concat __tmp2511 __tmp2525)) + (let __tmp2527 (Concat __tmp2509 __tmp2526)) + (let __tmp2528 (Concat __tmp2507 __tmp2527)) + (let __tmp2529 (Concat __tmp2505 __tmp2528)) + (let __tmp2530 (Concat __tmp2503 __tmp2529)) + (let __tmp2531 (Concat __tmp2501 __tmp2530)) + (let __tmp2532 (Concat __tmp2499 __tmp2531)) + (let __tmp2533 (Concat __tmp2497 __tmp2532)) + (let __tmp2534 (Concat __tmp2495 __tmp2533)) + (let __tmp2535 (Concat __tmp2493 __tmp2534)) + (let __tmp2536 (DoWhile __tmp2202 __tmp2535)) + (let __tmp2537 (Get __tmp2536 0)) + (let __tmp2538 (Single __tmp2537)) + (let __tmp2539 (Get __tmp2536 2)) + (let __tmp2540 (Single __tmp2539)) + (let __tmp2541 (Get __tmp2536 4)) + (let __tmp2542 (Single __tmp2541)) + (let __tmp2543 (Get __tmp2536 5)) + (let __tmp2544 (Single __tmp2543)) + (let __tmp2545 (Get __tmp2536 6)) + (let __tmp2546 (Single __tmp2545)) + (let __tmp2547 (Get __tmp2536 7)) + (let __tmp2548 (Single __tmp2547)) + (let __tmp2549 (Get __tmp2536 8)) + (let __tmp2550 (Single __tmp2549)) + (let __tmp2551 (Get __tmp2536 9)) + (let __tmp2552 (Single __tmp2551)) + (let __tmp2553 (Concat __tmp2550 __tmp2552)) + (let __tmp2554 (Concat __tmp2548 __tmp2553)) + (let __tmp2555 (Concat __tmp2546 __tmp2554)) + (let __tmp2556 (Concat __tmp2544 __tmp2555)) + (let __tmp2557 (Concat __tmp2542 __tmp2556)) + (let __tmp2558 (Concat __tmp1238 __tmp2557)) + (let __tmp2559 (Concat __tmp2540 __tmp2558)) + (let __tmp2560 (Concat __tmp1233 __tmp2559)) + (let __tmp2561 (Concat __tmp2538 __tmp2560)) + (let __tmp2562 (TCons __tmp115 __tmp2203)) + (let __tmp2563 (TCons __tmp114 __tmp2562)) + (let __tmp2564 (TCons __tmp115 __tmp2563)) + (let __tmp2565 (TCons __tmp115 __tmp2564)) + (let __tmp2566 (TCons __tmp113 __tmp2565)) + (let __tmp2567 (TCons __tmp113 __tmp2566)) + (let __tmp2568 (TCons __tmp0 __tmp2567)) + (let __tmp2569 (TupleT __tmp2568)) + (let __tmp2570 (Arg __tmp2569 __tmp6)) + (let __tmp2571 (Get __tmp2570 3)) + (let __tmp2572 (Get __tmp2570 9)) + (let __tmp2573 (Bop __tmp112 __tmp2571 __tmp2572)) + (let __tmp2574 (Get __tmp2570 0)) + (let __tmp2575 (Single __tmp2574)) + (let __tmp2576 (Get __tmp2570 1)) + (let __tmp2577 (Single __tmp2576)) + (let __tmp2578 (Get __tmp2570 2)) + (let __tmp2579 (Single __tmp2578)) + (let __tmp2580 (Single __tmp2571)) + (let __tmp2581 (Get __tmp2570 4)) + (let __tmp2582 (Single __tmp2581)) + (let __tmp2583 (Get __tmp2570 5)) + (let __tmp2584 (Single __tmp2583)) + (let __tmp2585 (Get __tmp2570 6)) + (let __tmp2586 (Single __tmp2585)) + (let __tmp2587 (Get __tmp2570 7)) + (let __tmp2588 (Single __tmp2587)) + (let __tmp2589 (Get __tmp2570 8)) + (let __tmp2590 (Single __tmp2589)) + (let __tmp2591 (Single __tmp2572)) + (let __tmp2592 (Concat __tmp2590 __tmp2591)) + (let __tmp2593 (Concat __tmp2588 __tmp2592)) + (let __tmp2594 (Concat __tmp2586 __tmp2593)) + (let __tmp2595 (Concat __tmp2584 __tmp2594)) + (let __tmp2596 (Concat __tmp2582 __tmp2595)) + (let __tmp2597 (Concat __tmp2580 __tmp2596)) + (let __tmp2598 (Concat __tmp2579 __tmp2597)) + (let __tmp2599 (Concat __tmp2577 __tmp2598)) + (let __tmp2600 (Concat __tmp2575 __tmp2599)) + (let __tmp2601 (Const __tmp95 __tmp2569 __tmp6)) + (let __tmp2602 (Single __tmp2601)) + (let __tmp2603 (Const __tmp83 __tmp2569 __tmp6)) + (let __tmp2604 (Single __tmp2603)) + (let __tmp2605 (Concat __tmp2604 __tmp2595)) + (let __tmp2606 (Concat __tmp2602 __tmp2605)) + (let __tmp2607 (Concat __tmp2582 __tmp2606)) + (let __tmp2608 (Concat __tmp2580 __tmp2607)) + (let __tmp2609 (Concat __tmp2579 __tmp2608)) + (let __tmp2610 (Concat __tmp2577 __tmp2609)) + (let __tmp2611 (Concat __tmp2575 __tmp2610)) + (let __tmp2612 (TCons __tmp113 __tmp2564)) + (let __tmp2613 (TCons __tmp115 __tmp2612)) + (let __tmp2614 (TCons __tmp115 __tmp2613)) + (let __tmp2615 (TCons __tmp113 __tmp2614)) + (let __tmp2616 (TCons __tmp113 __tmp2615)) + (let __tmp2617 (TCons __tmp0 __tmp2616)) + (let __tmp2618 (TupleT __tmp2617)) + (let __tmp2619 (Arg __tmp2618 __tmp6)) + (let __tmp2620 (Get __tmp2619 6)) + (let __tmp2621 (Get __tmp2619 8)) + (let __tmp2622 (Bop __tmp112 __tmp2620 __tmp2621)) + (let __tmp2623 (Get __tmp2619 0)) + (let __tmp2624 (Single __tmp2623)) + (let __tmp2625 (Get __tmp2619 1)) + (let __tmp2626 (Single __tmp2625)) + (let __tmp2627 (Get __tmp2619 2)) + (let __tmp2628 (Single __tmp2627)) + (let __tmp2629 (Get __tmp2619 3)) + (let __tmp2630 (Single __tmp2629)) + (let __tmp2631 (Get __tmp2619 4)) + (let __tmp2632 (Single __tmp2631)) + (let __tmp2633 (Get __tmp2619 5)) + (let __tmp2634 (Single __tmp2633)) + (let __tmp2635 (Single __tmp2620)) + (let __tmp2636 (Get __tmp2619 7)) + (let __tmp2637 (Single __tmp2636)) + (let __tmp2638 (Single __tmp2621)) + (let __tmp2639 (Get __tmp2619 9)) + (let __tmp2640 (Single __tmp2639)) + (let __tmp2641 (Get __tmp2619 10)) + (let __tmp2642 (Single __tmp2641)) + (let __tmp2643 (Get __tmp2619 11)) + (let __tmp2644 (Single __tmp2643)) + (let __tmp2645 (Concat __tmp2642 __tmp2644)) + (let __tmp2646 (Concat __tmp2640 __tmp2645)) + (let __tmp2647 (Concat __tmp2638 __tmp2646)) + (let __tmp2648 (Concat __tmp2637 __tmp2647)) + (let __tmp2649 (Concat __tmp2635 __tmp2648)) + (let __tmp2650 (Concat __tmp2634 __tmp2649)) + (let __tmp2651 (Concat __tmp2632 __tmp2650)) + (let __tmp2652 (Concat __tmp2630 __tmp2651)) + (let __tmp2653 (Concat __tmp2628 __tmp2652)) + (let __tmp2654 (Concat __tmp2626 __tmp2653)) + (let __tmp2655 (Concat __tmp2624 __tmp2654)) + (let __tmp2656 (Bop __tmp1449 __tmp2633 __tmp2641)) + (let __tmp2657 (Bop __tmp330 __tmp2625 __tmp2656)) + (let __tmp2658 (Single __tmp2657)) + (let __tmp2659 (Concat __tmp2640 __tmp2624)) + (let __tmp2660 (Concat __tmp2658 __tmp2659)) + (let __tmp2661 (Call 'fmod' __tmp2660)) + (let __tmp2662 (Get __tmp2661 0)) + (let __tmp2663 (Bop __tmp1448 __tmp2662 __tmp2639)) + (let __tmp2664 (Single __tmp2663)) + (let __tmp2665 (Get __tmp2661 1)) + (let __tmp2666 (Single __tmp2665)) + (let __tmp2667 (Concat __tmp2664 __tmp2666)) + (let __tmp2668 (Concat __tmp2638 __tmp2667)) + (let __tmp2669 (Concat __tmp2635 __tmp2668)) + (let __tmp2670 (Concat __tmp2630 __tmp2669)) + (let __tmp2671 (Concat __tmp2637 __tmp2670)) + (let __tmp2672 (Call 'matrix_set' __tmp2671)) + (let __tmp2673 (Get __tmp2672 0)) + (let __tmp2674 (Single __tmp2673)) + (let __tmp2675 (Const __tmp361 __tmp2618 __tmp6)) + (let __tmp2676 (Single __tmp2675)) + (let __tmp2677 (Bop __tmp1449 __tmp2633 __tmp2627)) + (let __tmp2678 (Single __tmp2677)) + (let __tmp2679 (Bop __tmp358 __tmp2620 __tmp2631)) + (let __tmp2680 (Single __tmp2679)) + (let __tmp2681 (Concat __tmp2680 __tmp2648)) + (let __tmp2682 (Concat __tmp2678 __tmp2681)) + (let __tmp2683 (Concat __tmp2676 __tmp2682)) + (let __tmp2684 (Concat __tmp2632 __tmp2683)) + (let __tmp2685 (Concat __tmp2630 __tmp2684)) + (let __tmp2686 (Concat __tmp2628 __tmp2685)) + (let __tmp2687 (Concat __tmp2626 __tmp2686)) + (let __tmp2688 (Concat __tmp2674 __tmp2687)) + (let __tmp2689 (Const __tmp379 __tmp2618 __tmp6)) + (let __tmp2690 (Single __tmp2689)) + (let __tmp2691 (Concat __tmp2690 __tmp2650)) + (let __tmp2692 (Concat __tmp2632 __tmp2691)) + (let __tmp2693 (Concat __tmp2630 __tmp2692)) + (let __tmp2694 (Concat __tmp2628 __tmp2693)) + (let __tmp2695 (Concat __tmp2626 __tmp2694)) + (let __tmp2696 (Concat __tmp2624 __tmp2695)) + (let __tmp2697 (If __tmp2622 __tmp2655 __tmp2688 __tmp2696)) + (let __tmp2698 (Get __tmp2697 5)) + (let __tmp2699 (Single __tmp2698)) + (let __tmp2700 (Get __tmp2697 0)) + (let __tmp2701 (Single __tmp2700)) + (let __tmp2702 (Get __tmp2697 1)) + (let __tmp2703 (Single __tmp2702)) + (let __tmp2704 (Get __tmp2697 2)) + (let __tmp2705 (Single __tmp2704)) + (let __tmp2706 (Get __tmp2697 3)) + (let __tmp2707 (Single __tmp2706)) + (let __tmp2708 (Get __tmp2697 4)) + (let __tmp2709 (Single __tmp2708)) + (let __tmp2710 (Get __tmp2697 6)) + (let __tmp2711 (Single __tmp2710)) + (let __tmp2712 (Get __tmp2697 7)) + (let __tmp2713 (Single __tmp2712)) + (let __tmp2714 (Get __tmp2697 8)) + (let __tmp2715 (Single __tmp2714)) + (let __tmp2716 (Get __tmp2697 9)) + (let __tmp2717 (Single __tmp2716)) + (let __tmp2718 (Get __tmp2697 10)) + (let __tmp2719 (Single __tmp2718)) + (let __tmp2720 (Get __tmp2697 11)) + (let __tmp2721 (Single __tmp2720)) + (let __tmp2722 (Get __tmp2697 12)) + (let __tmp2723 (Single __tmp2722)) + (let __tmp2724 (Concat __tmp2721 __tmp2723)) + (let __tmp2725 (Concat __tmp2719 __tmp2724)) + (let __tmp2726 (Concat __tmp2717 __tmp2725)) + (let __tmp2727 (Concat __tmp2715 __tmp2726)) + (let __tmp2728 (Concat __tmp2713 __tmp2727)) + (let __tmp2729 (Concat __tmp2711 __tmp2728)) + (let __tmp2730 (Concat __tmp2709 __tmp2729)) + (let __tmp2731 (Concat __tmp2707 __tmp2730)) + (let __tmp2732 (Concat __tmp2705 __tmp2731)) + (let __tmp2733 (Concat __tmp2703 __tmp2732)) + (let __tmp2734 (Concat __tmp2701 __tmp2733)) + (let __tmp2735 (Concat __tmp2699 __tmp2734)) + (let __tmp2736 (DoWhile __tmp2611 __tmp2735)) + (let __tmp2737 (Get __tmp2736 0)) + (let __tmp2738 (Single __tmp2737)) + (let __tmp2739 (Const __tmp361 __tmp2569 __tmp6)) + (let __tmp2740 (Single __tmp2739)) + (let __tmp2741 (Get __tmp2736 1)) + (let __tmp2742 (Get __tmp2736 2)) + (let __tmp2743 (Bop __tmp1449 __tmp2741 __tmp2742)) + (let __tmp2744 (Single __tmp2743)) + (let __tmp2745 (Single __tmp2742)) + (let __tmp2746 (Get __tmp2736 3)) + (let __tmp2747 (Get __tmp2736 4)) + (let __tmp2748 (Bop __tmp358 __tmp2746 __tmp2747)) + (let __tmp2749 (Single __tmp2748)) + (let __tmp2750 (Single __tmp2747)) + (let __tmp2751 (Get __tmp2736 7)) + (let __tmp2752 (Single __tmp2751)) + (let __tmp2753 (Get __tmp2736 8)) + (let __tmp2754 (Single __tmp2753)) + (let __tmp2755 (Get __tmp2736 9)) + (let __tmp2756 (Single __tmp2755)) + (let __tmp2757 (Get __tmp2736 10)) + (let __tmp2758 (Single __tmp2757)) + (let __tmp2759 (Get __tmp2736 11)) + (let __tmp2760 (Single __tmp2759)) + (let __tmp2761 (Concat __tmp2758 __tmp2760)) + (let __tmp2762 (Concat __tmp2756 __tmp2761)) + (let __tmp2763 (Concat __tmp2754 __tmp2762)) + (let __tmp2764 (Concat __tmp2752 __tmp2763)) + (let __tmp2765 (Concat __tmp2750 __tmp2764)) + (let __tmp2766 (Concat __tmp2749 __tmp2765)) + (let __tmp2767 (Concat __tmp2745 __tmp2766)) + (let __tmp2768 (Concat __tmp2744 __tmp2767)) + (let __tmp2769 (Concat __tmp2740 __tmp2768)) + (let __tmp2770 (Concat __tmp2738 __tmp2769)) + (let __tmp2771 (Const __tmp379 __tmp2569 __tmp6)) + (let __tmp2772 (Single __tmp2771)) + (let __tmp2773 (Concat __tmp2772 __tmp2599)) + (let __tmp2774 (Concat __tmp2575 __tmp2773)) + (let __tmp2775 (If __tmp2573 __tmp2600 __tmp2770 __tmp2774)) + (let __tmp2776 (Get __tmp2775 1)) + (let __tmp2777 (Single __tmp2776)) + (let __tmp2778 (Get __tmp2775 0)) + (let __tmp2779 (Single __tmp2778)) + (let __tmp2780 (Get __tmp2775 2)) + (let __tmp2781 (Single __tmp2780)) + (let __tmp2782 (Get __tmp2775 3)) + (let __tmp2783 (Single __tmp2782)) + (let __tmp2784 (Get __tmp2775 4)) + (let __tmp2785 (Single __tmp2784)) + (let __tmp2786 (Get __tmp2775 5)) + (let __tmp2787 (Single __tmp2786)) + (let __tmp2788 (Get __tmp2775 6)) + (let __tmp2789 (Single __tmp2788)) + (let __tmp2790 (Get __tmp2775 7)) + (let __tmp2791 (Single __tmp2790)) + (let __tmp2792 (Get __tmp2775 8)) + (let __tmp2793 (Single __tmp2792)) + (let __tmp2794 (Get __tmp2775 9)) + (let __tmp2795 (Single __tmp2794)) + (let __tmp2796 (Get __tmp2775 10)) + (let __tmp2797 (Single __tmp2796)) + (let __tmp2798 (Concat __tmp2795 __tmp2797)) + (let __tmp2799 (Concat __tmp2793 __tmp2798)) + (let __tmp2800 (Concat __tmp2791 __tmp2799)) + (let __tmp2801 (Concat __tmp2789 __tmp2800)) + (let __tmp2802 (Concat __tmp2787 __tmp2801)) + (let __tmp2803 (Concat __tmp2785 __tmp2802)) + (let __tmp2804 (Concat __tmp2783 __tmp2803)) + (let __tmp2805 (Concat __tmp2781 __tmp2804)) + (let __tmp2806 (Concat __tmp2779 __tmp2805)) + (let __tmp2807 (Concat __tmp2777 __tmp2806)) + (let __tmp2808 (DoWhile __tmp2561 __tmp2807)) + (let __tmp2809 (Get __tmp2808 0)) + (let __tmp2810 (Single __tmp2809)) + (let __tmp2811 (Function 'init' __tmp1228 __tmp3 __tmp2810)) + (let __tmp2812 (TCons __tmp115 __tmp2)) + (let __tmp2813 (TCons __tmp115 __tmp2812)) + (let __tmp2814 (TupleT __tmp2813)) + (let __tmp2815 (TCons __tmp114 __tmp2)) + (let __tmp2816 (TupleT __tmp2815)) + (let __tmp2817 (Mul)) + (let __tmp2818 (Arg __tmp2814 __tmp6)) + (let __tmp2819 (Get __tmp2818 0)) + (let __tmp2820 (Get __tmp2818 1)) + (let __tmp2821 (Bop __tmp2817 __tmp2819 __tmp2820)) + (let __tmp2822 (Get __tmp2818 2)) + (let __tmp2823 (Alloc 0 __tmp2821 __tmp2822 __tmp114)) + (let __tmp2824 (Get __tmp2823 0)) + (let __tmp2825 (Single __tmp2824)) + (let __tmp2826 (Get __tmp2823 1)) + (let __tmp2827 (Single __tmp2826)) + (let __tmp2828 (Concat __tmp2825 __tmp2827)) + (let __tmp2829 (Function 'matrix_new' __tmp2814 __tmp2816 __tmp2828)) + (let __tmp2830 (TCons __tmp115 __tmp2813)) + (let __tmp2831 (TCons __tmp114 __tmp2830)) + (let __tmp2832 (TupleT __tmp2831)) + (let __tmp2833 (PtrAdd)) + (let __tmp2834 (Arg __tmp2832 __tmp6)) + (let __tmp2835 (Get __tmp2834 0)) + (let __tmp2836 (Get __tmp2834 1)) + (let __tmp2837 (Get __tmp2834 3)) + (let __tmp2838 (Bop __tmp2817 __tmp2836 __tmp2837)) + (let __tmp2839 (Get __tmp2834 2)) + (let __tmp2840 (Bop __tmp358 __tmp2838 __tmp2839)) + (let __tmp2841 (Bop __tmp2833 __tmp2835 __tmp2840)) + (let __tmp2842 (Single __tmp2841)) + (let __tmp2843 (Get __tmp2834 4)) + (let __tmp2844 (Single __tmp2843)) + (let __tmp2845 (Concat __tmp2842 __tmp2844)) + (let __tmp2846 (Function 'matrix_loc' __tmp2832 __tmp2816 __tmp2845)) + (let __tmp2847 (TupleT __tmp1216)) + (let __tmp2848 (Load)) + (let __tmp2849 (Single __tmp2835)) + (let __tmp2850 (Single __tmp2836)) + (let __tmp2851 (Single __tmp2839)) + (let __tmp2852 (Single __tmp2837)) + (let __tmp2853 (Concat __tmp2852 __tmp2844)) + (let __tmp2854 (Concat __tmp2851 __tmp2853)) + (let __tmp2855 (Concat __tmp2850 __tmp2854)) + (let __tmp2856 (Concat __tmp2849 __tmp2855)) + (let __tmp2857 (Call 'matrix_loc' __tmp2856)) + (let __tmp2858 (Get __tmp2857 0)) + (let __tmp2859 (Get __tmp2857 1)) + (let __tmp2860 (Bop __tmp2848 __tmp2858 __tmp2859)) + (let __tmp2861 (Get __tmp2860 0)) + (let __tmp2862 (Single __tmp2861)) + (let __tmp2863 (Get __tmp2860 1)) + (let __tmp2864 (Single __tmp2863)) + (let __tmp2865 (Concat __tmp2862 __tmp2864)) + (let __tmp2866 (Function 'matrix_get' __tmp2832 __tmp2847 __tmp2865)) + (let __tmp2867 (TCons __tmp115 __tmp1217)) + (let __tmp2868 (TCons __tmp115 __tmp2867)) + (let __tmp2869 (TCons __tmp114 __tmp2868)) + (let __tmp2870 (TupleT __tmp2869)) + (let __tmp2871 (Write)) + (let __tmp2872 (Arg __tmp2870 __tmp6)) + (let __tmp2873 (Get __tmp2872 0)) + (let __tmp2874 (Single __tmp2873)) + (let __tmp2875 (Get __tmp2872 1)) + (let __tmp2876 (Single __tmp2875)) + (let __tmp2877 (Get __tmp2872 2)) + (let __tmp2878 (Single __tmp2877)) + (let __tmp2879 (Get __tmp2872 3)) + (let __tmp2880 (Single __tmp2879)) + (let __tmp2881 (Get __tmp2872 5)) + (let __tmp2882 (Single __tmp2881)) + (let __tmp2883 (Concat __tmp2880 __tmp2882)) + (let __tmp2884 (Concat __tmp2878 __tmp2883)) + (let __tmp2885 (Concat __tmp2876 __tmp2884)) + (let __tmp2886 (Concat __tmp2874 __tmp2885)) + (let __tmp2887 (Call 'matrix_loc' __tmp2886)) + (let __tmp2888 (Get __tmp2887 0)) + (let __tmp2889 (Get __tmp2872 4)) + (let __tmp2890 (Get __tmp2887 1)) + (let __tmp2891 (Top __tmp2871 __tmp2888 __tmp2889 __tmp2890)) + (let __tmp2892 (Single __tmp2891)) + (let __tmp2893 (Function 'matrix_set' __tmp2870 __tmp3 __tmp2892)) + (let __tmp2894 (Bop __tmp2848 __tmp2888 __tmp2890)) + (let __tmp2895 (Get __tmp2894 0)) + (let __tmp2896 (Bop __tmp1449 __tmp2895 __tmp2889)) + (let __tmp2897 (Get __tmp2894 1)) + (let __tmp2898 (Top __tmp2871 __tmp2888 __tmp2896 __tmp2897)) + (let __tmp2899 (Single __tmp2898)) + (let __tmp2900 (Function 'matrix_incr' __tmp2870 __tmp3 __tmp2899)) + (let __tmp2901 (Bop __tmp330 __tmp2895 __tmp2889)) + (let __tmp2902 (Top __tmp2871 __tmp2888 __tmp2901 __tmp2897)) + (let __tmp2903 (Single __tmp2902)) + (let __tmp2904 (Function 'matrix_scale' __tmp2870 __tmp3 __tmp2903)) + (let __tmp2905 (TCons __tmp114 __tmp2813)) + (let __tmp2906 (TupleT __tmp2905)) + (let __tmp2907 (Arg __tmp2906 __tmp6)) + (let __tmp2908 (Get __tmp2907 3)) + (let __tmp2909 (Single __tmp2908)) + (let __tmp2910 (Const __tmp95 __tmp2906 __tmp6)) + (let __tmp2911 (Single __tmp2910)) + (let __tmp2912 (Const __tmp83 __tmp2906 __tmp6)) + (let __tmp2913 (Single __tmp2912)) + (let __tmp2914 (Const __tmp86 __tmp2906 __tmp6)) + (let __tmp2915 (Single __tmp2914)) + (let __tmp2916 (Get __tmp2907 0)) + (let __tmp2917 (Single __tmp2916)) + (let __tmp2918 (Get __tmp2907 1)) + (let __tmp2919 (Get __tmp2907 2)) + (let __tmp2920 (Bop __tmp2817 __tmp2918 __tmp2919)) + (let __tmp2921 (Single __tmp2920)) + (let __tmp2922 (Concat __tmp2917 __tmp2921)) + (let __tmp2923 (Concat __tmp2915 __tmp2922)) + (let __tmp2924 (Concat __tmp2913 __tmp2923)) + (let __tmp2925 (Concat __tmp2911 __tmp2924)) + (let __tmp2926 (Concat __tmp2909 __tmp2925)) + (let __tmp2927 (TCons __tmp114 __tmp1772)) + (let __tmp2928 (TCons __tmp115 __tmp2927)) + (let __tmp2929 (TCons __tmp115 __tmp2928)) + (let __tmp2930 (TCons __tmp113 __tmp2929)) + (let __tmp2931 (TCons __tmp0 __tmp2930)) + (let __tmp2932 (TupleT __tmp2931)) + (let __tmp2933 (Arg __tmp2932 __tmp6)) + (let __tmp2934 (Get __tmp2933 2)) + (let __tmp2935 (Get __tmp2933 5)) + (let __tmp2936 (Bop __tmp112 __tmp2934 __tmp2935)) + (let __tmp2937 (Get __tmp2933 0)) + (let __tmp2938 (Single __tmp2937)) + (let __tmp2939 (Get __tmp2933 1)) + (let __tmp2940 (Single __tmp2939)) + (let __tmp2941 (Single __tmp2934)) + (let __tmp2942 (Get __tmp2933 3)) + (let __tmp2943 (Single __tmp2942)) + (let __tmp2944 (Get __tmp2933 4)) + (let __tmp2945 (Single __tmp2944)) + (let __tmp2946 (Single __tmp2935)) + (let __tmp2947 (Concat __tmp2945 __tmp2946)) + (let __tmp2948 (Concat __tmp2943 __tmp2947)) + (let __tmp2949 (Concat __tmp2941 __tmp2948)) + (let __tmp2950 (Concat __tmp2940 __tmp2949)) + (let __tmp2951 (Concat __tmp2938 __tmp2950)) + (let __tmp2952 (Bop __tmp2833 __tmp2944 __tmp2934)) + (let __tmp2953 (Bop __tmp2848 __tmp2952 __tmp2937)) + (let __tmp2954 (Get __tmp2953 1)) + (let __tmp2955 (Single __tmp2954)) + (let __tmp2956 (Get __tmp2953 0)) + (let __tmp2957 (Bop __tmp1449 __tmp2939 __tmp2956)) + (let __tmp2958 (Single __tmp2957)) + (let __tmp2959 (Const __tmp361 __tmp2932 __tmp6)) + (let __tmp2960 (Single __tmp2959)) + (let __tmp2961 (Bop __tmp358 __tmp2934 __tmp2942)) + (let __tmp2962 (Single __tmp2961)) + (let __tmp2963 (Concat __tmp2962 __tmp2948)) + (let __tmp2964 (Concat __tmp2960 __tmp2963)) + (let __tmp2965 (Concat __tmp2958 __tmp2964)) + (let __tmp2966 (Concat __tmp2955 __tmp2965)) + (let __tmp2967 (Const __tmp379 __tmp2932 __tmp6)) + (let __tmp2968 (Single __tmp2967)) + (let __tmp2969 (Concat __tmp2968 __tmp2949)) + (let __tmp2970 (Concat __tmp2940 __tmp2969)) + (let __tmp2971 (Concat __tmp2938 __tmp2970)) + (let __tmp2972 (If __tmp2936 __tmp2951 __tmp2966 __tmp2971)) + (let __tmp2973 (Get __tmp2972 2)) + (let __tmp2974 (Single __tmp2973)) + (let __tmp2975 (Get __tmp2972 0)) + (let __tmp2976 (Single __tmp2975)) + (let __tmp2977 (Get __tmp2972 1)) + (let __tmp2978 (Single __tmp2977)) + (let __tmp2979 (Get __tmp2972 3)) + (let __tmp2980 (Single __tmp2979)) + (let __tmp2981 (Get __tmp2972 4)) + (let __tmp2982 (Single __tmp2981)) + (let __tmp2983 (Get __tmp2972 5)) + (let __tmp2984 (Single __tmp2983)) + (let __tmp2985 (Get __tmp2972 6)) + (let __tmp2986 (Single __tmp2985)) + (let __tmp2987 (Concat __tmp2984 __tmp2986)) + (let __tmp2988 (Concat __tmp2982 __tmp2987)) + (let __tmp2989 (Concat __tmp2980 __tmp2988)) + (let __tmp2990 (Concat __tmp2978 __tmp2989)) + (let __tmp2991 (Concat __tmp2976 __tmp2990)) + (let __tmp2992 (Concat __tmp2974 __tmp2991)) + (let __tmp2993 (DoWhile __tmp2926 __tmp2992)) + (let __tmp2994 (Get __tmp2993 1)) + (let __tmp2995 (Single __tmp2994)) + (let __tmp2996 (Get __tmp2993 0)) + (let __tmp2997 (Single __tmp2996)) + (let __tmp2998 (Concat __tmp2995 __tmp2997)) + (let __tmp2999 (Function 'matrix_sum' __tmp2906 __tmp2847 __tmp2998)) + (let __tmp3000 (TCons __tmp113 __tmp1216)) + (let __tmp3001 (TupleT __tmp3000)) + (let __tmp3002 (Arg __tmp3001 __tmp6)) + (let __tmp3003 (Get __tmp3002 2)) + (let __tmp3004 (Single __tmp3003)) + (let __tmp3005 (Get __tmp3002 0)) + (let __tmp3006 (Single __tmp3005)) + (let __tmp3007 (Const __tmp1247 __tmp3001 __tmp6)) + (let __tmp3008 (Single __tmp3007)) + (let __tmp3009 (Const __tmp95 __tmp3001 __tmp6)) + (let __tmp3010 (Single __tmp3009)) + (let __tmp3011 (Get __tmp3002 1)) + (let __tmp3012 (Single __tmp3011)) + (let __tmp3013 (Concat __tmp3010 __tmp3012)) + (let __tmp3014 (Concat __tmp3008 __tmp3013)) + (let __tmp3015 (Concat __tmp3006 __tmp3014)) + (let __tmp3016 (Concat __tmp3004 __tmp3015)) + (let __tmp3017 (FGreaterEq)) + (let __tmp3018 (TCons __tmp113 __tmp116)) + (let __tmp3019 (TCons __tmp113 __tmp3018)) + (let __tmp3020 (TCons __tmp113 __tmp3019)) + (let __tmp3021 (TCons __tmp0 __tmp3020)) + (let __tmp3022 (TupleT __tmp3021)) + (let __tmp3023 (Arg __tmp3022 __tmp6)) + (let __tmp3024 (Get __tmp3023 1)) + (let __tmp3025 (Get __tmp3023 4)) + (let __tmp3026 (Bop __tmp3017 __tmp3024 __tmp3025)) + (let __tmp3027 (Get __tmp3023 0)) + (let __tmp3028 (Single __tmp3027)) + (let __tmp3029 (Single __tmp3024)) + (let __tmp3030 (Get __tmp3023 2)) + (let __tmp3031 (Single __tmp3030)) + (let __tmp3032 (Get __tmp3023 3)) + (let __tmp3033 (Single __tmp3032)) + (let __tmp3034 (Single __tmp3025)) + (let __tmp3035 (Concat __tmp3033 __tmp3034)) + (let __tmp3036 (Concat __tmp3031 __tmp3035)) + (let __tmp3037 (Concat __tmp3029 __tmp3036)) + (let __tmp3038 (Concat __tmp3028 __tmp3037)) + (let __tmp3039 (Concat __tmp3034 __tmp3036)) + (let __tmp3040 (Concat __tmp3029 __tmp3039)) + (let __tmp3041 (Concat __tmp3028 __tmp3040)) + (let __tmp3042 (FSub)) + (let __tmp3043 (TCons __tmp113 __tmp3020)) + (let __tmp3044 (TCons __tmp0 __tmp3043)) + (let __tmp3045 (TupleT __tmp3044)) + (let __tmp3046 (Arg __tmp3045 __tmp6)) + (let __tmp3047 (Get __tmp3046 1)) + (let __tmp3048 (Get __tmp3046 2)) + (let __tmp3049 (Bop __tmp3042 __tmp3047 __tmp3048)) + (let __tmp3050 (Get __tmp3046 4)) + (let __tmp3051 (Bop __tmp3017 __tmp3049 __tmp3050)) + (let __tmp3052 (Get __tmp3046 0)) + (let __tmp3053 (Single __tmp3052)) + (let __tmp3054 (Single __tmp3047)) + (let __tmp3055 (Single __tmp3048)) + (let __tmp3056 (Get __tmp3046 3)) + (let __tmp3057 (Single __tmp3056)) + (let __tmp3058 (Single __tmp3050)) + (let __tmp3059 (Get __tmp3046 5)) + (let __tmp3060 (Single __tmp3059)) + (let __tmp3061 (Concat __tmp3058 __tmp3060)) + (let __tmp3062 (Concat __tmp3057 __tmp3061)) + (let __tmp3063 (Concat __tmp3055 __tmp3062)) + (let __tmp3064 (Concat __tmp3054 __tmp3063)) + (let __tmp3065 (Concat __tmp3053 __tmp3064)) + (let __tmp3066 (Bop __tmp330 __tmp3048 __tmp3056)) + (let __tmp3067 (Single __tmp3066)) + (let __tmp3068 (Const __tmp361 __tmp3045 __tmp6)) + (let __tmp3069 (Single __tmp3068)) + (let __tmp3070 (Concat __tmp3069 __tmp3061)) + (let __tmp3071 (Concat __tmp3057 __tmp3070)) + (let __tmp3072 (Concat __tmp3067 __tmp3071)) + (let __tmp3073 (Concat __tmp3054 __tmp3072)) + (let __tmp3074 (Concat __tmp3053 __tmp3073)) + (let __tmp3075 (Const __tmp379 __tmp3045 __tmp6)) + (let __tmp3076 (Single __tmp3075)) + (let __tmp3077 (Concat __tmp3076 __tmp3061)) + (let __tmp3078 (Concat __tmp3057 __tmp3077)) + (let __tmp3079 (Concat __tmp3055 __tmp3078)) + (let __tmp3080 (Concat __tmp3054 __tmp3079)) + (let __tmp3081 (Concat __tmp3053 __tmp3080)) + (let __tmp3082 (If __tmp3051 __tmp3065 __tmp3074 __tmp3081)) + (let __tmp3083 (Get __tmp3082 4)) + (let __tmp3084 (Single __tmp3083)) + (let __tmp3085 (Get __tmp3082 0)) + (let __tmp3086 (Single __tmp3085)) + (let __tmp3087 (Get __tmp3082 1)) + (let __tmp3088 (Single __tmp3087)) + (let __tmp3089 (Get __tmp3082 2)) + (let __tmp3090 (Single __tmp3089)) + (let __tmp3091 (Get __tmp3082 3)) + (let __tmp3092 (Single __tmp3091)) + (let __tmp3093 (Get __tmp3082 5)) + (let __tmp3094 (Single __tmp3093)) + (let __tmp3095 (Get __tmp3082 6)) + (let __tmp3096 (Single __tmp3095)) + (let __tmp3097 (Concat __tmp3094 __tmp3096)) + (let __tmp3098 (Concat __tmp3092 __tmp3097)) + (let __tmp3099 (Concat __tmp3090 __tmp3098)) + (let __tmp3100 (Concat __tmp3088 __tmp3099)) + (let __tmp3101 (Concat __tmp3086 __tmp3100)) + (let __tmp3102 (Concat __tmp3084 __tmp3101)) + (let __tmp3103 (DoWhile __tmp3041 __tmp3102)) + (let __tmp3104 (Get __tmp3103 0)) + (let __tmp3105 (Single __tmp3104)) + (let __tmp3106 (Get __tmp3103 1)) + (let __tmp3107 (Get __tmp3103 2)) + (let __tmp3108 (Get __tmp3103 3)) + (let __tmp3109 (Bop __tmp1448 __tmp3107 __tmp3108)) + (let __tmp3110 (Bop __tmp3042 __tmp3106 __tmp3109)) + (let __tmp3111 (Single __tmp3110)) + (let __tmp3112 (Const __tmp361 __tmp3022 __tmp6)) + (let __tmp3113 (Single __tmp3112)) + (let __tmp3114 (Single __tmp3108)) + (let __tmp3115 (Get __tmp3103 4)) + (let __tmp3116 (Single __tmp3115)) + (let __tmp3117 (Get __tmp3103 5)) + (let __tmp3118 (Single __tmp3117)) + (let __tmp3119 (Concat __tmp3116 __tmp3118)) + (let __tmp3120 (Concat __tmp3114 __tmp3119)) + (let __tmp3121 (Concat __tmp3113 __tmp3120)) + (let __tmp3122 (Concat __tmp3111 __tmp3121)) + (let __tmp3123 (Concat __tmp3105 __tmp3122)) + (let __tmp3124 (Const __tmp379 __tmp3022 __tmp6)) + (let __tmp3125 (Single __tmp3124)) + (let __tmp3126 (Concat __tmp3125 __tmp3036)) + (let __tmp3127 (Concat __tmp3029 __tmp3126)) + (let __tmp3128 (Concat __tmp3028 __tmp3127)) + (let __tmp3129 (If __tmp3026 __tmp3038 __tmp3123 __tmp3128)) + (let __tmp3130 (Get __tmp3129 2)) + (let __tmp3131 (Single __tmp3130)) + (let __tmp3132 (Get __tmp3129 0)) + (let __tmp3133 (Single __tmp3132)) + (let __tmp3134 (Get __tmp3129 1)) + (let __tmp3135 (Single __tmp3134)) + (let __tmp3136 (Get __tmp3129 3)) + (let __tmp3137 (Single __tmp3136)) + (let __tmp3138 (Get __tmp3129 4)) + (let __tmp3139 (Single __tmp3138)) + (let __tmp3140 (Get __tmp3129 5)) + (let __tmp3141 (Single __tmp3140)) + (let __tmp3142 (Concat __tmp3139 __tmp3141)) + (let __tmp3143 (Concat __tmp3137 __tmp3142)) + (let __tmp3144 (Concat __tmp3135 __tmp3143)) + (let __tmp3145 (Concat __tmp3133 __tmp3144)) + (let __tmp3146 (Concat __tmp3131 __tmp3145)) + (let __tmp3147 (DoWhile __tmp3016 __tmp3146)) + (let __tmp3148 (Get __tmp3147 1)) + (let __tmp3149 (Single __tmp3148)) + (let __tmp3150 (Get __tmp3147 0)) + (let __tmp3151 (Single __tmp3150)) + (let __tmp3152 (Concat __tmp3149 __tmp3151)) + (let __tmp3153 (Function 'fmod' __tmp3001 __tmp2847 __tmp3152)) + (FunctionHasType 'main' (TupleT (TCons (StateT) (TNil))) (TupleT (TCons (StateT) (TNil)))) + (FunctionHasType 'init' (TupleT (TCons (PointerT (FloatT)) (TCons (PointerT (FloatT)) (TCons (PointerT (FloatT)) (TCons (PointerT (FloatT)) (TCons (IntT) (TCons (FloatT) (TCons (IntT) (TCons (FloatT) (TCons (IntT) (TCons (FloatT) (TCons (IntT) (TCons (FloatT) (TCons (StateT) (TNil))))))))))))))) (TupleT (TCons (StateT) (TNil)))) + (FunctionHasType 'matrix_new' (TupleT (TCons (IntT) (TCons (IntT) (TCons (StateT) (TNil))))) (TupleT (TCons (PointerT (FloatT)) (TCons (StateT) (TNil))))) + (FunctionHasType 'matrix_loc' (TupleT (TCons (PointerT (FloatT)) (TCons (IntT) (TCons (IntT) (TCons (IntT) (TCons (StateT) (TNil))))))) (TupleT (TCons (PointerT (FloatT)) (TCons (StateT) (TNil))))) + (FunctionHasType 'matrix_get' (TupleT (TCons (PointerT (FloatT)) (TCons (IntT) (TCons (IntT) (TCons (IntT) (TCons (StateT) (TNil))))))) (TupleT (TCons (FloatT) (TCons (StateT) (TNil))))) + (FunctionHasType 'matrix_set' (TupleT (TCons (PointerT (FloatT)) (TCons (IntT) (TCons (IntT) (TCons (IntT) (TCons (FloatT) (TCons (StateT) (TNil)))))))) (TupleT (TCons (StateT) (TNil)))) + (FunctionHasType 'matrix_incr' (TupleT (TCons (PointerT (FloatT)) (TCons (IntT) (TCons (IntT) (TCons (IntT) (TCons (FloatT) (TCons (StateT) (TNil)))))))) (TupleT (TCons (StateT) (TNil)))) + (FunctionHasType 'matrix_scale' (TupleT (TCons (PointerT (FloatT)) (TCons (IntT) (TCons (IntT) (TCons (IntT) (TCons (FloatT) (TCons (StateT) (TNil)))))))) (TupleT (TCons (StateT) (TNil)))) + (FunctionHasType 'matrix_sum' (TupleT (TCons (PointerT (FloatT)) (TCons (IntT) (TCons (IntT) (TCons (StateT) (TNil)))))) (TupleT (TCons (FloatT) (TCons (StateT) (TNil))))) + (FunctionHasType 'fmod' (TupleT (TCons (FloatT) (TCons (FloatT) (TCons (StateT) (TNil))))) (TupleT (TCons (FloatT) (TCons (StateT) (TNil)))))) + :ruleset initialization )") + (premises) + (substitution)) diff --git a/egglog-experimental/tests/snapshots/files__proof_unit_unstable_fresh_proof.snap b/egglog-experimental/tests/snapshots/files__proof_unit_unstable_fresh_proof.snap new file mode 100644 index 0000000..1c3542c --- /dev/null +++ b/egglog-experimental/tests/snapshots/files__proof_unit_unstable_fresh_proof.snap @@ -0,0 +1,6 @@ +--- +source: egglog-experimental/tests/files.rs +expression: snapshot +--- +(let t0 (Let (Var "x") (Var "y"))) +(Fiat (= t0 t0)) diff --git a/egglog/.gitignore b/egglog/.gitignore index 0cd4ed6..c380f4a 100644 --- a/egglog/.gitignore +++ b/egglog/.gitignore @@ -9,6 +9,8 @@ pkg/ flamegraph.svg perf.data* profile.json +nightly/output/ +nightly/.venv/ /*.json /*.txt @@ -24,3 +26,5 @@ scripts/compiled tests/*.json lcov.info + +__pycache__/ diff --git a/egglog/CHANGELOG.md b/egglog/CHANGELOG.md index 5bf6fe5..dff0897 100644 --- a/egglog/CHANGELOG.md +++ b/egglog/CHANGELOG.md @@ -2,7 +2,9 @@ ## [Unreleased] - ReleaseDate +- Add `make nightly` and `scripts/nightly_bench.py`, a hyperfine-based benchmark harness that measures every `tests/**/*.egg` program at 1/2/4/8 threads and (where supported) in proof-testing mode, caps each run at a 2-minute timeout, skips sub-50ms programs, and emits an HTML dashboard (one row per benchmark, one column per configuration) for nightly.cs.washington.edu. The dashboard uses [eval-live](https://github.com/oflatt/eval-live) for interactive filtering and sorting. - Add typed `EGraph` extension state that clones with `EGraph` and is restored by `push`/`pop`. +- Fix custom scheduler queries so subsumed rows are not offered as fresh matches. - Report full source file paths in egglog span and error messages. - Fix seminaive matching after nested containers rebuild in place by propagating dirty container ids through parent containers. - Render nullary AST calls without a trailing space, e.g. (foo) instead of (foo ). @@ -17,6 +19,7 @@ - Expose `Read::table_size(name)` and `Read::table_sizes()` so read-capable primitives can inspect row counts without raw execution-state access, while avoiding an all-table scan when only one table is needed. - **`:naive` and `:unsafe-seminaive` rule options** (mutually exclusive). Both compile a rule under the permissive `Read`/`Full` contexts so its RHS can read the database (read-primitives and function-table lookups). `:naive` matches the whole database every iteration; `:unsafe-seminaive` keeps seminaive (delta) matching, which is faster but **unsafe** — an RHS read observes the database mid-iteration, so results can depend on evaluation order. `:unsafe-seminaive` is rejected by the term/proof encoding. - **Name-indexed e-graph access from primitives and `rust_rule` callbacks (#745, #751).** New `Read` / `Write` capability traits on the state wrappers let primitive bodies and rule callbacks read/write tables by name (`fs.lookup`, `fs.set`, `fs.add`, `fs.union`, `fs.function_entries`, `fs.constructor_enodes`, etc.) instead of through raw `FunctionId` + `&[Value]`; `EGraph::update(|fs| ...)` gives the same surface outside a rule, and `EGraph::function_entries` / `EGraph::constructor_enodes` expose the table scans directly at the top level. Misuse (wrong subtype, wrong arity, unknown table) surfaces as `Error::ApiError`. +- **Container support in the term/proof encoding.** Programs using container sorts (`Vec`, `Set`, `Map`, `MultiSet`, `Pair`) now work under the term/proof encoding (previously rejected), including containers read (`vec-get`, `map-get`, …) or constructed (`vec-of`, `set-of`, …) in a rule body (`set-get` excepted: it indexes an internal runtime order that proofs cannot reproduce). A container built in the body is a *side condition* with no carryable proof: it is marked with an `Eval` proof step and re-evaluated against the typed rule when checked, so it can be read or matched in the query but not carried into an action (that is rejected). Two user-visible extraction changes: container terms extract in a deterministic, reproducible order rather than value-id order, and maps extract in a flat `(map-of k0 v0 …)` form (new `map-of` constructor) instead of nested `map-insert`s. ## [2.0.0] - 2026-02-11 diff --git a/egglog/Makefile b/egglog/Makefile index 8108fa7..9a26a50 100644 --- a/egglog/Makefile +++ b/egglog/Makefile @@ -1,4 +1,4 @@ -.PHONY: all test nits docs graphs rm-graphs doctest coverage insta-test fixnits +.PHONY: all test nits docs graphs rm-graphs doctest coverage insta-test fixnits nightly RUST_SRC=$(shell find . -type f -wholename '*/src/*.rs' -or -name 'Cargo.toml') TESTS=$(shell find tests/ -type f -name '*.egg' -not -name '*repro-*') @@ -7,6 +7,16 @@ WWW=${PWD}/target/www all: test nits docs +# Build egglog and benchmark every tests/*.egg file with hyperfine, writing an +# HTML dashboard to nightly/output/ (matching `report=` in nightly-conf). +# Run nightly on nightly.cs.washington.edu. Dependencies install into a venv so +# this works on PEP 668 externally-managed systems; eval_live must be importable +# by the script's interpreter, so run it with the venv's python. +nightly: + python3 -m venv nightly/.venv + nightly/.venv/bin/pip install -q -r scripts/requirements.txt + nightly/.venv/bin/python scripts/nightly_bench.py + test: doctest cargo insta test --test-runner nextest --release --workspace --unreferenced reject diff --git a/egglog/core-relations/src/containers/mod.rs b/egglog/core-relations/src/containers/mod.rs index 64a78d2..39c7e5f 100644 --- a/egglog/core-relations/src/containers/mod.rs +++ b/egglog/core-relations/src/containers/mod.rs @@ -28,7 +28,7 @@ use crate::{ WrappedTable, common::{DashMap, IndexSet, SubsetTracker}, parallel_heuristics::{parallelize_inter_container_op, parallelize_intra_container_op}, - table_spec::Rebuilder, + table_spec::{Rebuilder, ValueRebuilder}, }; #[cfg(test)] @@ -162,6 +162,31 @@ impl ContainerValues { env.get_or_insert(&container, exec_state) } + /// Rebuild a single container value by remapping each contained value + /// through `remap`, returning the (possibly new) interned value, or `value` + /// unchanged if it is not a registered container of the type behind + /// `type_id`. + /// + /// Unlike [`ContainerValues::rebuild_all`], which drives rebuilds off the + /// backend union-find, the caller supplies the remapping explicitly and + /// identifies the container type dynamically by its [`TypeId`]. + pub fn rebuild_val_with( + &self, + type_id: TypeId, + value: Value, + exec_state: &mut ExecutionState, + remap: &(dyn Fn(Value) -> Value + Send + Sync), + ) -> Value { + let Some(id) = self.container_ids.get(&type_id) else { + return value; + }; + let Some(env) = self.data.get(id) else { + return value; + }; + env.rebuild_val_with(value, exec_state, remap) + .unwrap_or(value) + } + /// Apply the given rebuild to the contents of each container. pub fn rebuild_all( &mut self, @@ -262,11 +287,11 @@ impl ContainerValues { /// rebuilding of container contents and merging containers that become equal after a rebuild pass /// has taken place. pub trait ContainerValue: Hash + Eq + Clone + Send + Sync + 'static { - /// Rebuild an additional container in place according the the given [`Rebuilder`]. + /// Rebuild an additional container in place according the the given [`ValueRebuilder`]. /// /// If this method returns `false` then the container must not have been modified (i.e. it must /// hash to the same value, and compare equal to a copy of itself before the call). - fn rebuild_contents(&mut self, rebuilder: &dyn Rebuilder) -> bool; + fn rebuild_contents(&mut self, rebuilder: &dyn ValueRebuilder) -> bool; /// Iterate over the contents of the container. /// @@ -292,6 +317,15 @@ pub trait DynamicContainerEnv: Any + dyn_clone::DynClone + Send + Sync { /// [`ContainerValue::iter`] and lets callers climb from dirty child ids to /// all directly containing parent container ids. fn extend_containers_containing(&self, values: &IndexSet, out: &mut IndexSet); + /// Rebuild the single container `value` by remapping each contained value + /// through `remap`, returning the (possibly new) interned value, or `None` + /// if `value` is not registered in this environment. + fn rebuild_val_with( + &self, + value: Value, + exec_state: &mut ExecutionState, + remap: &(dyn Fn(Value) -> Value + Send + Sync), + ) -> Option; } // Implements `Clone` for `Box`. @@ -350,6 +384,19 @@ impl DynamicContainerEnv for ContainerEnv { } } } + + fn rebuild_val_with( + &self, + value: Value, + exec_state: &mut ExecutionState, + remap: &(dyn Fn(Value) -> Value + Send + Sync), + ) -> Option { + // Clone out of the guard before re-interning to avoid deadlocking on + // the underlying map. + let mut container = self.get_container(value)?.clone(); + container.rebuild_contents(&ClosureRebuilder { remap }); + Some(self.get_or_insert(&container, exec_state)) + } } impl ContainerEnv { @@ -737,3 +784,16 @@ fn incremental_rebuild(uf_size: usize, table_size: usize, parallel: bool) -> boo table_size > 1000 && uf_size * 8 <= table_size } } + +/// A [`ValueRebuilder`] that remaps individual values through a caller-supplied +/// closure. Used by [`ContainerValues::rebuild_val_with`] to rebuild a single +/// container against an explicit value mapping rather than a backend union-find. +struct ClosureRebuilder<'a> { + remap: &'a (dyn Fn(Value) -> Value + Send + Sync), +} + +impl ValueRebuilder for ClosureRebuilder<'_> { + fn rebuild_val(&self, val: Value) -> Value { + (self.remap)(val) + } +} diff --git a/egglog/core-relations/src/containers/tests.rs b/egglog/core-relations/src/containers/tests.rs index 74206cb..54a2f95 100644 --- a/egglog/core-relations/src/containers/tests.rs +++ b/egglog/core-relations/src/containers/tests.rs @@ -9,8 +9,8 @@ use crate::numeric_id::NumericId; use egglog_concurrency::Notification; use crate::{ - ColumnId, Database, ExecutionState, Rebuilder, RowId, Value, row_buffer::RowBuffer, - table_spec::WrappedTableRef, + ColumnId, Database, ExecutionState, Rebuilder, RowId, Value, ValueRebuilder, + row_buffer::RowBuffer, table_spec::WrappedTableRef, }; use super::{ContainerEnv, ContainerRebuildSummary, ContainerValue, hash_container}; @@ -23,7 +23,7 @@ fn cont(values: [usize; N]) -> VecContainer { } impl ContainerValue for VecContainer { - fn rebuild_contents(&mut self, rebuilder: &dyn Rebuilder) -> bool { + fn rebuild_contents(&mut self, rebuilder: &dyn ValueRebuilder) -> bool { rebuilder.rebuild_slice(&mut self.0) } @@ -41,11 +41,7 @@ struct FakeRebuilder { new_inner_val: Option, } -impl Rebuilder for FakeRebuilder { - fn hint_col(&self) -> Option { - None - } - +impl ValueRebuilder for FakeRebuilder { fn rebuild_val(&self, val: Value) -> Value { match (self.old_outer_id, self.new_outer_id) { (Some(old), Some(new)) if val == old => new, @@ -53,6 +49,27 @@ impl Rebuilder for FakeRebuilder { } } + fn rebuild_slice(&self, vals: &mut [Value]) -> bool { + let mut changed = false; + for val in vals { + if let (Some(old), Some(new)) = (self.old_inner_val, self.new_inner_val) + && *val == old + { + *val = new; + changed = true; + } + } + changed + } +} + +// Also exercised via the table-level rebuild path, so it implements the full +// `Rebuilder`; that path only calls the value-level methods for containers. +impl Rebuilder for FakeRebuilder { + fn hint_col(&self) -> Option { + None + } + fn rebuild_buf( &self, _buf: &RowBuffer, @@ -73,19 +90,6 @@ impl Rebuilder for FakeRebuilder { ) { unreachable!("FakeRebuilder does not support rebuild_subset") } - - fn rebuild_slice(&self, vals: &mut [Value]) -> bool { - let mut changed = false; - for val in vals { - if let (Some(old), Some(new)) = (self.old_inner_val, self.new_inner_val) - && *val == old - { - *val = new; - changed = true; - } - } - changed - } } #[test] diff --git a/egglog/core-relations/src/hash_index/mod.rs b/egglog/core-relations/src/hash_index/mod.rs index dfa7b93..788e671 100644 --- a/egglog/core-relations/src/hash_index/mod.rs +++ b/egglog/core-relations/src/hash_index/mod.rs @@ -16,6 +16,7 @@ use indexmap::map::Entry; use once_cell::sync::Lazy; use rayon::iter::ParallelIterator; use rustc_hash::FxHasher; +use smallvec::SmallVec; use crate::{ OffsetRange, Subset, @@ -335,50 +336,46 @@ impl IndexBase for ColumnIndex { /// then build each key's subset with a single pre-sized allocation. Compared to `merge_rows`, /// this eliminates the doubling memmoves from `push_vec` that occur in the row-at-a-time `add_row` path. /// - /// Supports multiple columns (e.g. rebuild_index covering all value columns): pairs from - /// all columns are merged into one sorted list, so each value maps to the union of rows - /// containing it in any of the covered columns. + /// Supports multiple columns (e.g. rebuild_index covering all value columns): each value + /// maps to the union of rows containing it in any of the covered columns. fn rebuild_full(&mut self, cols: &[ColumnId], table: WrappedTableRef, subset: SubsetRef) { - let n = table.all().size() * cols.len(); - - let mut pairs: Vec<(Value, RowId)> = Vec::with_capacity(n); + // Collect each column into its own contiguous block, still in RowId-ascending scan + // order. `bounds[b]..bounds[b + 1]` delimits column `b`'s block; the number of columns + // is tiny, so it stays inline. + let rows = subset.size(); + let mut pairs: Vec<(Value, RowId)> = Vec::with_capacity(rows * cols.len()); + let mut bounds: SmallVec<[usize; 8]> = SmallVec::new(); + bounds.push(0); for &col in cols { table.for_each_col(subset, col, &mut |row_id, val| { pairs.push((val, row_id)); }); + bounds.push(pairs.len()); } - radix_sort_pairs_by_value(&mut pairs); - if cols.len() > 1 { - // Remove duplicates (same value in multiple columns of the same row). - pairs.dedup(); + // Value-only sort each block. Since each block arrives RowId-ascending and the sort is + // stable, the block ends up ordered by (Value, RowId) without any RowId pass. + let mut scratch: Vec<(Value, RowId)> = + vec![(Value::new_const(0), RowId::new_const(0)); rows]; + for b in 0..cols.len() { + radix_sort_slice_by_value(&mut pairs[bounds[b]..bounds[b + 1]], &mut scratch); } - let mut i = 0; - while i < pairs.len() { - let key = pairs[i].0; - let start = i; - let mut first = pairs[i].1; - let mut last = pairs[i].1; - while i < pairs.len() && pairs[i].0 == key { - last = cmp::max(last, pairs[i].1); - first = cmp::min(first, pairs[i].1); - i += 1; - } - let shard = self.shard_data.get_shard_mut(key, &mut self.shards); - let count = i - start; - let buffered = if last.rep() - first.rep() == (count - 1) as u32 { - // If the row ids are contiguous, we can represent the subset as a dense range - // to avoid allocations - BufferedSubset::Dense(OffsetRange::new(first, last.inc())) - } else { - let bv = shard - .subsets - .new_vec(pairs[start..i].iter().map(|&(_, r)| r)); - BufferedSubset::Sparse(bv) - }; - shard.table.insert(key, buffered); + if cols.len() == 1 { + // A single column needs no merge: its block is already (Value, RowId)-sorted, and a + // row has one value per column so there are no duplicates. + self.build_subsets_from_sorted(&pairs); + return; } + + // Multiple columns: merge the sorted blocks with a balanced (tournament) two-way merge. + // Each merge drops duplicate (Value, RowId) pairs -- a value appearing in several of a + // row's columns -- and dedup composes through the tree, so the result is + // (Value, RowId)-sorted and unique without ever sorting by RowId. Halving the number of + // runs each round makes this O(n log k) rather than the O(n*k) of a left fold (whose + // growing accumulator is re-copied every step), which matters for wide tables. + let merged = merge_sorted_blocks_dedup(pairs, &bounds); + self.build_subsets_from_sorted(&merged); } } @@ -419,37 +416,37 @@ fn run_in_thread_pool_and_block<'a>(pool: &rayon::ThreadPool, f: impl FnMut() + n.wait() } -/// Adaptive LSB radix sort for (Value, RowId) pairs, sorting by the Value field. -/// -/// Chooses 1–4 passes of 8-bit radix sort based on the observed maximum Value, so that -/// only the actually-used bit range is processed. Within each Value group the original -/// order (scan order = RowId-ascending) is preserved by the LSB stability guarantee, -/// satisfying the add_row_sorted invariant without an explicit RowId sort. -/// -/// Falls back to `sort_unstable()` for n < 64 where radix setup overhead dominates. -fn radix_sort_pairs_by_value(pairs: &mut Vec<(Value, RowId)>) { - let n = pairs.len(); - if n < 64 { - pairs.sort_unstable(); - return; - } - - let max_val = pairs.iter().map(|&(v, _)| v.rep()).max().unwrap_or(0); - let n_passes: u32 = if max_val < 256 { +/// Number of 8-bit radix passes needed to cover values up to `max`. +fn radix_passes_for(max: u32) -> u32 { + if max < 256 { 1 - } else if max_val < 65_536 { + } else if max < 65_536 { 2 - } else if max_val < (1 << 24) { + } else if max < (1 << 24) { 3 } else { 4 - }; + } +} - let null_pair = (Value::new_const(0), RowId::new_const(0)); - let mut buf: Vec<(Value, RowId)> = vec![null_pair; n]; +/// Adaptive value-only LSB radix sort of a single (Value, RowId) block, in place. +/// +/// `scratch` must be at least `data.len()` long; it is used as ping-pong space. Because the +/// sort is stable and `data` arrives in RowId-ascending order, the result is ordered by +/// (Value, RowId). The multi-column rebuild path sorts each column's block this way before +/// merging, so no explicit RowId sort is ever needed. +fn radix_sort_slice_by_value(data: &mut [(Value, RowId)], scratch: &mut [(Value, RowId)]) { + let n = data.len(); + if n < 64 { + data.sort_unstable(); + return; + } + + let max_val = data.iter().map(|&(v, _)| v.rep()).max().unwrap_or(0); + let n_passes = radix_passes_for(max_val); - let mut src: &mut Vec<(Value, RowId)> = pairs; - let mut dst: &mut Vec<(Value, RowId)> = &mut buf; + let mut src: &mut [(Value, RowId)] = data; + let mut dst: &mut [(Value, RowId)] = &mut scratch[..n]; for pass in 0..n_passes { let shift = pass * 8; @@ -479,14 +476,98 @@ fn radix_sort_pairs_by_value(pairs: &mut Vec<(Value, RowId)>) { core::mem::swap(&mut src, &mut dst); } - // After `n_passes` swaps, `src` points to the sorted data. - // Odd passes: src == buf.as_mut_ptr(); copy back to pairs. - // Even passes: src == pairs.as_mut_ptr(); already in place. + // After `n_passes` swaps, `src` points to the sorted data. If odd, that is `scratch`; + // copy it back into `data` (which is now `dst`). if n_passes % 2 == 1 { dst.copy_from_slice(src); } } +/// Merge two (Value, RowId)-sorted slices, *appending* the result to `out` and dropping pairs +/// equal to the previous one emitted *by this call*. +/// +/// Inputs `a` and `b` must each be sorted by (Value, RowId). Duplicates arise when one value +/// appears in several of a row's columns; the dedup check is scoped to this call's output (via +/// `start`) so back-to-back runs packed into the same buffer are not merged into each other. +fn merge2_into(a: &[(Value, RowId)], b: &[(Value, RowId)], out: &mut Vec<(Value, RowId)>) { + let start = out.len(); + let push = |out: &mut Vec<(Value, RowId)>, next: (Value, RowId)| { + if out.len() == start || *out.last().unwrap() != next { + out.push(next); + } + }; + let (mut i, mut j) = (0, 0); + while i < a.len() && j < b.len() { + if a[i] <= b[j] { + push(out, a[i]); + i += 1; + } else { + push(out, b[j]); + j += 1; + } + } + for &next in &a[i..] { + push(out, next); + } + for &next in &b[j..] { + push(out, next); + } +} + +/// Merge the `(Value, RowId)`-sorted column blocks of `src` (block `b` is +/// `src[bounds[b]..bounds[b + 1]]`) into one sorted, de-duplicated vector. +/// +/// Uses a balanced (tournament) two-way merge: adjacent runs are merged pairwise, then the +/// results are merged pairwise, halving the run count each round. This is O(n log k) in the +/// number of blocks `k`, versus the O(n*k) of merging a single growing accumulator against +/// each block in turn -- the difference matters when a table has many covered columns. +/// +/// Each round packs its merged runs contiguously into a second buffer of the same size and the +/// two buffers ping-pong, so the whole tournament uses just one extra allocation (`src` is +/// reused as the other buffer) rather than a fresh `Vec` per merge. Because merging two +/// de-duplicated sorted runs leaves any shared pair adjacent, dedup composes across rounds. +fn merge_sorted_blocks_dedup( + mut src: Vec<(Value, RowId)>, + bounds: &[usize], +) -> Vec<(Value, RowId)> { + let n = src.len(); + debug_assert!(bounds.len() >= 2); + + // `src` holds the current rounds's runs, delimited by `cur`; `dst` receives the merged runs. + let mut dst: Vec<(Value, RowId)> = Vec::with_capacity(n); + let mut cur: SmallVec<[usize; 8]> = bounds.iter().copied().collect(); + + // Each round more than halves the run count (`cur.len() - 1`); stop at a single run. + while cur.len() > 2 { + dst.clear(); + let mut next: SmallVec<[usize; 8]> = SmallVec::new(); + next.push(0); + let runs = cur.len() - 1; + let mut r = 0; + while r < runs { + if r + 1 < runs { + merge2_into( + &src[cur[r]..cur[r + 1]], + &src[cur[r + 1]..cur[r + 2]], + &mut dst, + ); + r += 2; + } else { + // Odd trailing run: already sorted and de-duplicated, so copy it forward. + dst.extend_from_slice(&src[cur[r]..cur[r + 1]]); + r += 1; + } + next.push(dst.len()); + } + mem::swap(&mut src, &mut dst); + cur = next; + } + + // One run remains, packed at the front of `src`. + src.truncate(cur[1]); + src +} + impl ColumnIndex { pub(crate) fn new() -> ColumnIndex { with_pool_set(|ps| { @@ -500,6 +581,37 @@ impl ColumnIndex { }) } + /// Build each key's subset from `pairs`, which must be sorted by (Value, RowId) and + /// free of duplicate (Value, RowId) entries. Each contiguous run of equal values + /// becomes one subset, pre-sized from the run length. + fn build_subsets_from_sorted(&mut self, pairs: &[(Value, RowId)]) { + let mut i = 0; + while i < pairs.len() { + let key = pairs[i].0; + let start = i; + let mut first = pairs[i].1; + let mut last = pairs[i].1; + while i < pairs.len() && pairs[i].0 == key { + last = cmp::max(last, pairs[i].1); + first = cmp::min(first, pairs[i].1); + i += 1; + } + let shard = self.shard_data.get_shard_mut(key, &mut self.shards); + let count = i - start; + let buffered = if last.rep() - first.rep() == (count - 1) as u32 { + // If the row ids are contiguous, we can represent the subset as a dense range + // to avoid allocations + BufferedSubset::Dense(OffsetRange::new(first, last.inc())) + } else { + let bv = shard + .subsets + .new_vec(pairs[start..i].iter().map(|&(_, r)| r)); + BufferedSubset::Sparse(bv) + }; + shard.table.insert(key, buffered); + } + } + /// Pre-reserve capacity in each shard's HashMap for `n` rows total. /// Eliminates hashbrown rehashing during add_row for the small-subset path. pub(crate) fn reserve_for_n_rows(&mut self, n: usize) { diff --git a/egglog/core-relations/src/hash_index/tests.rs b/egglog/core-relations/src/hash_index/tests.rs index 91cbfb8..07006c7 100644 --- a/egglog/core-relations/src/hash_index/tests.rs +++ b/egglog/core-relations/src/hash_index/tests.rs @@ -1,7 +1,8 @@ -use crate::numeric_id::NumericId; +use crate::{numeric_id::NumericId, offsets::Offsets}; use crate::{ TupleIndex, + hash_index::ColumnIndex, table_shortcuts::{fill_table, v}, table_spec::{ColumnId, WrappedTable}, }; @@ -89,3 +90,44 @@ fn basic_updates() { } } } + +#[test] +fn multi_column_column_index_rebuild_orders_each_value_by_row() { + let rows = (0..128).map(|i| { + let left = if i >= 96 { v(7) } else { v(1_000 + i) }; + let right = if i < 32 { v(7) } else { v(2_000 + i) }; + vec![v(i), left, right] + }); + let mut table = WrappedTable::new(fill_table(rows, 1, None, |old, new| { + assert_eq!(old, new, "no conflicts in this test"); + None + })); + let mut index = Index::new(vec![ColumnId::new(1), ColumnId::new(2)], ColumnIndex::new()); + index.refresh(table.as_ref()); + + empty_execution_state!(es); + let start_version = table.version().major; + while table.version().major == start_version { + table.new_buffer().stage_remove(&[v(0)]); + table.merge(&mut es); + table.new_buffer().stage_insert(&[v(0), v(1000), v(7)]); + table.merge(&mut es); + } + + index.refresh(table.as_ref()); + let key = v(7); + let subset = index.get_subset(&key).unwrap(); + let mut row_ids = Vec::new(); + subset.offsets(|row_id| row_ids.push(row_id.index())); + + let mut expected = Vec::new(); + table + .scan(table.all().as_ref()) + .iter() + .for_each(|(row_id, row)| { + if row[1] == key || row[2] == key { + expected.push(row_id.index()); + } + }); + assert_eq!(row_ids, expected); +} diff --git a/egglog/core-relations/src/lib.rs b/egglog/core-relations/src/lib.rs index 20642b5..6ad455d 100644 --- a/egglog/core-relations/src/lib.rs +++ b/egglog/core-relations/src/lib.rs @@ -40,7 +40,7 @@ pub use row_buffer::TaggedRowBuffer; pub use table::{MergeFn, SortedWritesTable}; pub use table_spec::{ ColumnId, Constraint, MutationBuffer, Offset, Rebuilder, Row, Table, TableChange, TableSpec, - TableVersion, WrappedTable, + TableVersion, ValueRebuilder, WrappedTable, }; pub use uf::DisplacedTable; diff --git a/egglog/core-relations/src/table_spec.rs b/egglog/core-relations/src/table_spec.rs index 9aec479..a4117b5 100644 --- a/egglog/core-relations/src/table_spec.rs +++ b/egglog/core-relations/src/table_spec.rs @@ -100,19 +100,43 @@ pub enum Constraint { GeConst { col: ColumnId, val: Value }, } +/// Remap individual values (e.g. to their union-find leaders) — the value-level +/// half of rebuilding, enough to rebuild a single container's contents (see +/// [`crate::ContainerValue::rebuild_contents`]). +pub trait ValueRebuilder: Send + Sync { + /// Rebuild a single value. + fn rebuild_val(&self, val: Value) -> Value; + /// Rebuild a slice of values in place, returning true if any values were changed. + /// + /// Defaults to mapping each value through [`ValueRebuilder::rebuild_val`]; + /// implementors may override for efficiency. + fn rebuild_slice(&self, vals: &mut [Value]) -> bool { + let mut changed = false; + for val in vals.iter_mut() { + let new = self.rebuild_val(*val); + if new != *val { + *val = new; + changed = true; + } + } + changed + } +} + /// Custom functions used for tables that encode a bulk value-level rebuild of other tables. /// +/// Extends [`ValueRebuilder`] with table-level (bulk) operations. +/// /// The initial use-case for this trait is to support optimized implementations of rebuilding, /// where `Rebuilder` is implemented as a Union-find. /// /// Value-level rebuilds are difficult to implement efficiently using rules as they require /// searching for changes to any column for a table: while it is possible to do, implementing this /// custom is more efficient in the case of rebuilding. -pub trait Rebuilder: Send + Sync { +pub trait Rebuilder: ValueRebuilder { /// The column that contains values that should be rebuilt. If this is set, callers can use /// this functionality to perform rebuilds incrementally. fn hint_col(&self) -> Option; - fn rebuild_val(&self, val: Value) -> Value; /// Rebuild a contiguous slice of rows in the table. fn rebuild_buf( &self, @@ -130,8 +154,6 @@ pub trait Rebuilder: Send + Sync { out: &mut TaggedRowBuffer, exec_state: &mut ExecutionState, ); - /// Rebuild a slice of values in place, returning true if any values were changed. - fn rebuild_slice(&self, vals: &mut [Value]) -> bool; } /// A row in a table. diff --git a/egglog/core-relations/src/uf/mod.rs b/egglog/core-relations/src/uf/mod.rs index 99df41c..edf1d38 100644 --- a/egglog/core-relations/src/uf/mod.rs +++ b/egglog/core-relations/src/uf/mod.rs @@ -18,7 +18,7 @@ use crate::{ row_buffer::RowBuffer, table_spec::{ ColumnId, Constraint, Generation, MutationBuffer, Offset, Rebuilder, Row, Table, TableSpec, - TableVersion, WrappedTableRef, + TableVersion, ValueRebuilder, WrappedTableRef, }, }; @@ -64,13 +64,17 @@ struct Canonicalizer<'a> { table: &'a DisplacedTable, } +impl ValueRebuilder for Canonicalizer<'_> { + fn rebuild_val(&self, val: Value) -> Value { + self.table.uf.find_naive(val) + } + // `rebuild_slice` uses the default (per-value `rebuild_val`). +} + impl Rebuilder for Canonicalizer<'_> { fn hint_col(&self) -> Option { Some(ColumnId::new(0)) } - fn rebuild_val(&self, val: Value) -> Value { - self.table.uf.find_naive(val) - } fn rebuild_buf( &self, buf: &RowBuffer, @@ -184,15 +188,6 @@ impl Rebuilder for Canonicalizer<'_> { } } } - fn rebuild_slice(&self, vals: &mut [Value]) -> bool { - let mut changed = false; - for val in vals { - let canon = self.table.uf.find_naive(*val); - changed |= canon != *val; - *val = canon; - } - changed - } } impl Default for DisplacedTable { diff --git a/egglog/egglog-bridge/src/tests.rs b/egglog/egglog-bridge/src/tests.rs index cbee0e8..54df39f 100644 --- a/egglog/egglog-bridge/src/tests.rs +++ b/egglog/egglog-bridge/src/tests.rs @@ -11,7 +11,7 @@ use std::{ use crate::core_relations; use crate::core_relations::{ - ContainerValue, ExternalFunctionId, Rebuilder, Value, make_external_func, + ContainerValue, ExternalFunctionId, Value, ValueRebuilder, make_external_func, }; use crate::numeric_id::NumericId; use log::debug; @@ -449,7 +449,7 @@ fn math_test(mut egraph: EGraph, can_subsume: bool) { #[derive(Clone, Debug, Hash, Eq, PartialEq)] struct VecContainer(Vec); impl ContainerValue for VecContainer { - fn rebuild_contents(&mut self, rebuilder: &dyn Rebuilder) -> bool { + fn rebuild_contents(&mut self, rebuilder: &dyn ValueRebuilder) -> bool { rebuilder.rebuild_slice(&mut self.0) } fn iter(&self) -> impl Iterator + '_ { diff --git a/egglog/scripts/nightly_bench.py b/egglog/scripts/nightly_bench.py new file mode 100644 index 0000000..8797edd --- /dev/null +++ b/egglog/scripts/nightly_bench.py @@ -0,0 +1,489 @@ +#!/usr/bin/env python3 +""" +nightly_bench.py — egglog nightly benchmark harness + +Builds the release `egglog` binary, runs every benchmark `.egg` file under +`tests/` through `hyperfine` in several configurations, and writes a +self-contained HTML report (plus a machine-readable `results.json`) into an +output directory. + +Each program is benchmarked in these configurations: + + * standard — `egglog -j 1 ` (single thread, the baseline) + * 2 threads — `egglog -j 2 ` + * 4 threads — `egglog -j 4 ` + * 8 threads — `egglog -j 8 ` + * proof — `egglog --proof-testing ` (single thread), for programs + that support proofs (mirrors `file_supports_proofs` minus the + known-unsupported exclusion list used by tests/files.rs) + +The report is a single table (one row per benchmark, one column per +configuration above), rendered with eval-live (https://github.com/oflatt/eval-live) +for in-browser filtering. eval-live is a Python dependency; see +`scripts/requirements.txt`. + +Gating: + * Every individual run has a 2-minute timeout. A run that exceeds it is + killed and reported as "timeout". + * A benchmark is skipped entirely if neither its standard run nor its proof + run reaches 50ms — too fast to measure reliably. Programs under + `tests/proofs/` require proofs, so only their proof run is considered. + +Usage: + nightly_bench.py [output_dir] # default output_dir: /nightly/output + +This is the entry point used by `make nightly` for the nightly dashboard at +nightly.cs.washington.edu. +""" + +import json +import os +import shlex +import shutil +import subprocess +import sys +import tempfile +import time +from datetime import UTC, datetime +from html import escape +from pathlib import Path + +SCRIPT_DIR = Path(__file__).parent.resolve() +REPO_ROOT = SCRIPT_DIR.parent +TEST_DIR = REPO_ROOT / "tests" +EGGLOG = REPO_ROOT / "target" / "release" / "egglog" + +# Benchmarks faster than this (single-run wall clock) are skipped. +MIN_BENCH_SECONDS = 0.050 + +# Every individual run is capped at two minutes. +RUN_TIMEOUT = 120 + +# Programs that are expected to fail or are reproduction snippets are not +# benchmarks; skip them entirely. +EXCLUDE_SUBSTRINGS = ("fail-typecheck", "repro-", "/repro") + +# Programs that statically support proofs but are excluded from proof-mode +# benchmarking (too slow, or known correctness bugs). Mirrors the +# `proof_unsupported_file_list` in tests/files.rs. +PROOF_UNSUPPORTED_FILES = ( + "math-microbenchmark.egg", + "rectangle.egg", + "eggcc-2mm.egg", + "subsume.egg", + "subsume-relation.egg", +) + +# Prefix used to cap each run at RUN_TIMEOUT, e.g. ["timeout", "120"]. Set by +# calibrate_timeout(): only used when the `timeout` binary's own overhead is +# small enough not to pollute measurements (GNU timeout is ~1ms; some +# reimplementations add ~100ms, which would swamp sub-100ms benchmarks). +TIMEOUT_PREFIX: list[str] = [] + +# (key, label, threads, proof) — also the report's column order. +CONFIGS = [ + ("standard", "Standard", 1, False), + ("threads2", "2 threads", 2, False), + ("threads4", "4 threads", 4, False), + ("threads8", "8 threads", 8, False), + ("proof", "Proof", 1, True), +] +THREAD_KEYS = ("standard", "threads2", "threads4", "threads8") + + +def log(msg: str = "") -> None: + print(msg, flush=True) + + +# ── git helpers ─────────────────────────────────────────────────────────────── + + +def _git(*args: str) -> str: + try: + return subprocess.check_output( + ["git", "-C", str(REPO_ROOT), *args], text=True, stderr=subprocess.DEVNULL + ).strip() + except (subprocess.CalledProcessError, FileNotFoundError): + return "" + + +def commit_info() -> dict[str, str]: + return { + "commit": _git("rev-parse", "HEAD"), + "commit_short": _git("rev-parse", "--short", "HEAD"), + "subject": _git("log", "-1", "--format=%s"), + "branch": _git("rev-parse", "--abbrev-ref", "HEAD"), + } + + +# ── benchmark discovery ───────────────────────────────────────────────────────── + + +def discover_benchmarks() -> list[Path]: + files = sorted(TEST_DIR.rglob("*.egg")) + return [ + f for f in files if not any(sub in f.as_posix() for sub in EXCLUDE_SUBSTRINGS) + ] + + +def requires_proofs(path: Path) -> bool: + """Programs under tests/proofs/ only make sense with proofs enabled.""" + return path.parent.name == "proofs" + + +def proof_excluded(path: Path) -> bool: + return path.name in PROOF_UNSUPPORTED_FILES + + +def egglog_cmd(path: Path, threads: int, proof: bool) -> list[str]: + cmd = [str(EGGLOG), "-j", str(threads)] + if proof: + cmd.append("--proof-testing") + cmd.append(str(path)) + return cmd + + +# ── probing & measuring ───────────────────────────────────────────────────────── + + +def probe(path: Path, threads: int, proof: bool) -> tuple[bool, float, bool]: + """Run a config once. Returns (ok, elapsed_seconds, timed_out). + + ok is False if egglog exited non-zero (e.g. a program that does not support + proofs in proof-testing mode) or if the run exceeded RUN_TIMEOUT. + """ + start = time.perf_counter() + try: + proc = subprocess.run( + egglog_cmd(path, threads, proof), + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + timeout=RUN_TIMEOUT, + ) + except subprocess.TimeoutExpired: + return False, time.perf_counter() - start, True + return proc.returncode == 0, time.perf_counter() - start, False + + +def runs_for(probe_seconds: float) -> tuple[int, int]: + """Pick (warmup, runs) for hyperfine: more samples for fast benchmarks, + fewer for slow ones so the whole sweep stays within a reasonable budget.""" + if probe_seconds < 0.5: + return 2, 10 + if probe_seconds < 2.0: + return 2, 7 + if probe_seconds < 5.0: + return 1, 5 + return 1, 3 + + +def calibrate_timeout() -> None: + """Decide whether wrapping runs in `timeout` is cheap enough to use. + + GNU coreutils `timeout` adds ~1ms; some reimplementations add ~100ms, which + would dominate fast benchmarks. We only use the wrapper when its overhead is + negligible; either way the per-run cap is also enforced by probe() and by a + subprocess-level backstop in hyperfine().""" + global TIMEOUT_PREFIX + if not shutil.which("timeout"): + log("Note: `timeout` not found; per-run cap enforced via probe only.") + return + best = min(_time_true() for _ in range(3)) + if best < 0.025: + TIMEOUT_PREFIX = ["timeout", str(RUN_TIMEOUT)] + else: + log(f"Note: `timeout` overhead is {best * 1000:.0f}ms; not wrapping runs " + "with it (per-run cap still enforced via probe and backstop).") + + +def _time_true() -> float: + start = time.perf_counter() + subprocess.run(["timeout", str(RUN_TIMEOUT), "true"], + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + return time.perf_counter() - start + + +def hyperfine(path: Path, threads: int, proof: bool, warmup: int, runs: int) -> dict | None: + # When available, wrap each run in `timeout` so no single execution exceeds + # RUN_TIMEOUT; hyperfine then aborts the benchmark (reported as a timeout). + shell_cmd = ( + (" ".join(TIMEOUT_PREFIX) + " " if TIMEOUT_PREFIX else "") + + shlex.join(egglog_cmd(path, threads, proof)) + + " >/dev/null 2>&1" + ) + # Aggregate backstop: even without the per-run wrapper, never let the whole + # measurement run away (e.g. a non-deterministic hang in a repeat run). + backstop = RUN_TIMEOUT * (warmup + runs) + 30 + with tempfile.NamedTemporaryFile(suffix=".json", delete=False) as tf: + tmp_json = tf.name + try: + proc = subprocess.run( + [ + "hyperfine", + "--warmup", str(warmup), + "--runs", str(runs), + "--export-json", tmp_json, + shell_cmd, + ], + capture_output=True, + text=True, + timeout=backstop, + ) + if proc.returncode != 0: + return None + with open(tmp_json) as f: + return json.load(f)["results"][0] + except subprocess.TimeoutExpired: + return None + finally: + os.unlink(tmp_json) + + +def measure_cell(path: Path, threads: int, proof: bool, + probe_result: tuple[bool, float, bool] | None = None) -> dict: + """Measure one (benchmark, configuration) cell. Returns a dict with either + a measured mean or a status: 'timeout' / 'error'.""" + ok, elapsed, timed_out = probe_result or probe(path, threads, proof) + if not ok: + return {"status": "timeout" if timed_out else "error"} + + warmup, runs = runs_for(elapsed) + hf = hyperfine(path, threads, proof, warmup, runs) + if hf is None: + # hyperfine aborts on a non-zero exit; with the timeout wrapper that + # almost always means a run was killed at RUN_TIMEOUT. + return {"status": "timeout"} + return { + "mean": hf["mean"], + "stddev": hf.get("stddev", 0.0), + "min": hf["min"], + "max": hf["max"], + "runs": len(hf.get("times", [])), + } + + +# ── main sweep ────────────────────────────────────────────────────────────────── + + +def ensure_rustup_on_path() -> None: + """Put the rustup shim dir (~/.cargo/bin) first on PATH. + + The nightly host has a system `cargo` ahead of the rustup shim; it is too + old for this crate's 2024 edition and ignores rust-toolchain.toml. The shim + reads rust-toolchain.toml and installs/uses the pinned toolchain on demand. + hyperfine and other cargo-installed tools live here too.""" + cargo_bin = str(Path.home() / ".cargo" / "bin") + parts = [p for p in os.environ.get("PATH", "").split(os.pathsep) if p != cargo_bin] + os.environ["PATH"] = os.pathsep.join([cargo_bin, *parts]) + + +def build() -> None: + log("Building egglog (release)...") + subprocess.run( + ["cargo", "build", "--release", "--bin", "egglog", + "--manifest-path", str(REPO_ROOT / "Cargo.toml")], + check=True, + ) + if not EGGLOG.exists(): + sys.exit(f"egglog binary not found at {EGGLOG}") + + +def run_sweep() -> tuple[list[dict], list[dict]]: + """Returns (rows, skipped). Each row is {name, cells: {config_key: cell}}.""" + benchmarks = discover_benchmarks() + log(f"Discovered {len(benchmarks)} candidate program(s) under {TEST_DIR}\n") + + rows: list[dict] = [] + skipped: list[dict] = [] + + headers = " ".join(f"{label:>10}" for _, label, _, _ in CONFIGS) + log(f" {'Benchmark':<40} {headers}") + log(" " + "─" * (40 + len(CONFIGS) * 12)) + + for path in benchmarks: + name = path.relative_to(TEST_DIR).as_posix() + try: + req = requires_proofs(path) + + # Qualification probes: the single-thread standard run and the proof run. + std_probe = None if req else probe(path, 1, False) + proof_probe = None if proof_excluded(path) else probe(path, 1, True) + proof_supported = proof_probe is not None and proof_probe[0] + + std_qualifies = std_probe is not None and std_probe[0] and std_probe[1] >= MIN_BENCH_SECONDS + proof_qualifies = proof_supported and proof_probe[1] >= MIN_BENCH_SECONDS + + if not (std_qualifies or proof_qualifies): + reason = "errored" if (req and not proof_supported) else "too-fast" + skipped.append({"name": name, "reason": reason}) + continue + + cells: dict[str, dict] = {} + for key, _label, threads, proof in CONFIGS: + if proof: + if not proof_supported: + cells[key] = {"status": "na"} # proofs unsupported / excluded + else: + cells[key] = measure_cell(path, threads, True, proof_probe) + else: + if req: + cells[key] = {"status": "na"} # needs proofs; no plain run + else: + pr = std_probe if threads == 1 else None + cells[key] = measure_cell(path, threads, False, pr) + + # Enforce the threshold on measured data: the cold qualification probe + # can overshoot 50ms for a program whose warmed runs are all faster. + measured = [c["mean"] for c in cells.values() if "mean" in c] + if not measured or max(measured) < MIN_BENCH_SECONDS: + skipped.append({"name": name, "reason": "too-fast"}) + continue + + rows.append({"name": name, "cells": cells}) + + formatted = [] + for key, *_ in CONFIGS: + c = cells[key] + formatted.append( + f"{c['mean']:>10.3f}" + if "mean" in c + else f"{c.get('status', '—'):>10}" + ) + log(f" {name:<40} " + " ".join(formatted)) + except Exception as err: + reason = f"error: {type(err).__name__}: {err}" + skipped.append({"name": name, "reason": reason}) + log(f" {name:<40} skipped: {reason}") + continue + + rows.sort(key=lambda r: r["cells"].get("standard", {}).get("mean", 0.0) + or r["cells"].get("proof", {}).get("mean", 0.0), reverse=True) + + n_fast = sum(s["reason"] == "too-fast" for s in skipped) + log(f"\n Benchmarked {len(rows)}; skipped {n_fast} under " + f"{int(MIN_BENCH_SECONDS * 1000)}ms, " + f"{len(skipped) - n_fast} errored/proof-only-unsupported.") + return rows, skipped + + +# ── report rendering ────────────────────────────────────────────────────────── + + +def render_html(rows: list[dict], skipped: list[dict], meta: dict) -> str: + import eval_live + + # Flatten the nested cells structure into eval-live row objects: one row per + # benchmark, one column per configuration. A measured cell becomes its mean + # (a number, so eval-live's column filter offers a numeric dropdown); an + # "na" cell becomes "—" (not applicable, e.g. a non-proof run of a + # proofs-only program); "timeout"/"error" cells keep their status string. + bench_rows = [] + for r in rows: + cells = r["cells"] + entry: dict = {"name": r["name"]} + for key, label, _, _ in CONFIGS: + cell = cells.get(key, {"status": "na"}) + if "mean" in cell: + entry[label] = round(cell["mean"], 4) + elif cell.get("status") == "na": + entry[label] = "—" + else: + entry[label] = cell.get("status", "error") + bench_rows.append(entry) + + data: dict = {"Benchmarks": bench_rows} + if skipped: + data["Skipped"] = [{"name": s["name"], "reason": s["reason"]} for s in skipped] + + css = eval_live.css() + js = eval_live.js() + # Embedded inside a " breakout. + # ("<\/" is just "' + f'{escape(commit)}' + if commit_full else escape(commit) + ) + generated = datetime.now(UTC).strftime("%Y-%m-%d %H:%M UTC") + + return f""" + + + + + egglog nightly benchmarks + + + +

egglog nightly benchmarks

+

+ Commit {commit_link} · + branch {escape(meta.get('branch', '?'))} · + {escape(meta.get('subject', ''))} · + Generated {generated} +

+

+ All times in seconds (mean). Each run is capped at a {RUN_TIMEOUT // 60}-minute timeout. + Programs whose standard and proof runs are both under + {int(MIN_BENCH_SECONDS * 1000)}ms are omitted. + Raw data: results.json. +

+
+ + +""" + + +def main() -> int: + ensure_rustup_on_path() + if not shutil.which("hyperfine"): + sys.exit("hyperfine not found — install with: cargo install hyperfine") + # Fail fast: the report uses eval-live, but it is only needed at the very + # end, after a sweep that can take a long time. Check it up front. + try: + import eval_live # noqa: F401 + except ImportError: + sys.exit("eval-live not found — install with: " + "pip install -r scripts/requirements.txt") + + out_dir = Path(sys.argv[1]) if len(sys.argv) > 1 else REPO_ROOT / "nightly" / "output" + out_dir.mkdir(parents=True, exist_ok=True) + + calibrate_timeout() + build() + meta = commit_info() + rows, skipped = run_sweep() + + payload = { + "generated_at": datetime.now(UTC).isoformat().replace("+00:00", "Z"), + **meta, + "min_bench_seconds": MIN_BENCH_SECONDS, + "run_timeout_seconds": RUN_TIMEOUT, + "configs": [ + {"key": key, "label": label, "threads": threads, "proof": proof} for key, label, threads, proof in CONFIGS + ], + "rows": rows, + "skipped": skipped, + } + (out_dir / "results.json").write_text(json.dumps(payload, indent=2)) + (out_dir / "index.html").write_text(render_html(rows, skipped, meta)) + log(f"\n Wrote report to {out_dir / 'index.html'}") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/egglog/scripts/requirements.txt b/egglog/scripts/requirements.txt new file mode 100644 index 0000000..139035c --- /dev/null +++ b/egglog/scripts/requirements.txt @@ -0,0 +1 @@ +eval-live @ git+https://github.com/oflatt/eval-live.git@5a1caae821c7c0a4080f0984bfc9e4c2cb482c05 diff --git a/egglog/src/ast/desugar.rs b/egglog/src/ast/desugar.rs index 11614aa..428f22b 100644 --- a/egglog/src/ast/desugar.rs +++ b/egglog/src/ast/desugar.rs @@ -71,6 +71,8 @@ pub(crate) fn desugar_command( presort_and_args: None, uf: None, proof_func: None, + container_rebuild: None, + proof_constructors: None, unionable: true, }); } @@ -91,6 +93,8 @@ pub(crate) fn desugar_command( presort_and_args: Some((sort, args)), uf: None, proof_func: None, + container_rebuild: None, + proof_constructors: None, unionable: true, }); } @@ -144,6 +148,8 @@ pub(crate) fn desugar_command( presort_and_args, uf, proof_func, + container_rebuild, + proof_constructors, unionable, } => vec![NCommand::Sort { span, @@ -151,6 +157,8 @@ pub(crate) fn desugar_command( presort_and_args, uf, proof_func, + container_rebuild, + proof_constructors, unionable, }], Command::AddRuleset(span, name) => vec![NCommand::AddRuleset(span, name)], @@ -234,6 +242,8 @@ fn desugar_prove(parser: &mut Parser, span: Span, query: Vec) -> Vec) -> Vec, +} + +impl Display for ContainerRebuildSpec { + fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { + write!(f, "(container-rebuild-spec {}", self.internal_rebuild_prim)?; + if let Some(proof_prim) = &self.internal_rebuild_proof_prim { + write!(f, " {proof_prim}")?; + } + write!(f, ")") + } +} + +/// The program-global proof constructor names, recorded on the `Proof` sort as +/// the `:internal-proof-names` annotation (the `Proof` datatype name is the +/// sort's own name). +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct ProofConstructorNames { + pub congr: String, + pub trans: String, + pub sym: String, + pub normalize: String, +} + #[derive(Clone, Debug)] /// The egglog internal representation of already compiled rules pub(crate) enum Ruleset { @@ -56,12 +88,20 @@ where span: Span, name: String, presort_and_args: Option<(String, Vec>)>, - /// The name of the union-find function for this sort. - /// Used in term encoding to canonicalize values during extraction. - uf: Option, + /// The union-find `(constructor, optional function-index)` table names + /// for this sort: `UF_` (scanned by extraction's `find_canonical`) + /// and the optional `UF_f` index (single-key leader lookup). + uf: Option<(String, Option)>, /// The name of the proof function for this sort. /// Set by proof desugaring to record where proofs are stored for this sort. proof_func: Option, + /// For container sorts under the term/proof encoding: the spec for the + /// container's rebuild primitives (see [`ContainerRebuildSpec`]), carried + /// as the `:internal-container-rebuild` annotation. + container_rebuild: Option, + /// The global proof constructor names (see [`ProofConstructorNames`]), + /// recorded once on the `Proof` sort as `:internal-proof-names`. + proof_constructors: Option, /// Whether values of this sort can be unioned. /// Defaults to true for user-defined sorts. /// Set to false for relations and term tables that should not allow union. @@ -116,6 +156,8 @@ where presort_and_args, uf, proof_func, + container_rebuild, + proof_constructors, unionable, } => GenericCommand::Sort { span: span.clone(), @@ -123,6 +165,8 @@ where presort_and_args: presort_and_args.clone(), uf: uf.clone(), proof_func: proof_func.clone(), + container_rebuild: container_rebuild.clone(), + proof_constructors: proof_constructors.clone(), unionable: *unionable, }, GenericNCommand::Function(f) => match f.subtype { @@ -242,6 +286,8 @@ where presort_and_args, uf, proof_func, + container_rebuild, + proof_constructors, unionable, } => GenericNCommand::Sort { span, @@ -249,6 +295,8 @@ where presort_and_args, uf, proof_func, + container_rebuild, + proof_constructors, unionable, }, GenericNCommand::Function(func) => GenericNCommand::Function(func.visit_exprs(f)), @@ -552,12 +600,19 @@ where span: Span, name: String, presort_and_args: Option<(String, Vec)>, - /// The name of the union-find function for this sort. - /// Used in term encoding to canonicalize values during extraction. - uf: Option, + /// The union-find `(constructor, optional function-index)` table names + /// for this sort (see [`GenericNCommand::Sort`]). + uf: Option<(String, Option)>, /// The name of the proof function for this sort. /// Set by proof desugaring to record where proofs are stored for this sort. proof_func: Option, + /// For container sorts under the term/proof encoding: the spec for the + /// container's rebuild primitives (see [`ContainerRebuildSpec`]), carried + /// as the `:internal-container-rebuild` annotation. + container_rebuild: Option, + /// The global proof constructor names (see [`ProofConstructorNames`]), + /// recorded once on the `Proof` sort as `:internal-proof-names`. + proof_constructors: Option, /// Whether values of this sort can be unioned. /// Defaults to true for user-defined sorts. /// Set to false for relations and term tables that should not allow union. @@ -956,23 +1011,43 @@ where presort_and_args: None, uf, proof_func, + proof_constructors, .. } => { write!(f, "(sort {name}")?; - if let Some(uf) = uf { - write!(f, " :internal-uf {uf}")?; + if let Some((uf_ctor, uf_index)) = uf { + write!(f, " :internal-uf {uf_ctor}")?; + if let Some(uf_index) = uf_index { + write!(f, " {uf_index}")?; + } } if let Some(pf) = proof_func { write!(f, " :internal-proof-func {pf}")?; } + if let Some(pc) = proof_constructors { + write!( + f, + " :internal-proof-names {} {} {} {}", + pc.congr, pc.trans, pc.sym, pc.normalize + )?; + } write!(f, ")") } GenericCommand::Sort { name, presort_and_args: Some((name2, args)), + proof_func, + container_rebuild, .. } => { - write!(f, "(sort {name} ({name2} {}))", ListDisplay(args, " ")) + write!(f, "(sort {name} ({name2} {})", ListDisplay(args, " "))?; + if let Some(pf) = proof_func { + write!(f, " :internal-proof-func {pf}")?; + } + if let Some(spec) = container_rebuild { + write!(f, " :internal-container-rebuild {spec}")?; + } + write!(f, ")") } GenericCommand::Function { span: _, @@ -1600,13 +1675,17 @@ where presort_and_args, uf, proof_func, + container_rebuild, + proof_constructors, unionable, } => GenericCommand::Sort { span, name: fun(name), presort_and_args, - uf: uf.map(&mut *fun), + uf: uf.map(|(ctor, index)| (fun(ctor), index.map(&mut *fun))), proof_func: proof_func.map(&mut *fun), + container_rebuild, + proof_constructors, unionable, }, GenericCommand::Datatype { @@ -1877,6 +1956,8 @@ where presort_and_args, uf, proof_func, + container_rebuild, + proof_constructors, unionable, } => GenericCommand::Sort { span, @@ -1884,6 +1965,8 @@ where presort_and_args, uf, proof_func, + container_rebuild, + proof_constructors, unionable, }, GenericCommand::Datatype { diff --git a/egglog/src/ast/parse.rs b/egglog/src/ast/parse.rs index 4d0aebb..e73a807 100644 --- a/egglog/src/ast/parse.rs +++ b/egglog/src/ast/parse.rs @@ -111,6 +111,32 @@ fn map_fallible( .collect::>() } +/// Parse the `:internal-container-rebuild` annotation value (see +/// [`ContainerRebuildSpec`]). The dual of its `Display`. +fn parse_container_rebuild_spec(sexp: &Sexp) -> Result { + let (head, items, span) = sexp.expect_call("container-rebuild spec")?; + if head != "container-rebuild-spec" { + return error!(span, "expected (container-rebuild-spec ...)"); + } + let (prim, proof_prim) = match items { + [prim] => (prim, None), + [prim, proof_prim] => ( + prim, + Some(proof_prim.expect_atom("container rebuild proof primitive name")?), + ), + _ => { + return error!( + span, + "container-rebuild-spec needs a primitive name and an optional proof primitive name" + ); + } + }; + Ok(ContainerRebuildSpec { + internal_rebuild_prim: prim.expect_atom("container rebuild primitive name")?, + internal_rebuild_proof_prim: proof_prim, + }) +} + pub trait Macro: Send + Sync { fn name(&self) -> &str; fn parse(&self, args: &[Sexp], span: Span, parser: &mut Parser) -> Result; @@ -267,10 +293,34 @@ impl Parser { presort_and_args: None, uf: None, proof_func: None, + container_rebuild: None, + proof_constructors: None, unionable: true, }], - [name, call @ Sexp::List(..)] => { + [name, call @ Sexp::List(..), rest @ ..] => { let (func, args, _) = call.expect_call("container sort declaration")?; + // Container sorts may carry :internal-proof-func (their + // `Proof` table) and an :internal-container-rebuild + // spec (both emitted by the term/proof encoder). + let mut proof_func = None; + let mut container_rebuild = None; + for (key, val) in self.parse_options(rest)? { + match (key, val) { + (":internal-proof-func", [pf]) => { + proof_func = + Some(pf.expect_atom("internal-proof-func function name")?); + } + (":internal-container-rebuild", [spec]) => { + container_rebuild = Some(parse_container_rebuild_spec(spec)?); + } + _ => { + return error!( + span, + "usage:\n(sort ( *) [:internal-proof-func ] [:internal-container-rebuild ])" + ); + } + } + } vec![Command::Sort { span, name: name.expect_atom("sort name")?, @@ -279,27 +329,46 @@ impl Parser { map_fallible(args, self, Self::parse_expr)?, )), uf: None, - proof_func: None, + proof_func, + container_rebuild, + proof_constructors: None, unionable: true, }] } [name, rest @ ..] => { - // Parse :internal-uf and :internal-proof-func annotations + // Parse :internal-uf / :internal-proof-func and the + // :internal-proof-names global proof-constructor record. let mut uf = None; let mut proof_func = None; + let mut proof_constructors = None; for (key, val) in self.parse_options(rest)? { match (key, val) { - (":internal-uf", [uf_func]) => { - uf = Some(uf_func.expect_atom("uf function name")?); + (":internal-uf", [uf_ctor]) => { + uf = Some((uf_ctor.expect_atom("uf constructor name")?, None)); + } + (":internal-uf", [uf_ctor, uf_index]) => { + uf = Some(( + uf_ctor.expect_atom("uf constructor name")?, + Some(uf_index.expect_atom("uf index function name")?), + )); } (":internal-proof-func", [pf]) => { proof_func = Some(pf.expect_atom("internal-proof-func function name")?); } + (":internal-proof-names", [congr, trans, sym, normalize]) => { + proof_constructors = Some(ProofConstructorNames { + congr: congr.expect_atom("congr constructor")?, + trans: trans.expect_atom("trans constructor")?, + sym: sym.expect_atom("sym constructor")?, + normalize: normalize + .expect_atom("container-normalize constructor")?, + }); + } _ => { return error!( span, - "usages:\n(sort )\n(sort :internal-uf )\n(sort :internal-proof-func )\n(sort ( *))" + "usages:\n(sort )\n(sort :internal-uf [])\n(sort :internal-proof-func )\n(sort :internal-proof-names )\n(sort ( *))" ); } } @@ -310,6 +379,8 @@ impl Parser { presort_and_args: None, uf, proof_func, + container_rebuild: None, + proof_constructors, unionable: true, }] } diff --git a/egglog/src/lib.rs b/egglog/src/lib.rs index b9d7e20..3174206 100644 --- a/egglog/src/lib.rs +++ b/egglog/src/lib.rs @@ -70,7 +70,7 @@ use std::ops::Deref; use std::path::PathBuf; use std::str::FromStr; use std::sync::Arc; -pub use termdag::{Term, TermDag, TermId}; +pub use termdag::{OrdTerm, Term, TermDag, TermId}; use thiserror::Error; pub use typechecking::PrimitiveValidator; pub use typechecking::TypeError; @@ -166,6 +166,29 @@ impl CommandOutput { /// legitimately differ or are non-deterministic (timing, `PrintFunction` /// per #793, extraction variants) and reduces `ExtractBest` to its cost. pub fn snapshot_stable_under_proof_encoding(outputs: &[CommandOutput]) -> String { + Self::snapshot_stable(outputs, true) + } + + /// Render only proof outputs. This keeps proof snapshots focused on the + /// proof certificate and leaves ordinary outputs to the shared snapshots. + pub fn snapshot_proofs_only(outputs: &[CommandOutput]) -> String { + outputs + .iter() + .filter_map(|output| match output { + CommandOutput::ProveExists { .. } => Some(output.to_string()), + _ => None, + }) + .collect::>() + .join("") + } + + /// Render the non-proof outputs that should still match the normal-mode + /// shared snapshot when proof-testing rewrites checks into prove commands. + pub fn snapshot_non_proof_stable_under_proof_encoding(outputs: &[CommandOutput]) -> String { + Self::snapshot_stable(outputs, false) + } + + fn snapshot_stable(outputs: &[CommandOutput], include_proofs: bool) -> String { outputs .iter() .filter_map(|output| match output { @@ -175,6 +198,7 @@ impl CommandOutput { Some(format!("(extraction-costs {cost})\n")) } CommandOutput::ExtractVariants(..) => None, + CommandOutput::ProveExists { .. } if !include_proofs => None, other => Some(other.to_string()), }) .collect::>() @@ -527,7 +551,8 @@ impl EGraph { /// Enable the term-encoding pipeline on an existing `EGraph`. /// /// This method is to support the current CLI implementation with egglog-experimental (https://github.com/egraphs-good/egglog/issues/768) - pub(crate) fn with_term_encoding_enabled(mut self) -> Self { + #[doc(hidden)] + pub fn with_term_encoding_enabled(mut self) -> Self { self.proof_state.original_typechecking = Some(Box::new(self.clone())); self } @@ -535,7 +560,8 @@ impl EGraph { /// Enable proof generation on this e-graph. /// TODO proofs should be turned on during creation of the e-graph, not afterwards. /// This method is to support the current CLI implementation with egglog-experimental (https://github.com/egraphs-good/egglog/issues/768) - pub(crate) fn with_proofs_enabled(mut self) -> Self { + #[doc(hidden)] + pub fn with_proofs_enabled(mut self) -> Self { self = self.with_term_encoding_enabled(); self.proof_state.proofs_enabled = true; self @@ -1594,11 +1620,17 @@ impl EGraph { name, uf, proof_func, + proof_constructors, .. } => { - // If the sort has a :internal-uf field, store the mapping for extraction - if let Some(uf_name) = uf { - self.proof_state.uf_parent.insert(name.clone(), uf_name); + // Restore the sort's UF tables into proof_state: the constructor + // for extraction's `find_canonical`, the index for container + // rebuild's leader lookups. + if let Some((uf_ctor, uf_index)) = uf { + self.proof_state.uf_parent.insert(name.clone(), uf_ctor); + if let Some(uf_index) = uf_index { + self.proof_state.uf_function.insert(name.clone(), uf_index); + } } // If the sort has a :internal-proof-func field, store the mapping for proof lookup. // This annotation is set by proof instrumentation and consumed here. @@ -1607,6 +1639,16 @@ impl EGraph { .proof_func_parent .insert(name.clone(), proof_func_name); } + // The Proof sort's :internal-proof-names records the global proof + // constructors; restore them so container rebuild can recover them. + if let Some(pc) = proof_constructors { + let names = &mut self.proof_state.proof_names; + names.proof_datatype = name.clone(); + names.congr_constructor = pc.congr; + names.eq_trans_constructor = pc.trans; + names.eq_sym_constructor = pc.sym; + names.container_normalize_constructor = pc.normalize; + } log::info!("Declared sort {name}.") } ResolvedNCommand::Function(fdecl) => { @@ -1959,9 +2001,10 @@ impl EGraph { let typechecked = original_typechecking.typecheck_program(&desugared)?; for command in &typechecked { - if let Err(reason) = - command_supports_proof_encoding(&command.to_command(), &self.type_info) - { + if let Err(reason) = command_supports_proof_encoding( + &command.to_command(), + &original_typechecking.type_info, + ) { let command_text = format!("{}", command.to_command()); return Err(Error::UnsupportedProofCommand { command: command_text, @@ -2948,6 +2991,81 @@ mod tests { .unwrap(); } + #[test] + fn proof_support_accepts_container_sort_declarations() { + let mut egraph = EGraph::default(); + let resolved = egraph + .resolve_program(None, "(datatype X (x))\n(sort XPair (Pair X i64))") + .unwrap(); + assert!(program_supports_proofs(&resolved, &egraph.type_info)); + + let mut egraph = EGraph::default(); + let resolved = egraph + .resolve_program(None, "(datatype X (x))\n(sort XFn (UnstableFn (X) X))") + .unwrap(); + assert!(program_supports_proofs(&resolved, &egraph.type_info)); + } + + #[test] + fn proof_support_rejects_unstable_fn_primitives_without_validators() { + let mut egraph = EGraph::default(); + let resolved = egraph + .resolve_program( + None, + r#" + (datatype X (x)) + (sort XFn (UnstableFn (X) X)) + (function id (X) X :merge old) + (let f (unstable-fn "id")) + "#, + ) + .unwrap(); + assert!(!program_supports_proofs(&resolved, &egraph.type_info)); + } + + #[test] + fn proof_support_accepts_set_primitive_validators() { + let mut egraph = EGraph::default(); + let resolved = egraph + .resolve_program( + None, + r#" + (sort ISet (Set i64)) + (function Shared () ISet :merge (set-intersect old new)) + + (check (= (set-insert (set-empty) 1) (set-of 1))) + (check (= (set-remove (set-of 1 2) 2) (set-of 1))) + (check (= (set-length (set-of 1 2)) 2)) + (check (set-contains (set-of 1 2) 1)) + (check (set-not-contains (set-of 1 2) 3)) + (check (= (set-union (set-of 1) (set-of 2)) (set-of 1 2))) + (check (= (set-diff (set-of 1 2) (set-of 2)) (set-of 1))) + (check (= (set-intersect (set-of 1 2) (set-of 2 3)) (set-of 2))) + "#, + ) + .unwrap(); + + assert!(program_supports_proofs(&resolved, &egraph.type_info)); + } + + /// `set-get` indexes the runtime value order, which the proof checker + /// cannot reproduce from terms, so it has no validator. + #[test] + fn proof_support_rejects_set_get() { + let mut egraph = EGraph::default(); + let resolved = egraph + .resolve_program( + None, + r#" + (sort ISet (Set i64)) + (check (= (set-get (set-of 1 2) 0) 1)) + "#, + ) + .unwrap(); + + assert!(!program_supports_proofs(&resolved, &egraph.type_info)); + } + #[test] fn test_typecheck_expr_with_bindings_and_output_rejects_mismatch() { let mut egraph = EGraph::default(); diff --git a/egglog/src/prelude.rs b/egglog/src/prelude.rs index 3e8b6c5..30194d0 100644 --- a/egglog/src/prelude.rs +++ b/egglog/src/prelude.rs @@ -758,6 +758,8 @@ pub fn add_sort(egraph: &mut EGraph, name: &str) -> Result, E presort_and_args: None, uf: None, proof_func: None, + container_rebuild: None, + proof_constructors: None, unionable: true, }]) } @@ -913,6 +915,14 @@ pub trait ContainerSort: Any + Send + Sync + Debug { ) -> TermId; fn serialized_name(&self, container_values: &ContainerValues, value: Value) -> String; + /// Optional: a container that supports proofs returns its canonical + /// constructor head and the validator that canonicalizes its term form (e.g. + /// `set-of` sorts and dedups). `None` (the default) means proofs are + /// unsupported for this container. See [`Sort::rebuild_container_normalizer`]. + fn rebuild_container_normalizer(&self) -> Option<(String, PrimitiveValidator)> { + None + } + fn to_arcsort(self) -> ArcSort where Self: Sized, @@ -983,6 +993,10 @@ impl Sort for ContainerSortImpl { self.0 .reconstruct_termdag(container_values, value, termdag, element_terms) } + + fn rebuild_container_normalizer(&self) -> Option<(String, PrimitiveValidator)> { + self.0.rebuild_container_normalizer() + } } /// Add a [`BaseSort`] to the e-graph diff --git a/egglog/src/proofs/mod.rs b/egglog/src/proofs/mod.rs index 0d6359b..037d42a 100644 --- a/egglog/src/proofs/mod.rs +++ b/egglog/src/proofs/mod.rs @@ -1,4 +1,5 @@ pub(crate) mod proof_checker; +pub(crate) mod proof_container_rebuild; pub(crate) mod proof_encoding; pub(crate) mod proof_encoding_helpers; pub(crate) mod proof_extraction; diff --git a/egglog/src/proofs/proof_checker.rs b/egglog/src/proofs/proof_checker.rs index 8938026..050b332 100644 --- a/egglog/src/proofs/proof_checker.rs +++ b/egglog/src/proofs/proof_checker.rs @@ -20,6 +20,25 @@ use crate::{ }; use thiserror::Error; +/// A side condition is a rule-body fact that is just a container-producing +/// primitive applied to bound variables — `(= v (vec-of e))`, `(= (set-of a) +/// (set-of b))`, etc. Its proof is a bare [`Justification::Eval`] marker and it +/// is verified by re-evaluation in [`ProofStore::check_side_condition`] rather +/// than by matching a premise proposition. +pub(super) fn is_container_side_condition(fact: &ResolvedFact) -> bool { + fn is_container_primitive(expr: &ResolvedExpr) -> bool { + matches!( + expr, + ResolvedExpr::Call(_, ResolvedCall::Primitive(p), _) + if p.output().is_eq_container_sort() + ) + } + match fact { + ResolvedFact::Eq(_, lhs, rhs) => is_container_primitive(lhs) || is_container_primitive(rhs), + ResolvedFact::Fact(expr) => is_container_primitive(expr), + } +} + /// Result of processing actions: terms bound to variables and propositions #[derive(Debug, Clone)] pub(crate) struct ActionContext { @@ -455,6 +474,41 @@ pub enum ProofCheckErrorKind { /// Two rules have the same name #[error("Duplicate rule name '{rule_name}' found in the program")] DuplicateRuleName { rule_name: String }, + /// Container-normalize proof: the normalized container term doesn't match the claim + #[error( + "Proof {proof_id}: container normalization error - normalizing {raw:?} gives {normalized:?}, but proof claims rhs {proof_rhs:?} (lhs ok: {lhs_ok})" + )] + ContainerNormalizeMismatch { + proof_id: ProofId, + raw: TermId, + normalized: TermId, + proof_rhs: TermId, + lhs_ok: bool, + }, + /// Eval marker appeared outside a container side condition + #[error("Proof {proof_id}: Eval marker used outside a container side condition")] + EvalOutsideSideCondition { proof_id: ProofId }, + /// A container side condition's two sides evaluate to different containers + #[error("Rule '{rule_name}': side condition {fact} does not hold ({lhs:?} != {rhs:?})")] + SideConditionMismatch { + rule_name: String, + fact: String, + lhs: TermId, + rhs: TermId, + }, + /// A container side condition has no determined side to evaluate + #[error("Rule '{rule_name}': side condition {fact} has no bound side to evaluate")] + SideConditionUnbound { rule_name: String, fact: String }, + /// Not in proof normal form: a primitive has a constructor/function argument + #[error( + "Rule '{rule_name}': primitive argument {arg} is not a variable, literal, or primitive (not in proof normal form)" + )] + PrimitiveNonNormalArg { rule_name: String, arg: String }, + /// Not in proof normal form: a container primitive is not a side condition + #[error( + "Rule '{rule_name}': container primitive {prim} appears nested rather than as a side condition (not in proof normal form)" + )] + ContainerPrimitiveNotSideCondition { rule_name: String, prim: String }, } /// Context needed for proof checking @@ -587,35 +641,33 @@ impl ProofStore { .into()); } - // Check each premise proof - let mut premise_propositions = Vec::new(); - for &premise_id in premise_proofs { - let prop = self.check_proof_with_context(premise_id, program, ctx)?; - premise_propositions.push(prop); - } - - let substitution_with_globals = ctx + let mut working_subst = ctx .global_bindings .iter() .map(|(k, v)| (k.clone(), *v)) .chain(substitution.iter().map(|(k, v)| (k.clone(), *v))) .collect::>(); - // Verify that premises match the rule body under the substitution - for (fact, prop) in rule.body.iter().zip(premise_propositions.iter()) { - self.check_fact_matches_proposition( - fact, - prop, - &substitution_with_globals, - name, - )?; + // Verify each premise in order. A container side condition carries + // only an `Eval` marker, so re-evaluate it here with the rule's + // typed validator — this binds its output into the substitution for + // later facts. Every other fact is matched against its premise + // proposition. + for (fact, &premise_id) in rule.body.iter().zip(premise_proofs.iter()) { + self.assert_body_proof_normal_form(fact, name)?; + if is_container_side_condition(fact) { + self.check_side_condition(fact, &mut working_subst, name)?; + } else { + let prop = self.check_proof_with_context(premise_id, program, ctx)?; + self.check_fact_matches_proposition(fact, &prop, &working_subst, name)?; + } } // Verify that the conclusion matches what the rule produces self.check_rule_produces_equality( rule, substitution, - &substitution_with_globals, + &working_subst, proof.proposition(), name, )?; @@ -859,6 +911,34 @@ impl ProofStore { Ok(Proposition::new(proof.lhs(), proof.rhs())) } + + Justification::ContainerNormalize { proof: inner_id } => { + // The sub-proof establishes `t1 = raw`; normalize `raw` to its + // canonical container form via the validator for its head. + let inner_prop = self.check_proof_with_context(*inner_id, program, ctx)?; + let raw = inner_prop.rhs; + let normalized = self.normalize_container(raw); + let lhs_ok = proof.lhs() == inner_prop.lhs; + if !lhs_ok || proof.rhs() != normalized { + return Err(ProofCheckErrorKind::ContainerNormalizeMismatch { + proof_id, + raw, + normalized, + proof_rhs: proof.rhs(), + lhs_ok, + } + .into()); + } + Ok(Proposition::new(proof.lhs(), proof.rhs())) + } + + Justification::Eval => { + // The `Eval` marker is the proof of a container side condition and + // is checked by re-evaluation in `check_side_condition` (driven by + // the rule body), never on its own. Reaching it here means it + // appeared outside a side condition, which is malformed. + Err(ProofCheckErrorKind::EvalOutsideSideCondition { proof_id }.into()) + } }; // Cache the result @@ -869,7 +949,130 @@ impl ProofStore { result } - /// Check that a fact matches a proposition under a substitution + /// Check a container side condition by re-evaluating it against the rule + /// body, rather than against a premise proposition. An unbound side is the + /// side condition's output and is bound; otherwise both sides must evaluate + /// to the same container. Extends `subst` with any bound output. + fn check_side_condition( + &mut self, + fact: &ResolvedFact, + subst: &mut HashMap, + rule_name: &str, + ) -> Result<(), ProofCheckError> { + let (lhs, rhs) = match fact { + ResolvedFact::Eq(_, lhs, rhs) => (lhs, rhs), + ResolvedFact::Fact(expr) => { + return match self.eval_side(expr, subst, rule_name)? { + Some(_) => Ok(()), + None => Err(ProofCheckErrorKind::SideConditionUnbound { + rule_name: rule_name.to_string(), + fact: format!("{fact}"), + } + .into()), + }; + } + }; + let lhs_val = self.eval_side(lhs, subst, rule_name)?; + let rhs_val = self.eval_side(rhs, subst, rule_name)?; + match (lhs, lhs_val, rhs, rhs_val) { + // One side is an unbound variable: it is the side condition's output. + (ResolvedExpr::Var(_, v), None, _, Some(val)) + | (_, Some(val), ResolvedExpr::Var(_, v), None) => { + subst.insert(v.name.clone(), val); + Ok(()) + } + // Both sides determined: they must be the same container. + (_, Some(l), _, Some(r)) => { + if l != r { + return Err(ProofCheckErrorKind::SideConditionMismatch { + rule_name: rule_name.to_string(), + fact: format!("{fact}"), + lhs: l, + rhs: r, + } + .into()); + } + Ok(()) + } + _ => Err(ProofCheckErrorKind::SideConditionUnbound { + rule_name: rule_name.to_string(), + fact: format!("{fact}"), + } + .into()), + } + } + + /// Evaluate one side of a side condition: an unbound variable yields `None` + /// (it is an output to bind), anything else is evaluated with the rule's + /// typed primitive validators. + fn eval_side( + &mut self, + expr: &ResolvedExpr, + subst: &HashMap, + rule_name: &str, + ) -> Result, ProofCheckError> { + match expr { + ResolvedExpr::Var(_, v) => Ok(subst.get(&v.name).copied()), + _ => { + let (term, _) = eval_expr_with_subst(rule_name, expr, &mut self.term_dag, subst)?; + Ok(Some(term)) + } + } + } + + /// Reject a rule-body fact that isn't in proof normal form: a primitive must + /// not have a constructor/function argument, and a container-producing + /// primitive must not appear nested (it must be its own side condition). + fn assert_body_proof_normal_form( + &self, + fact: &ResolvedFact, + rule_name: &str, + ) -> Result<(), ProofCheckError> { + fn check(expr: &ResolvedExpr, rule_name: &str) -> Result<(), ProofCheckError> { + let ResolvedExpr::Call(_, head, args) = expr else { + return Ok(()); + }; + for arg in args { + match head { + ResolvedCall::Primitive(_) + if matches!(arg, ResolvedExpr::Call(_, ResolvedCall::Func(_), _)) => + { + return Err(ProofCheckErrorKind::PrimitiveNonNormalArg { + rule_name: rule_name.to_string(), + arg: format!("{arg}"), + } + .into()); + } + ResolvedCall::Func(_) + if matches!( + arg, + ResolvedExpr::Call(_, ResolvedCall::Primitive(p), _) + if p.output().is_eq_container_sort() + ) => + { + return Err(ProofCheckErrorKind::ContainerPrimitiveNotSideCondition { + rule_name: rule_name.to_string(), + prim: format!("{arg}"), + } + .into()); + } + _ => {} + } + check(arg, rule_name)?; + } + Ok(()) + } + match fact { + ResolvedFact::Eq(_, lhs, rhs) => { + check(lhs, rule_name)?; + check(rhs, rule_name)?; + } + ResolvedFact::Fact(expr) => check(expr, rule_name)?, + } + Ok(()) + } + + /// Check that a fact matches a proposition under a substitution fn check_fact_matches_proposition( &mut self, fact: &ResolvedFact, diff --git a/egglog/src/proofs/proof_container_rebuild.rs b/egglog/src/proofs/proof_container_rebuild.rs new file mode 100644 index 0000000..7331829 --- /dev/null +++ b/egglog/src/proofs/proof_container_rebuild.rs @@ -0,0 +1,368 @@ +//! Container rebuild for the term/proof encoding. +//! +//! Registers a container sort's rebuild primitives from its +//! [`ContainerRebuildSpec`] ([`register_container_rebuild_from_spec`]), and +//! defines the `ContainerRebuild` / `ContainerRebuildProof` primitives that +//! canonicalize a container's elements to their union-find leaders (and, in +//! proof mode, prove the rebuild). The encoder side that *builds* the spec lives +//! in [`super::proof_encoding`]. + +use crate::exec_state::{Internal, RegistrySealed}; +use crate::*; + +/// Register a container sort's rebuild primitives from its +/// [`ContainerRebuildSpec`]. Called when a container Sort command carrying an +/// `:internal-container-rebuild` annotation is typechecked, so the primitives +/// exist before the rebuild rules — both during encoding and on re-parse. +pub(crate) fn register_container_rebuild_from_spec( + eg: &mut EGraph, + sort_name: &str, + spec: &ContainerRebuildSpec, +) { + let Some(container_sort) = eg.get_sort_by_name(sort_name).cloned() else { + return; + }; + // Each element eq-sort's UF index table, recovered from proof_state (filled + // by the element sorts' `:internal-uf` on re-parse) rather than the spec. + let mut uf_names = HashMap::default(); + collect_element_uf_names(eg, &container_sort, &mut uf_names); + + eg.add_read_primitive( + ContainerRebuild { + name: spec.internal_rebuild_prim.clone(), + container_sort: container_sort.clone(), + uf_names: uf_names.clone(), + proof_mode: spec.internal_rebuild_proof_prim.is_some(), + }, + None, + ); + + if let Some(proof_prim) = &spec.internal_rebuild_proof_prim { + // Each container's `Proof` table (this sort + nested containers), + // recovered from proof_state (filled by `:internal-proof-func`). + let mut cproof_names = HashMap::default(); + collect_container_proof_names(eg, &container_sort, &mut cproof_names); + // The global proof constructors, recovered from proof_state (repopulated + // from the `Proof` sort's `:internal-proof-names` on re-parse). + let names = &eg.proof_state.proof_names; + let congr_name = names.congr_constructor.clone(); + let trans_name = names.eq_trans_constructor.clone(); + let sym_name = names.eq_sym_constructor.clone(); + let container_normalize_name = names.container_normalize_constructor.clone(); + let proof_sort: ArcSort = std::sync::Arc::new(EqSort { + name: names.proof_datatype.clone(), + }); + eg.add_full_primitive( + ContainerRebuildProof { + name: proof_prim.clone(), + container_sort, + proof_sort, + uf_names, + cproof_names, + congr_name, + trans_name, + sym_name, + container_normalize_name, + }, + None, + ); + } +} + +/// Each transitively-reachable eq-sort element's UF index table, from +/// `proof_state.uf_function` (filled by element sorts' `:internal-uf`). +fn collect_element_uf_names(eg: &EGraph, sort: &ArcSort, out: &mut HashMap) { + for elem in sort.inner_sorts() { + if elem.is_eq_sort() { + if let Some(uf) = eg.proof_state.uf_function.get(elem.name()) { + out.insert(elem.name().to_string(), uf.clone()); + } + } else if elem.is_eq_container_sort() { + collect_element_uf_names(eg, &elem, out); + } + } +} + +/// The `Proof` table for `sort` and every nested container sort, from +/// `proof_state.proof_func_parent` (filled by `:internal-proof-func`). +fn collect_container_proof_names(eg: &EGraph, sort: &ArcSort, out: &mut HashMap) { + if let Some(cp) = eg.proof_state.proof_func_parent.get(sort.name()) { + out.insert(sort.name().to_string(), cp.clone()); + } + for elem in sort.inner_sorts() { + if elem.is_eq_container_sort() { + collect_container_proof_names(eg, &elem, out); + } + } +} + +/// Re-intern container `value` of `sort` with each contained value remapped +/// through `leaders` (an old-value -> union-find-leader map); the value-level +/// half of the container rebuild performed by the rebuild rules. +fn rebuild_with_leaders( + cvs: &ContainerValues, + es: &mut ExecutionState, + sort: &ArcSort, + value: Value, + leaders: &HashMap, +) -> Value { + let type_id = sort + .value_type() + .expect("container sorts have a value type"); + cvs.rebuild_val_with(type_id, value, es, &|v| { + leaders.get(&v).copied().unwrap_or(v) + }) +} + +/// Recursively canonicalize a container `value` of sort `sort` for the term +/// encoding, returning the rebuilt interned value. Each element is resolved by +/// a uniform per-child rule: an eq-sort element maps to its union-find leader +/// (via `UF_f`; in proof mode the index stores `(pair leader proof)`), a +/// container element is recursively rebuilt, and anything else is unchanged. +fn rebuild_container_value_rec( + state: &mut ReadState, + sort: &ArcSort, + value: Value, + uf_names: &HashMap, + proof_mode: bool, +) -> Option { + let elements = { + let cvs = state.container_values(); + sort.inner_values(cvs, value) + }; + let mut leaders: HashMap = HashMap::default(); + for (esort, eval) in &elements { + let new = if esort.is_eq_sort() { + match self_lookup_leader(state, uf_names, esort, *eval, proof_mode)? { + Some(leader) => leader, + None => *eval, + } + } else if esort.is_eq_container_sort() { + rebuild_container_value_rec(state, esort, *eval, uf_names, proof_mode)? + } else { + *eval + }; + if new != *eval { + leaders.insert(*eval, new); + } + } + let cvs = state.container_values(); + let es = state.raw_exec_state(); + Some(rebuild_with_leaders(cvs, es, sort, value, &leaders)) +} + +/// Look up an eq-sort element's union-find leader, if a `UF_f` row exists. +/// In proof mode the index stores `(pair leader proof)`, so take `pair-first`. +/// Returns `Ok(None)` when there is no UF row (element is its own leader). +fn self_lookup_leader( + state: &mut ReadState, + uf_names: &HashMap, + esort: &ArcSort, + eval: Value, + proof_mode: bool, +) -> Option> { + let Some(uf_name) = uf_names.get(esort.name()) else { + return Some(None); + }; + let Some(looked_up) = state + .lookup(uf_name, eval) + .expect("union-find index lookup failed") + else { + return Some(None); + }; + let leader = if proof_mode { + state + .container_values() + .get_val::(looked_up)? + .first + } else { + looked_up + }; + Some(Some(leader)) +} + +/// A term-encoding primitive that canonicalizes a container value's elements to +/// their union-find leaders (recursing through nested containers). Registered +/// per container sort by `ensure_container_rebuild` and +/// invoked from the container-column arm of the rebuild rules. It reads the +/// `UF_f` tables, so it is only valid in a `:naive` rule (read-context body). +#[derive(Clone)] +struct ContainerRebuild { + name: String, + container_sort: ArcSort, + /// element-sort name -> `UF_f` table name (all reachable eq-sorts) + uf_names: HashMap, + /// In proof mode the UF index returns `(pair leader proof)`; take pair-first. + proof_mode: bool, +} + +impl Primitive for ContainerRebuild { + fn name(&self) -> &str { + &self.name + } + + fn get_type_constraints(&self, span: &Span) -> Box { + SimpleTypeConstraint::new( + &self.name, + vec![self.container_sort.clone(), self.container_sort.clone()], + span.clone(), + ) + .into_box() + } +} + +impl ReadPrim for ContainerRebuild { + fn apply<'a, 'db>(&self, mut state: ReadState<'a, 'db>, args: &[Value]) -> Option { + rebuild_container_value_rec( + &mut state, + &self.container_sort, + args[0], + &self.uf_names, + self.proof_mode, + ) + } +} + +/// Proof-mode counterpart of [`ContainerRebuild`]: mints a `Congr` chain +/// proving `old_container = rebuilt_container` (recursing through nested +/// containers). Reads `UF_f` (element equality proofs) and `Proof` +/// (reflexive bases), mints `Congr`/`Trans`/`Sym` terms, and anchors a +/// reflexive proof on each rebuilt container so it can be rebuilt again later. +/// It is a [`FullPrim`], valid only in a `:naive` rule's action. +#[derive(Clone)] +struct ContainerRebuildProof { + name: String, + container_sort: ArcSort, + proof_sort: ArcSort, + /// element-sort name -> `UF_f` table name (all reachable eq-sorts) + uf_names: HashMap, + /// container-sort name -> `Proof` table name (all reachable containers) + cproof_names: HashMap, + /// `Congr` / `Trans` / `Sym` / `ContainerNormalize` proof constructor names + congr_name: String, + trans_name: String, + sym_name: String, + container_normalize_name: String, +} + +impl Primitive for ContainerRebuildProof { + fn name(&self) -> &str { + &self.name + } + + fn get_type_constraints(&self, span: &Span) -> Box { + SimpleTypeConstraint::new( + &self.name, + vec![self.container_sort.clone(), self.proof_sort.clone()], + span.clone(), + ) + .into_box() + } +} + +impl FullPrim for ContainerRebuildProof { + fn apply<'a, 'db>(&self, mut state: FullState<'a, 'db>, args: &[Value]) -> Option { + let (_rebuilt, proof) = + rebuild_container_proof_rec(&mut state, self, &self.container_sort, args[0])?; + Some(proof) + } +} + +/// Recursively rebuild `value` (of container sort `sort`) and produce a proof +/// that `value = rebuilt`. Returns `(rebuilt_value, proof)`. Uses the same +/// per-child resolution as [`rebuild_container_value_rec`], additionally +/// folding a `Congr` step for every changed child and recording a reflexive +/// anchor `Proof(rebuilt) = Trans(Sym proof, proof)` so the rebuilt +/// value can itself be rebuilt in a later iteration. +fn rebuild_container_proof_rec( + state: &mut FullState, + prim: &ContainerRebuildProof, + sort: &ArcSort, + value: Value, +) -> Option<(Value, Value)> { + // Reflexive base proof `value = value`. + let base = state + .lookup(prim.cproof_names.get(sort.name())?, value) + .expect("container proof lookup failed")?; + let elements = { + let cvs = state.container_values(); + sort.inner_values(cvs, value) + }; + + let mut leaders: HashMap = HashMap::default(); + let mut child_proofs: Vec<(usize, Value)> = vec![]; + for (j, (esort, eval)) in elements.iter().enumerate() { + if esort.is_eq_sort() { + if let Some(uf_name) = prim.uf_names.get(esort.name()) + && let Some(pair_val) = state + .lookup(uf_name, *eval) + .expect("union-find index lookup failed") + { + let (leader, proof) = { + let pc = state + .container_values() + .get_val::(pair_val)?; + (pc.first, pc.second) + }; + if leader != *eval { + leaders.insert(*eval, leader); + child_proofs.push((j, proof)); + } + } + } else if esort.is_eq_container_sort() { + let (rebuilt_child, child_proof) = + rebuild_container_proof_rec(state, prim, esort, *eval)?; + if rebuilt_child != *eval { + leaders.insert(*eval, rebuilt_child); + child_proofs.push((j, child_proof)); + } + } + } + + // Rebuild the value against the collected leaders. + let rebuilt = { + let cvs = state.container_values(); + let es = state.raw_exec_state(); + rebuild_with_leaders(cvs, es, sort, value, &leaders) + }; + + // Fold a `Congr` step per changed child onto the reflexive base. This + // proves `value = raw`, where `raw` is the term with children replaced in + // place (it may be in non-canonical order, or have duplicate/clobbering + // entries for collapsing containers). + let congr_action = state.registry().lookup_table(&prim.congr_name)?.clone(); + let mut current = base; + for (j, proof) in child_proofs { + let j_val = state.base_values().get::(j as i64); + current = + congr_action.lookup_or_insert(state.raw_exec_state(), &[current, j_val, proof])?; + } + + // Bridge the (possibly non-canonical) `raw` term to the canonical `rebuilt` + // term with the container normalization: `ContainerNormalize(current)` proves + // `value = normalize(raw)`, which the checker recomputes to match + // `reconstruct_termdag(rebuilt)`. We mint it unconditionally; for + // order/arity-preserving containers (Vec/Pair) the normalization is the + // identity, so it is a no-op the proof simplifier removes. + let normalize_action = state + .registry() + .lookup_table(&prim.container_normalize_name)? + .clone(); + current = normalize_action.lookup_or_insert(state.raw_exec_state(), &[current])?; + + // Anchor a reflexive proof on the rebuilt value for future rebuilds. + if rebuilt != value { + let sym_action = state.registry().lookup_table(&prim.sym_name)?.clone(); + let trans_action = state.registry().lookup_table(&prim.trans_name)?.clone(); + let cproof_action = state + .registry() + .lookup_table(prim.cproof_names.get(sort.name())?)? + .clone(); + // Sym(current): rebuilt = value; Trans(Sym(current), current): rebuilt = rebuilt. + let sym_p = sym_action.lookup_or_insert(state.raw_exec_state(), &[current])?; + let refl = trans_action.lookup_or_insert(state.raw_exec_state(), &[sym_p, current])?; + cproof_action.insert(state.raw_exec_state(), [rebuilt, refl].into_iter()); + } + + Some((rebuilt, current)) +} diff --git a/egglog/src/proofs/proof_encoding.md b/egglog/src/proofs/proof_encoding.md index c0866b8..9831852 100644 --- a/egglog/src/proofs/proof_encoding.md +++ b/egglog/src/proofs/proof_encoding.md @@ -363,3 +363,53 @@ The structure is the same as term mode — view updates use `set`, UF updates us For nested terms, congruence proofs are built to ensure the proof terms match the original queries. +# Containers + +Container sorts (`Vec`, `Set`, `Map`, `MultiSet`, `Pair`) are never unioned +directly, so they get **no** union-find tables. Instead a container is +recanonicalized structurally when its elements' e-classes change. Take: + +```text +(datatype Math (Num i64)) +(sort MathVec (Vec Math)) +(constructor Wrap (MathVec) Math) +``` + +The `MathVec` argument of `Wrap` is a container column, so `Wrap`'s rebuild rule +canonicalizes it with a per-container *rebuild primitive* the encoding registers +(here `MathVec_rebuild`), alongside the usual `UF_Mathf` lookup for the +representative column: + +```text +(rule ((= v (WrapView c0 c1)) + (= c0_rebuilt (MathVec_rebuild c0)) + (= c1_leader (UF_Mathf c1)) + (guard (or (bool-!= c0 c0_rebuilt) (bool-!= c1 c1_leader)))) + ((set (WrapView c0_rebuilt c1_leader) ()) + (delete (WrapView c0 c1))) + :ruleset rebuilding :name "rebuild_rule" :naive) +``` + +The primitive clones the container, remaps each element to its union-find leader, +and re-interns it. Because it reads the elements' `UF_f` indices rather than +joining a tracked table, the rule is marked `:naive`: an element becoming equal +to another produces no delta on the container's own view row, so the rule must +rescan the view each round. Nested containers (e.g. `(Vec (Vec Math))`) rebuild +by recursing through container-typed elements. + +**Proofs.** A container's term form is the s-expr of its constructor — +`(vec-of e0 e1 …)`, `(pair a b)`, `(map-of k0 v0 …)` — so the generic `Congr` +machinery applies unchanged. Every container sort gets a reflexive `Proof` +table (a `container = container` proof, set at creation); a `Congr` chain over +the changed elements, anchored there, proves `old = new` and folds into the +view's congruence step like an eq-sort child's UF proof. + +For reordering/merging containers (`Set`, `Map`, `MultiSet`) the element-wise +`Congr` term can be out of order or hold duplicates, so a `ContainerNormalize` +step (see [`crate::proofs::proof_format`]) canonicalizes it — sort + dedup for +sets, sort for multisets, sort + last-write-wins for maps. It is emitted on every +rebuild and dropped by the proof simplifier wherever it is the identity (always +for `Vec` / `Pair`). Maps use a flat `(map-of k0 v0 …)` form so this works like +the other containers. + +See [`crate::proofs::proof_container_rebuild`] for the rebuild primitives. diff --git a/egglog/src/proofs/proof_encoding.rs b/egglog/src/proofs/proof_encoding.rs index a51701e..1d89085 100644 --- a/egglog/src/proofs/proof_encoding.rs +++ b/egglog/src/proofs/proof_encoding.rs @@ -10,6 +10,13 @@ pub(crate) struct EncodingState { pub uf_function: HashMap, /// Maps sort name -> proof function name (set from :internal-proof-func annotation). pub proof_func_parent: HashMap, + /// Maps container sort name -> the name of its registered container-rebuild + /// primitive (`ContainerRebuild`). Cached so each container sort gets + /// a single rebuild primitive shared across all functions using it. + pub container_rebuild_name: HashMap, + /// Maps container sort name -> the name of its registered proof-producing + /// container-rebuild primitive (`ContainerRebuildProof`). Proof mode only. + pub container_rebuild_proof_name: HashMap, /// Function name -> (hidden current-value function, input arity). The /// current function uses the original eager backend merge, so cleanup can /// discard stale proof-view candidates whenever the current value already @@ -35,6 +42,8 @@ impl EncodingState { uf_parent: HashMap::default(), uf_function: HashMap::default(), proof_func_parent: HashMap::default(), + container_rebuild_name: HashMap::default(), + container_rebuild_proof_name: HashMap::default(), merge_current: HashMap::default(), term_header_added: false, original_typechecking: None, @@ -101,11 +110,36 @@ impl<'a> ProofInstrumentor<'a> { /// When one term has two parents, those parents are unioned in the merge action. /// Also, we have a rule that maintains the invariant that each term points to its /// canonical representative. - fn declare_sort(&mut self, sort_name: &str) -> Vec { + fn declare_sort(&mut self, sort_name: &str, is_container: bool) -> Vec { + // Container sorts are never unioned directly; their values are + // canonicalized structurally by the container rebuild path (see + // `rebuilding_rules`). So they get no per-sort union-find tables or + // maintenance rules. In proof mode they still get a `Proof` + // term-proof table (and an `Ast` wrapper) used as the reflexive + // anchor for container rebuild proofs. + if is_container { + if self.egraph.proof_state.proofs_enabled { + let term_proof_name = self.term_proof_name(sort_name); + let add_to_ast_code = self.add_to_ast(sort_name); + let proof_type = self.proof_type_str().to_string(); + return self.parse_program(&format!( + "{add_to_ast_code} + (function {term_proof_name} ({sort_name}) {proof_type} :merge old :internal-hidden)" + )); + } + return vec![]; + } let pname = self.uf_name(sort_name); let uf_function_name = self.uf_function_name(sort_name); let fresh_name = self.egraph.parser.symbol_gen.fresh("uf_update"); let uf_function_index_name = self.egraph.parser.symbol_gen.fresh("uf_function_index"); + // Fresh query-variable names for the UF maintenance rules. These must be + // gensym'd (not literal `a`/`b`/`c`) so they cannot shadow a user-defined + // global constructor of the same name when the encoded program is + // re-parsed (e.g. a program with a `(constructor b () ...)`). + let a = self.egraph.parser.symbol_gen.fresh("uf_a"); + let b = self.egraph.parser.symbol_gen.fresh("uf_b"); + let c = self.egraph.parser.symbol_gen.fresh("uf_c"); let path_compress_ruleset_name = self.proof_names().path_compress_ruleset_name.clone(); let single_parent_ruleset_name = self.proof_names().single_parent_ruleset_name.clone(); @@ -124,31 +158,31 @@ impl<'a> ProofInstrumentor<'a> { let sym = self.proof_names().eq_sym_constructor.clone(); ( format!( - "(= {p1_fresh} ({pname} a b)) - (= {p2_fresh} ({pname} b c))" + "(= {p1_fresh} ({pname} {a} {b})) + (= {p2_fresh} ({pname} {b} {c}))" ), format!( - "(delete ({pname} a b)) - (set ({pname} a c) ({trans} {p1_fresh} {p2_fresh}))" + "(delete ({pname} {a} {b})) + (set ({pname} {a} {c}) ({trans} {p1_fresh} {p2_fresh}))" ), format!( - "(= {p1_fresh} ({pname} a b)) - (= {p2_fresh} ({pname} a c))" + "(= {p1_fresh} ({pname} {a} {b})) + (= {p2_fresh} ({pname} {a} {c}))" ), format!( - "(delete ({pname} a b)) - (set ({pname} b c) ({trans} ({sym} {p1_fresh}) {p2_fresh}))" + "(delete ({pname} {a} {b})) + (set ({pname} {b} {c}) ({trans} ({sym} {p1_fresh}) {p2_fresh}))" ), ) } else { ( - format!("({pname} a b)\n ({pname} b c)"), + format!("({pname} {a} {b})\n ({pname} {b} {c})"), format!( - "(delete ({pname} a b))\n (set ({pname} a c) ())" + "(delete ({pname} {a} {b}))\n (set ({pname} {a} {c}) ())" ), - format!("({pname} a b)\n ({pname} a c)"), + format!("({pname} {a} {b})\n ({pname} {a} {c})"), format!( - "(delete ({pname} a b))\n (set ({pname} b c) ())" + "(delete ({pname} {a} {b}))\n (set ({pname} {b} {c}) ())" ), ) }; @@ -162,15 +196,15 @@ impl<'a> ProofInstrumentor<'a> { ( pair_sort.clone(), format!("(sort {pair_sort} (Pair {sort_name} {proof_type}))"), - format!("(= {proof_fresh} ({pname} a b))"), - format!("(set ({uf_function_name} a) (pair b {proof_fresh}))"), + format!("(= {proof_fresh} ({pname} {a} {b}))"), + format!("(set ({uf_function_name} {a}) (pair {b} {proof_fresh}))"), ) } else { ( sort_name.to_string(), "".to_string(), - format!("({pname} a b)"), - format!("(set ({uf_function_name} a) b)"), + format!("({pname} {a} {b})"), + format!("(set ({uf_function_name} {a}) {b})"), ) }; @@ -180,14 +214,14 @@ impl<'a> ProofInstrumentor<'a> { (function {uf_function_name} ({sort_name}) {uf_function_output_type} :merge new :unextractable :internal-hidden) ;; performs path compression, ensuring each term points to the representative (rule ({path_compress_query} - (!= b c)) + (!= {b} {c})) ({path_compress_action}) :ruleset {path_compress_ruleset_name} :name \"{fresh_name}\") ;; ensures each term has only one parent (rule ({single_parent_query} - (!= b c) - (= (ordering-max b c) b)) + (!= {b} {c}) + (= (ordering-max {b} {c}) {b})) ({single_parent_action}) :ruleset {single_parent_ruleset_name} :name \"singleparent{fresh_name}\") @@ -524,9 +558,15 @@ impl<'a> ProofInstrumentor<'a> { /// Rules that update the views when children change. fn rebuilding_rules(&mut self, fdecl: &ResolvedFunctionDecl) -> Vec { let types = fdecl.resolved_schema.view_types(); + let proofs_enabled = self.egraph.proof_state.proofs_enabled; - // Check if there are any eq-sort columns at all; if not, no rebuild rule needed. - if !types.iter().any(|t| t.is_eq_sort()) { + // Check if there are any rebuildable columns at all; if not, no rule needed. + // Container columns (eq-container sorts) are rebuilt by calling a + // per-container rebuild primitive; eq-sort columns by a UF lookup. + if !types + .iter() + .any(|t| t.is_eq_sort() || t.is_eq_container_sort()) + { return vec![]; } @@ -535,12 +575,21 @@ impl<'a> ProofInstrumentor<'a> { let children_vec: Vec = (0..types.len()).map(child).collect(); let children = format!("{}", ListDisplay(&children_vec, " ")); - // For each eq-sort column, look up its leader via the UF table. - // For non-eq-sort columns, the leader is the same as the original. + // For each rebuildable column, compute its canonical value (and, in + // proof mode, a proof that the original equals the canonical value). + // Non-rebuildable columns keep their original value and have no proof. let mut uf_queries = vec![]; let mut leader_vars: Vec = vec![]; let mut bool_neq_exprs = vec![]; let mut uf_proof_vars: Vec> = vec![]; + // Action prologue for container columns (proof mode): bind each + // container rebuild proof and set a reflexive anchor for the rebuilt + // container value so it can itself be rebuilt later. + let mut container_proof_bindings: Vec = vec![]; + let mut container_reflexive_sets: Vec = vec![]; + // Whether any container column is present (forces a `:naive` rule, since + // the rebuild primitives read the UF index / mint proofs). + let mut has_container = false; for (i, ty) in types.iter().enumerate() { if ty.is_eq_sort() { @@ -548,7 +597,7 @@ impl<'a> ProofInstrumentor<'a> { let uf_function_name = self.uf_function_name(ty.name()); let ci = child(i); - if self.egraph.proof_state.proofs_enabled { + if proofs_enabled { // UF function index returns a Pair(leader, proof); one lookup gives both let pair_var = self.fresh_var(); let proof_var = format!("(pair-second {pair_var})"); @@ -564,6 +613,35 @@ impl<'a> ProofInstrumentor<'a> { bool_neq_exprs.push(format!("(bool-!= {ci} {leader_var})")); leader_vars.push(leader_var); + } else if ty.is_eq_container_sort() { + // Container column: canonicalize its elements via the per-container + // rebuild primitive in the rule body. The rule is `:naive` so this + // read primitive is permitted there. + has_container = true; + let rebuilt_var = format!("c{i}_rebuilt_"); + let ci = child(i); + let value_prim = self.ensure_container_rebuild(ty); + uf_queries.push(format!("(= {rebuilt_var} ({value_prim} {ci}))")); + bool_neq_exprs.push(format!("(bool-!= {ci} {rebuilt_var})")); + leader_vars.push(rebuilt_var.clone()); + + if proofs_enabled { + // The proof primitive (run in the action) mints a congruence + // proof that `ci = rebuilt`. Anchor a reflexive proof on the + // rebuilt value via `Trans(Sym p, p)` for future rebuilds. + let proof_prim = self.ensure_container_rebuild_proof(ty); + let proof_var = self.fresh_var(); + let cproof = self.term_proof_name(ty.name()); + let sym = self.proof_names().eq_sym_constructor.clone(); + let trans = self.proof_names().eq_trans_constructor.clone(); + container_proof_bindings.push(format!("(let {proof_var} ({proof_prim} {ci}))")); + container_reflexive_sets.push(format!( + "(set ({cproof} {rebuilt_var}) ({trans} ({sym} {proof_var}) {proof_var}))" + )); + uf_proof_vars.push(Some(proof_var)); + } else { + uf_proof_vars.push(None); + } } else { leader_vars.push(child(i)); uf_proof_vars.push(None); @@ -574,7 +652,7 @@ impl<'a> ProofInstrumentor<'a> { let or_expr = format!("(or {})", bool_neq_exprs.join("\n ")); let filter_query = format!("(guard {or_expr})"); - // Build the updated children: use leader_var for eq-sort columns, original for others. + // Build the updated children: use leader_var for rebuildable columns, original for others. let children_updated: Vec = leader_vars.clone(); let fresh_name = self.egraph.parser.symbol_gen.fresh("rebuild_rule"); @@ -583,24 +661,25 @@ impl<'a> ProofInstrumentor<'a> { // Build proof code if proofs are enabled. // We chain congruence proofs for each updated child and a transitivity proof // for the representative (last column) update. - let (pf_code, pf_var) = if self.egraph.proof_state.proofs_enabled { + let (pf_code, pf_var) = if proofs_enabled { let eq_trans_constructor = self.proof_names().eq_trans_constructor.clone(); let congr_constructor = self.proof_names().congr_constructor.clone(); let sym_constructor = self.proof_names().eq_sym_constructor.clone(); - // Start with the view proof and apply congruence for each eq-sort child - // (excluding the last column if this is a constructor, since that's the representative). + // Start with the view proof and apply congruence for each rebuilt child + // (using transitivity instead for the representative column of a constructor). let mut current_proof = view_prf.clone(); let mut proof_code_parts = vec![]; - for (i, ty) in types.iter().enumerate() { - if !ty.is_eq_sort() { + for i in 0..types.len() { + let Some(uf_prf) = uf_proof_vars[i].clone() else { continue; - } - - let uf_prf = uf_proof_vars[i].as_ref().unwrap(); + }; - if fdecl.subtype == FunctionSubtype::Constructor && i == types.len() - 1 { + if types[i].is_eq_sort() + && fdecl.subtype == FunctionSubtype::Constructor + && i == types.len() - 1 + { // Updating the representative term (last column of constructor): // use transitivity with sym of the UF proof let new_proof = self.fresh_var(); @@ -612,7 +691,7 @@ impl<'a> ProofInstrumentor<'a> { )); current_proof = new_proof; } else { - // Updating a child via congruence + // Updating a child (eq-sort or container) via congruence let new_proof = self.fresh_var(); proof_code_parts.push(format!( "(let {new_proof} @@ -629,18 +708,23 @@ impl<'a> ProofInstrumentor<'a> { }; let updated_view = self.update_view(&fdecl.name, &children_updated, &pf_var); + let container_proof_bindings_str = container_proof_bindings.join("\n"); + let container_reflexive_sets_str = container_reflexive_sets.join("\n"); // Make a single rule that updates the view when any child's leader differs. + let naive = if has_container { " :naive" } else { "" }; let rule = format!( "(rule ({query_view} {uf_query_str} {filter_query} ) ( + {container_proof_bindings_str} {pf_code} {updated_view} + {container_reflexive_sets_str} (delete ({view_name} {children})) - ) + ){naive} :ruleset {} :name \"{fresh_name}\" :internal-include-subsumed)", self.proof_names().rebuilding_ruleset_name ); @@ -782,13 +866,34 @@ impl<'a> ProofInstrumentor<'a> { } } ResolvedFact::Eq(_span, left_expr, right_expr) => { - let (v1, p1) = self.instrument_fact_expr(left_expr, res, action_lookups); - let (v2, p2) = self.instrument_fact_expr(right_expr, res, action_lookups); - res.push(format!("(= {v1} {v2})")); - let sym = &self.proof_names().eq_sym_constructor; - let trans = &self.proof_names().eq_trans_constructor; + let is_container_prim = |e: &ResolvedExpr| { + matches!( + e, + ResolvedExpr::Call(_, ResolvedCall::Primitive(p), _) + if p.output().is_eq_container_sort() + ) + }; + // A container side condition: a fact that builds a container with + // a primitive (`(= xs (vec-of e))`, `(= (set-of a) (set-of b))`). + // The container has no carryable proof — emit just the `Eval` + // marker and the query bindings; the checker re-evaluates the side + // condition (see `check_side_condition`). + if is_container_prim(left_expr) || is_container_prim(right_expr) { + // A container side condition: emit the fact as-is so the + // e-graph computes the container (its arguments are already + // bound). Its proof is the `Eval` marker, checked by + // re-evaluation (see `check_side_condition`). + res.push(fact.to_string()); + format!("({})", self.proof_names().eval_constructor) + } else { + let (v1, p1) = self.instrument_fact_expr(left_expr, res, action_lookups); + let (v2, p2) = self.instrument_fact_expr(right_expr, res, action_lookups); + res.push(format!("(= {v1} {v2})")); + let sym = &self.proof_names().eq_sym_constructor; + let trans = &self.proof_names().eq_trans_constructor; - format!("({trans} ({sym} {p1}) {p2})",) + format!("({trans} ({sym} {p1}) {p2})",) + } } ResolvedFact::Fact(generic_expr) => { let (_, proof) = self.instrument_fact_expr(generic_expr, res, action_lookups); @@ -917,9 +1022,17 @@ impl<'a> ProofInstrumentor<'a> { let proof = if !self.proofs_enabled() { "()".to_string() - } else if specialized_primitive.output().is_eq_sort() - || specialized_primitive.output().is_eq_container_sort() - { + } else if specialized_primitive.output().is_eq_container_sort() { + // A container computed in the query/rule body has no + // carryable proof. It only ever appears in a container + // side condition, whose proof is the `Eval` marker + // emitted at the fact level (see `instrument_fact`); + // this per-expression proof is unused. + "()".to_string() + } else if specialized_primitive.output().is_eq_sort() { + // An eq-sort (datatype) result is an existing anchored + // term (e.g. an identity primitive returning its + // input); reuse its term-proof, fetched in the action. let term_proof_name = self.term_proof_name(specialized_primitive.output().name()); let fresh_proof = self.fresh_var(); @@ -927,6 +1040,8 @@ impl<'a> ProofInstrumentor<'a> { .push(format!("(let {fresh_proof} ({term_proof_name} {fv}))")); fresh_proof } else { + // Base primitives produce a literal result; a + // reflexive `Fiat` over a literal is checker-valid. let fiat_constructor = &self.proof_names().fiat_constructor; let to_ast = self .proof_names() @@ -1029,6 +1144,33 @@ impl<'a> ProofInstrumentor<'a> { res } + /// Build the proof term that justifies a freshly-created term `fv` + /// (wrapped by the AST constructor `to_ast`) proving `fv = fv`, from the + /// surrounding [`Justification`]. Shared by constructor creation + /// (`add_term_and_view`) and container creation. + fn term_proof_for_justification( + &self, + fv: &str, + to_ast: &str, + justification: &Justification, + ) -> String { + let rule_constructor = &self.proof_names().rule_constructor; + let fiat_constructor = &self.proof_names().fiat_constructor; + match justification { + Justification::Rule(rule_name, rule_proof) => format!( + "({rule_constructor} \"{rule_name}\" {rule_proof} ({to_ast} {fv}) ({to_ast} {fv}))" + ), + Justification::Fiat => { + format!("({fiat_constructor} ({to_ast} {fv}) ({to_ast} {fv}))") + } + Justification::Merge(fn_name, p1, p2) => { + let merge_constructor = &self.proof_names().merge_fn_constructor; + format!("({merge_constructor} \"{fn_name}\" {p1} {p2} ({to_ast} {fv}))") + } + Justification::Proof(existing_proof) => existing_proof.clone(), + } + } + /// Update the view with the given arguments. /// The arguments include the eclass for constructors. /// View is always a function (returning Proof or Unit). @@ -1180,8 +1322,28 @@ impl<'a> ProofInstrumentor<'a> { "(let {} ({} {}))", fv, specialized_primitive.name(), - ListDisplay(args, " ") + ListDisplay(&args, " ") )); + // In proof mode, a primitive that builds a container + // value records a reflexive term-proof in `Proof`. + // This is the anchor for the container's rebuild + // congruence proofs (see `rebuilding_rules`). + if self.egraph.proof_state.proofs_enabled { + let out = specialized_primitive.output(); + if out.is_eq_container_sort() { + let csort = out.name().to_string(); + let to_ast = self + .proof_names() + .sort_to_ast_constructor + .get(&csort) + .unwrap() + .clone(); + let proof_str = + self.term_proof_for_justification(&fv, &to_ast, proof); + let cproof = self.term_proof_name(&csort); + res.push(format!("(set ({cproof} {fv}) {proof_str})")); + } + } fv } } @@ -1331,21 +1493,61 @@ impl<'a> ProofInstrumentor<'a> { unionable, .. } => { - let uf_name = self.uf_name(name); + // After the proof-encoding gate, any sort carrying a presort + // is one of the supported container sorts. Containers have no + // per-sort union-find (they are canonicalized structurally), + // so they get `uf: None` and `find_canonical` leaves their + // value unchanged during extraction. + let is_container = presort_and_args.is_some(); + let uf_name = if is_container { + None + } else { + // Carry both UF table names (constructor + function-index) so + // they round-trip; the index lets container rebuild recover + // its element UF lookups without a per-container list. + Some((self.uf_name(name), Some(self.uf_function_name(name)))) + }; + // Every sort (containers included) records its `Proof` + // table via `:internal-proof-func` so container rebuild can + // recover the per-container proof tables without a per-container + // list. (The table itself is declared in `declare_sort`.) let proof_func = if self.egraph.proof_state.proofs_enabled { Some(self.term_proof_name(name)) } else { None }; + // For container sorts, build the rebuild-primitive spec now (it + // generates and caches the fresh primitive names used by the + // rebuild rules below) and attach it as an annotation so the + // primitives can be re-registered when this desugared Sort + // command is typechecked / re-parsed. + let container_rebuild = if is_container { + let container_sort = self + .egraph + .proof_state + .original_typechecking + .as_ref() + .and_then(|tc| tc.get_sort_by_name(name).cloned()) + .unwrap_or_else(|| { + panic!("container sort {name} not found while term-encoding") + }); + Some(self.build_container_rebuild_spec(&container_sort)) + } else { + None + }; res.push(Command::Sort { span: span.clone(), name: name.clone(), presort_and_args: presort_and_args.clone(), - uf: Some(uf_name), + uf: uf_name, proof_func, unionable: *unionable, + container_rebuild, + // The Proof sort (which carries :internal-proof-names) is + // emitted as source by the proof header, not here. + proof_constructors: None, }); - res.extend(self.declare_sort(name)); + res.extend(self.declare_sort(name, is_container)); } ResolvedNCommand::Function(fdecl) => { res.extend(self.term_and_view(fdecl)); @@ -1459,4 +1661,67 @@ impl<'a> ProofInstrumentor<'a> { res } + + /// Build the [`ContainerRebuildSpec`] for a container sort: mint and cache + /// the fresh rebuild-primitive names. The primitives themselves are + /// registered from the spec when the Sort is typechecked (see + /// [`crate::proofs::proof_container_rebuild::register_container_rebuild_from_spec`]). + fn build_container_rebuild_spec(&mut self, container_sort: &ArcSort) -> ContainerRebuildSpec { + let sort_name = container_sort.name().to_string(); + let proof_mode = self.egraph.proof_state.proofs_enabled; + + let internal_rebuild_prim = self.egraph.parser.symbol_gen.fresh("container_rebuild"); + self.egraph + .proof_state + .container_rebuild_name + .insert(sort_name.clone(), internal_rebuild_prim.clone()); + + let internal_rebuild_proof_prim = proof_mode.then(|| { + let proof_prim = self + .egraph + .parser + .symbol_gen + .fresh("container_rebuild_proof"); + self.egraph + .proof_state + .container_rebuild_proof_name + .insert(sort_name, proof_prim.clone()); + proof_prim + }); + + ContainerRebuildSpec { + internal_rebuild_prim, + internal_rebuild_proof_prim, + } + } + + /// The (already-built) container value-rebuild primitive name for a sort. + fn ensure_container_rebuild(&mut self, container_sort: &ArcSort) -> String { + self.egraph + .proof_state + .container_rebuild_name + .get(container_sort.name()) + .cloned() + .unwrap_or_else(|| { + panic!( + "container rebuild primitive not built for sort {}", + container_sort.name() + ) + }) + } + + /// The (already-built) container proof-rebuild primitive name for a sort. + fn ensure_container_rebuild_proof(&mut self, container_sort: &ArcSort) -> String { + self.egraph + .proof_state + .container_rebuild_proof_name + .get(container_sort.name()) + .cloned() + .unwrap_or_else(|| { + panic!( + "container rebuild proof primitive not built for sort {}", + container_sort.name() + ) + }) + } } diff --git a/egglog/src/proofs/proof_encoding_helpers.rs b/egglog/src/proofs/proof_encoding_helpers.rs index 778476c..e9835c5 100644 --- a/egglog/src/proofs/proof_encoding_helpers.rs +++ b/egglog/src/proofs/proof_encoding_helpers.rs @@ -28,6 +28,8 @@ pub(crate) struct EncodingNames { pub(crate) eq_trans_constructor: String, pub(crate) eq_sym_constructor: String, pub(crate) congr_constructor: String, + pub(crate) container_normalize_constructor: String, + pub(crate) eval_constructor: String, /// For a given function symbol, the name of the function that converts to the AST type. pub(crate) sort_to_ast_constructor: HashMap, pub(crate) fn_to_term_sort: HashMap, @@ -69,6 +71,8 @@ impl EncodingNames { eq_trans_constructor: symbol_gen.fresh("Trans"), eq_sym_constructor: symbol_gen.fresh("Sym"), congr_constructor: symbol_gen.fresh("Congr"), + container_normalize_constructor: symbol_gen.fresh("ContainerNormalize"), + eval_constructor: symbol_gen.fresh("Eval"), sort_to_ast_constructor: HashMap::default(), fn_to_term_sort: HashMap::default(), single_parent_ruleset_name: symbol_gen.fresh("single_parent"), @@ -364,6 +368,8 @@ impl ProofInstrumentor<'_> { ref eq_trans_constructor, ref eq_sym_constructor, ref congr_constructor, + ref container_normalize_constructor, + ref eval_constructor, ref pcons, ref pnil, .. @@ -373,7 +379,9 @@ impl ProofInstrumentor<'_> { " (sort {proof_list_sort}) (sort {ast_sort}) ;; wrap sorts in this for proofs -(sort {proof_datatype}) +;; The proof datatype records the global proof constructor names so container +;; rebuild can recover them on re-parse (see ContainerRebuildSpec). +(sort {proof_datatype} :internal-proof-names {congr_constructor} {eq_trans_constructor} {eq_sym_constructor} {container_normalize_constructor}) (constructor {pcons} ({proof_datatype} {proof_list_sort}) {proof_list_sort} :internal-hidden) (constructor {pnil} () {proof_list_sort} :internal-hidden) @@ -399,6 +407,15 @@ impl ProofInstrumentor<'_> { ;; and a proof that ci = c2, ;; produces a justification that t1 = f(..., c2, ...) (constructor {congr_constructor} ({proof_datatype} i64 {proof_datatype}) {proof_datatype} :internal-hidden) + +;; given a proof that t1 = c, where c is a container term, produces a proof that +;; t1 = normalize(c) (the container's canonicalization: sort/dedup for sets, +;; last-write-wins for maps, sort for multisets) +(constructor {container_normalize_constructor} ({proof_datatype}) {proof_datatype} :internal-hidden) + +;; marks the proof of a container side condition. Carries nothing: the side +;; condition is re-evaluated against the rule body when checked. +(constructor {eval_constructor} () {proof_datatype} :internal-hidden) " ) } @@ -435,6 +452,10 @@ pub enum ProofEncodingUnsupportedReason { "action contains a function lookup. Finding the output of a function is only supported in queries." )] FunctionLookupInAction, + #[error( + "a container constructed in the query (a container-producing primitive result) is used in the actions. A query-built container is a side condition with no carryable proof, so it cannot be carried into an action." + )] + ContainerCreatedInQueryUsedInAction, #[error( "sort has a presort (custom sort container implementation). Custom sorts are not supported by proof encoding." )] @@ -541,7 +562,6 @@ pub(crate) fn command_supports_proof_encoding( { return Err(ProofEncodingUnsupportedReason::NaiveEqSortPrimitiveFact); } - // Check all expressions for primitives without validators let mut all_primitives_have_validators = true; command.clone().visit_exprs(&mut |expr| { @@ -568,12 +588,57 @@ pub(crate) fn command_supports_proof_encoding( return Err(ProofEncodingUnsupportedReason::FunctionLookupInAction); } + // A container built by a primitive in the query is a side condition with no + // carryable proof, so it can't be used in an action. Reject a rule that binds + // such a container to a variable used in its actions. + if let GenericCommand::Rule { rule } = command { + let mut constructed: Vec = Vec::new(); + for fact in &rule.body { + if let ResolvedFact::Eq(_, lhs, rhs) = fact { + for (var_side, call_side) in [(lhs, rhs), (rhs, lhs)] { + if let ResolvedExpr::Var(_, v) = var_side + && let ResolvedExpr::Call(_, ResolvedCall::Primitive(prim), _) = call_side + && prim.output().is_eq_container_sort() + { + constructed.push(v.name.clone()); + } + } + } + } + if !constructed.is_empty() { + let mut used_in_action = false; + for action in &rule.head.0 { + action.clone().visit_exprs(&mut |expr| { + expr.walk( + &mut |e| { + if let ResolvedExpr::Var(_, v) = e + && constructed.contains(&v.name) + { + used_in_action = true; + } + }, + &mut |_| {}, + ); + expr + }); + } + if used_in_action { + return Err(ProofEncodingUnsupportedReason::ContainerCreatedInQueryUsedInAction); + } + } + } + // Now check command-specific constraints match command { GenericCommand::Sort { + name, presort_and_args: Some(_), .. - } => Err(ProofEncodingUnsupportedReason::SortWithPresort), + } => type_info + .get_sort_by_name(name) + .filter(|sort| sort.is_container_sort()) + .map(|_| ()) + .ok_or(ProofEncodingUnsupportedReason::SortWithPresort), GenericCommand::Sort { uf: Some(_), .. } => { Err(ProofEncodingUnsupportedReason::SortWithUfAnnotation) } diff --git a/egglog/src/proofs/proof_extraction.rs b/egglog/src/proofs/proof_extraction.rs index c05c9c2..d885107 100644 --- a/egglog/src/proofs/proof_extraction.rs +++ b/egglog/src/proofs/proof_extraction.rs @@ -94,11 +94,19 @@ impl ProofInstrumentor<'_> { panic!("failed to extract proof term for constructor {}", func.name) }); + let container_normalizers = self + .egraph + .type_info + .sorts + .values() + .filter_map(|sort| sort.rebuild_container_normalizer()) + .collect(); let (mut proof_store, proof_id) = proof_store_from_term( &self.egraph.proof_state.proof_names, termdag, proof_term_id, &self.egraph.proof_check_program, + container_normalizers, ); // Remove globals from the proof diff --git a/egglog/src/proofs/proof_format.rs b/egglog/src/proofs/proof_format.rs index 027e2df..9861de4 100644 --- a/egglog/src/proofs/proof_format.rs +++ b/egglog/src/proofs/proof_format.rs @@ -2,7 +2,7 @@ use crate::{ ResolvedCall, Term, TermDag, TermId, ast::{FunctionSubtype, ResolvedExpr, ResolvedFact, ResolvedNCommand}, proofs::{proof_checker::gather_globals, proof_encoding_helpers::EncodingNames}, - typechecking::FuncType, + typechecking::{FuncType, PrimitiveValidator}, util::{HEntry, HashMap, IndexSet, SymbolGen}, }; use egglog_ast::generic_ast::Literal; @@ -25,6 +25,9 @@ impl fmt::Display for ProofId { /// A proof straight from the e-graph, not exposed to users. struct RawProofStore { term_dag: TermDag, + /// The proof constructor names, used to recognize each extracted proof + /// term's head by exact match (rather than substring guessing). + names: EncodingNames, /// Bidirectional map between proof terms and their ids. store: IndexSet, term_to_proof: HashMap, @@ -36,10 +39,11 @@ pub(crate) fn proof_store_from_term( term_dag: TermDag, proof_term: TermId, prog: &Vec, + container_normalizers: HashMap, ) -> (ProofStore, ProofId) { let (raw_store, raw_proof_id) = RawProofStore::from_extracted(encoding_names, term_dag, proof_term); - ProofStore::from_raw(prog, raw_store, raw_proof_id) + ProofStore::from_raw(prog, raw_store, raw_proof_id, container_normalizers) } /// Justifies a single grounded equality t1 = t2. @@ -65,16 +69,43 @@ enum RawProof { /// and a proof that ci = c2, /// produces a justification that t1 = f(..., c2, ...) Congr(RawProofId, usize, RawProofId), + /// Given a proof that `t1 = c` for a container term `c`, produces a proof of + /// `t1 = normalize(c)` — the container's canonicalization (reorder/dedup/ + /// merge), which a structural `Congr` chain can't express. + ContainerNormalize(RawProofId), + /// Marks the proof of a container side condition (a container-producing + /// primitive applied in a rule body). It carries nothing: the side condition + /// is re-evaluated against the rule body when checked (see + /// `check_side_condition`), so the proof needs no term. + Eval, } /// A [`ProofStore`] is similar to a [`TermDag`]. /// It's a hash-consed arena enabling proofs to share sub-proofs. /// We refer to proofs with a [`ProofId`] which is an index into the store, used with [`ProofStore::get`] to retrieve the proof. -#[derive(Clone, Debug)] +#[derive(Clone)] pub struct ProofStore { pub(super) term_dag: TermDag, proof_id: HashMap, pub(super) id_to_proof: DenseIdMap, + /// Container constructor head -> its validator (the container's term + /// normalizer), used by [`ProofStore::normalize_container`]. + container_normalizers: HashMap, +} + +impl fmt::Debug for ProofStore { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + // `container_normalizers` holds closures (not `Debug`); show its heads. + f.debug_struct("ProofStore") + .field("term_dag", &self.term_dag) + .field("proof_id", &self.proof_id) + .field("id_to_proof", &self.id_to_proof) + .field( + "container_normalizers", + &self.container_normalizers.keys().collect::>(), + ) + .finish() + } } /// In egglog, all proofs prove a [`Proposition`], which is an equality between two terms. @@ -168,17 +199,29 @@ pub enum Justification { child_index: usize, child_proof: ProofId, }, + /// Given a `proof` of `t1 = c` for a container term `c`, proves + /// `t1 = normalize(c)` — the container's canonicalization (sort by + /// [`TermDag::ast_cmp`]; dedup for sets; last-write-wins for maps). Sound by + /// the assumption that normalization preserves the container's value; the + /// checker recomputes it. + ContainerNormalize { proof: ProofId }, + /// Marks the proof of a container side condition. It proves nothing on its + /// own; the side condition is re-evaluated against the rule body when the + /// rule is checked (see `check_side_condition`), which is what establishes + /// the container's value. The `Proof`'s proposition is a placeholder. + Eval, } impl RawProofStore { /// After extracting a proof from the e-graph, convert it to a [`RawProof`]. pub(crate) fn from_extracted( - _encoding_names: &EncodingNames, + encoding_names: &EncodingNames, term_dag: TermDag, term: TermId, ) -> (Self, RawProofId) { let mut store = RawProofStore { term_dag: term_dag.clone(), + names: encoding_names.clone(), store: IndexSet::default(), term_to_proof: HashMap::default(), proof_to_term: HashMap::default(), @@ -206,36 +249,46 @@ impl RawProofStore { ); }; - let proof = if head.contains("Fiat") { + let proof = if head == self.names.fiat_constructor { assert!(args.len() == 2, "fiat constructor should have 2 args"); RawProof::Fiat(args[0], args[1]) - } else if head.contains("Rule") { + } else if head == self.names.rule_constructor { assert!(args.len() == 4, "rule constructor should have 4 args"); let name = self.parse_string(args[0]); let premises = self.parse_proof_list(args[1]); RawProof::Rule(name, premises, args[2], args[3]) - } else if head.contains("Merge") { + } else if head == self.names.merge_fn_constructor { assert!(args.len() == 4, "merge constructor should have 4 args"); let function = self.parse_string(args[0]); let old_proof = self.parse_proof(args[1]); let new_proof = self.parse_proof(args[2]); let term = args[3]; RawProof::MergeFn(function, old_proof, new_proof, term) - } else if head.contains("Trans") { + } else if head == self.names.eq_trans_constructor { assert!(args.len() == 2, "trans constructor should have 2 args"); let left = self.parse_proof(args[0]); let right = self.parse_proof(args[1]); RawProof::Trans(left, right) - } else if head.contains("Sym") { + } else if head == self.names.eq_sym_constructor { assert!(args.len() == 1, "sym constructor should have 1 arg"); let inner = self.parse_proof(args[0]); RawProof::Sym(inner) - } else if head.contains("Congr") { + } else if head == self.names.container_normalize_constructor { + assert!( + args.len() == 1, + "container-normalize constructor should have 1 arg" + ); + let inner = self.parse_proof(args[0]); + RawProof::ContainerNormalize(inner) + } else if head == self.names.congr_constructor { assert!(args.len() == 3, "congr constructor should have 3 args"); let proof = self.parse_proof(args[0]); let child_index = self.parse_index(args[1]); let child_proof = self.parse_proof(args[2]); RawProof::Congr(proof, child_index, child_proof) + } else if head == self.names.eval_constructor { + assert!(args.is_empty(), "eval constructor should have no args"); + RawProof::Eval } else { panic!("Unrecognized proof term head: {head}. Proof parsing assumes valid proofs."); }; @@ -247,10 +300,10 @@ impl RawProofStore { let term = self.term_dag.get(list_term).clone(); match term { Term::App(head, args) => { - if head.contains("PNil") { + if head == self.names.pnil { assert!(args.is_empty(), "pnil should not have arguments"); Vec::new() - } else if head.contains("PCons") { + } else if head == self.names.pcons { assert!(args.len() == 2, "pcons should have 2 arguments"); let head_proof = self.parse_proof(args[0]); let rest = self.parse_proof_list(args[1]); @@ -316,6 +369,19 @@ impl ProofStore { &self.term_dag } + /// Recompute a container term's canonical form by applying the constructor + /// validator registered for its head (the container's own term normalizer). + /// Non-container terms, and heads with no validator, are returned unchanged. + pub(super) fn normalize_container(&mut self, term_id: TermId) -> TermId { + let Term::App(head, args) = self.term_dag.get(term_id).clone() else { + return term_id; + }; + let Some(validator) = self.container_normalizers.get(&head).cloned() else { + return term_id; + }; + validator(&mut self.term_dag, &args).unwrap_or(term_id) + } + /// Get the [`Proof`] with the given id. /// Panics if the id is invalid (if it came from another proof store, for example). pub fn get(&self, proof_id: ProofId) -> &Proof { @@ -338,11 +404,13 @@ impl ProofStore { prog: &Vec, raw_store: RawProofStore, raw_proof_id: RawProofId, + container_normalizers: HashMap, ) -> (ProofStore, ProofId) { let mut store = ProofStore { term_dag: raw_store.term_dag.clone(), proof_id: HashMap::default(), id_to_proof: DenseIdMap::new(), + container_normalizers, }; let globals = gather_globals(prog, &mut store.term_dag) .unwrap_or_else(|_| panic!("failed to gather globals from program")); @@ -451,6 +519,26 @@ impl ProofStore { }, } } + RawProof::ContainerNormalize(inner_raw) => { + let inner_id = self.convert_raw_proof(prog, globals, raw_store, *inner_raw); + let inner_lhs = self.id_to_proof[inner_id].lhs(); + let inner_rhs = self.id_to_proof[inner_id].rhs(); + let normalized = self.normalize_container(inner_rhs); + Proof { + proposition: Proposition::new(inner_lhs, normalized), + justification: Justification::ContainerNormalize { proof: inner_id }, + } + } + RawProof::Eval => { + // The marker proves nothing on its own; `check_side_condition` + // re-evaluates the side condition against the rule body. Give it + // a placeholder proposition (the `Proof` struct requires one). + let placeholder = self.term_dag.app("@side-condition".to_string(), vec![]); + Proof { + proposition: Proposition::new(placeholder, placeholder), + justification: Justification::Eval, + } + } }; let proof_id = self.id_to_proof.push(proof); @@ -487,6 +575,12 @@ impl ProofStore { let mut current_subst = substitution; for (fact, proof_id) in rule.body.iter().zip(premise_proofs.iter()) { + // Container side conditions carry only an `Eval` marker (no value); + // their bindings are generated by `check_side_condition` at check + // time, so there is nothing to unify here. + if crate::proofs::proof_checker::is_container_side_condition(fact) { + continue; + } self.unify_fact(fact, *proof_id, &mut current_subst); } @@ -657,7 +751,8 @@ impl ProofStore { dag.to_string_with_let_internal(symbol_gen, proof_term_id, buffer, |constructor| { match constructor { "=" => "prop".to_string(), - "Fiat" | "Rule" | "Merge" | "Trans" | "Sym" | "Congr" => "prf".to_string(), + "Fiat" | "Rule" | "Merge" | "Trans" | "Sym" | "Congr" | "ContainerNormalize" + | "Eval" => "prf".to_string(), _ => "t".to_string(), } }) @@ -753,6 +848,15 @@ impl ProofStore { vec![equality, base_term_id, child_term_id, index_term], ) } + Justification::ContainerNormalize { proof: inner } => { + let equality = make_equality(dag, proof.lhs(), proof.rhs()); + let inner_term_id = self.proof_to_term_for_printing(dag, *inner, cache); + dag.app( + "ContainerNormalize".to_string(), + vec![equality, inner_term_id], + ) + } + Justification::Eval => dag.app("Eval".to_string(), vec![]), }; cache.insert(proof_id, term_id); diff --git a/egglog/src/proofs/proof_normal_form.rs b/egglog/src/proofs/proof_normal_form.rs index 7955468..39a8f9c 100644 --- a/egglog/src/proofs/proof_normal_form.rs +++ b/egglog/src/proofs/proof_normal_form.rs @@ -3,15 +3,20 @@ use crate::*; use crate::{core::ResolvedCall, typechecking::FuncType}; use egglog_ast::generic_ast::GenericExpr; -/// Transforms queries so that they are in "proof normal form" by lifting subexpressions out, making them top level. In proof normal form: -/// 1. Function calls like (lower-bound a b) are always top level and look like this: -/// (= (lower-bound a b) c) -/// 2. Primitives can't have constructors or function calls as arguments. -/// For example, (!= a (Const 0)) becomes: -/// (= (Const 0) v), (!= a v) +/// Transforms queries into "proof normal form" by lifting subexpressions to the +/// top level, so that every primitive is applied only to variables, literals, or +/// other primitives. This is what lets the proof checker re-evaluate a primitive +/// directly (see `check_side_condition`) instead of needing a proof for each of a +/// primitive's arguments — the arguments are already bound elsewhere. /// -/// Nested function calls like this are flattened: -/// (Add c (lower-bound a b)) +/// 1. A custom function call becomes its own top-level fact: +/// `(= (lower-bound a b) c)`. +/// 2. A constructor or function argument of a primitive is lifted to a fresh +/// variable: `(!= a (Const 0))` becomes `(= (Const 0) v)`, `(!= a v)`. +/// 3. A container-producing primitive is lifted out of any constructor into its +/// own side condition: `(WrapVec (vec-of e))` becomes `(= (vec-of e) v)`, +/// `(WrapVec v)`. Its proof is a contentless marker, which can't ride a +/// congruence step under the constructor. pub(crate) fn proof_form( prog: Vec, fresh: &mut SymbolGen, @@ -170,10 +175,40 @@ fn proof_form_expr( ResolvedExpr::Call(span, head, new_args) } ResolvedExpr::Call(span, head, args) => { - let new_args = args - .into_iter() - .map(|expr| proof_form_expr(expr, res, fresh)) - .collect(); + // `head` is a constructor here (custom functions and primitives are + // matched above). A container-producing primitive can't sit under a + // constructor in proof normal form — it has no anchored proof and + // can't ride a congruence step — so lift such an argument into its + // own side-condition binding `(= (prim ...) v)` and pass `v`. + let mut new_args = vec![]; + for arg in args { + let normalized = proof_form_expr(arg, res, fresh); + let lift = matches!( + &normalized, + ResolvedExpr::Call(_, ResolvedCall::Primitive(p), _) + if p.output().is_eq_container_sort() + ); + if lift { + let (arg_span, sort) = match &normalized { + ResolvedExpr::Call(s, ResolvedCall::Primitive(p), _) => { + (s.clone(), p.output().clone()) + } + _ => unreachable!(), + }; + let fresh_var = GenericExpr::Var( + arg_span.clone(), + ResolvedVar { + name: fresh.fresh("v"), + sort, + is_global_ref: false, + }, + ); + res.push(ResolvedFact::Eq(arg_span, normalized, fresh_var.clone())); + new_args.push(fresh_var); + } else { + new_args.push(normalized); + } + } ResolvedExpr::Call(span, head, new_args) } ResolvedExpr::Lit(..) | ResolvedExpr::Var(..) => fact, diff --git a/egglog/src/proofs/proof_simplification.rs b/egglog/src/proofs/proof_simplification.rs index 551bd9a..b7086b4 100644 --- a/egglog/src/proofs/proof_simplification.rs +++ b/egglog/src/proofs/proof_simplification.rs @@ -74,6 +74,10 @@ impl ProofStore { /// - Collapse double symmetry: Sym(Sym(p)) -> p /// - Push symmetry through transitivity: Sym(Trans(p1, p2)) -> Trans(Sym(p2), Sym(p1)) /// This enables further simplifications by exposing the inner proofs + /// - Remove redundant container normalization: ContainerNormalize(p) -> p when the + /// normalization left the term unchanged (always the case for + /// order/arity-preserving containers like Vec/Pair, which mint the normalization + /// unconditionally, and for already-canonical sets/maps/multisets) pub fn simplify(&mut self, proof_id: ProofId) -> ProofId { // First, recursively simplify all child proofs let proof_id = self.map_child_proofs(proof_id, |store, pid| store.simplify(pid)); @@ -104,6 +108,7 @@ impl ProofStore { Self::opt_reflexive_sym, Self::opt_double_sym, Self::opt_sym_trans, + Self::opt_redundant_container_normalize, ]; for opt in optimizations { @@ -132,6 +137,19 @@ impl ProofStore { None } + /// Optimization: Remove a redundant container normalization. + /// ContainerNormalize(p) -> p when normalization left the term unchanged + /// (its rhs equals the inner proof's rhs). + fn opt_redundant_container_normalize(&mut self, proof_id: ProofId) -> Option { + let proof = self.get(proof_id); + if let Justification::ContainerNormalize { proof: inner } = proof.justification() + && proof.rhs() == self.get(*inner).rhs() + { + return Some(*inner); + } + None + } + /// Optimization: Remove reflexive transitivity /// Trans(refl, p) -> p and Trans(p, refl) -> p fn opt_reflexive_trans(&mut self, proof_id: ProofId) -> Option { @@ -309,6 +327,21 @@ impl ProofStore { changed = true; } } + Justification::ContainerNormalize { proof: inner } => { + let mapped_inner = f(self, *inner); + if mapped_inner != *inner { + *inner = mapped_inner; + let (inner_lhs, inner_rhs) = { + let p = self.get(*inner); + (p.lhs(), p.rhs()) + }; + proof.proposition.lhs = inner_lhs; + proof.proposition.rhs = self.normalize_container(inner_rhs); + changed = true; + } + } + // No sub-proofs to remap; the result lives in the proposition. + Justification::Eval => return proof_id, } if !changed { @@ -350,6 +383,9 @@ impl Proof { } => {} Justification::Trans(_, _) => {} Justification::Sym(_) => {} + Justification::ContainerNormalize { proof: _ } => {} + // The only term (the result) lives in the proposition, already mapped. + Justification::Eval => {} } } } diff --git a/egglog/src/proofs/proof_tests.rs b/egglog/src/proofs/proof_tests.rs index 2fd2673..3103ffe 100644 --- a/egglog/src/proofs/proof_tests.rs +++ b/egglog/src/proofs/proof_tests.rs @@ -2,8 +2,8 @@ mod tests { use crate::ast::{ResolvedCommand, RuleEvalMode, sanitize_internal_names}; use crate::{ - ArcSort, CommandOutput, EGraph, Error, ProofEncodingUnsupportedReason, Sort, TermDag, - TermId, Value, add_primitive_with_validator, + CommandOutput, EGraph, Error, ProofEncodingUnsupportedReason, TermDag, TermId, + add_primitive_with_validator, }; fn term_encode(source: &str) -> Vec { @@ -178,80 +178,28 @@ mod tests { ); } - #[derive(Debug)] - struct EqContainerTestSort { - name: String, - } - - impl Sort for EqContainerTestSort { - fn name(&self) -> &str { - &self.name - } - - fn column_ty(&self, _backend: &egglog_bridge::EGraph) -> egglog_bridge::ColumnTy { - egglog_bridge::ColumnTy::Id - } - - fn register_type(&self, _backend: &mut egglog_bridge::EGraph) {} - - fn as_arc_any( - self: std::sync::Arc, - ) -> std::sync::Arc { - self - } - - fn is_eq_container_sort(&self) -> bool { - true - } - - fn value_type(&self) -> Option { - None - } - - fn reconstruct_termdag_base( - &self, - _base_values: &crate::sort::BaseValues, - _value: Value, - termdag: &mut TermDag, - ) -> TermId { - termdag.app("SeedValue".into(), vec![]) - } - } - - fn replace_with_eq_container_test_sort(egraph: &mut EGraph, name: &str) -> ArcSort { - let sort = std::sync::Arc::new(EqContainerTestSort { - name: name.to_string(), - }) as ArcSort; - egraph - .type_info - .sorts - .insert(name.to_string(), sort.clone()); - if let Some(original_typechecking) = egraph.proof_state.original_typechecking.as_mut() { - original_typechecking - .type_info - .sorts - .insert(name.to_string(), sort.clone()); - } - sort - } - #[test] fn proof_mode_allows_eq_container_primitive_results_in_facts() { + // A real (presort-declared) eq-container sort, so the term/proof + // encoding builds its rebuild primitive. A custom identity primitive + // returns an existing eq-container value, exercising the + // eq-container-primitive-result-in-a-fact path under proofs. let mut egraph = EGraph::new_with_proofs(); - egraph .parse_and_run_program( None, r#" - (sort EqContainer) - (constructor SeedValue () EqContainer) + (datatype E (Mk)) + (sort EqContainer (Vec E)) "#, ) .unwrap(); - let eq_container_sort = replace_with_eq_container_test_sort(&mut egraph, "EqContainer"); - assert!(eq_container_sort.is_eq_container_sort()); - + let eq_container_sort = egraph + .type_info + .get_sort_by_name("EqContainer") + .expect("EqContainer sort") + .clone(); let validator = |_: &mut TermDag, args: &[TermId]| -> Option { args.first().copied() }; add_primitive_with_validator!( @@ -275,7 +223,7 @@ mod tests { (relation SeedContainer (EqContainer)) (relation Done ()) - (SeedContainer (SeedValue)) + (SeedContainer (vec-of (Mk))) (rule ((SeedContainer ys) (= xs (proof-container-id ys))) @@ -289,6 +237,69 @@ mod tests { .unwrap(); } + // A container constructed in the query body and not used in an action: the + // binding fact's proof is the container's reflexive `Eval`, which the rule + // check re-derives with the typed primitive. + #[test] + fn proof_mode_query_constructed_container_not_used_in_action() { + let mut egraph = EGraph::new_with_proofs(); + egraph + .parse_and_run_program( + None, + r#" + (datatype E (Mk)) + (sort EqContainer (Vec E)) + (relation SeedElem (E)) + (relation Done ()) + + (SeedElem (Mk)) + + (rule ((SeedElem e) + (= xs (vec-of e))) + ((Done)) + :name "new-container-in-body") + + (run 1) + (prove (Done)) + "#, + ) + .unwrap(); + } + + // A container constructed in the query is a side condition with no carryable + // proof (just an `Eval` marker), so it can't be used in an action. Proof mode + // rejects such a rule rather than producing an unsound proof. + #[test] + fn proof_support_rejects_query_constructed_container_used_in_action() { + let mut egraph = EGraph::new_with_proofs(); + let err = egraph + .parse_and_run_program( + None, + r#" + (datatype E (Mk)) + (sort EqContainer (Vec E)) + (relation SeedElem (E)) + (relation Out (EqContainer)) + + (rule ((SeedElem e) + (= xs (vec-of e))) + ((Out xs)) + :name "new-container-in-action") + "#, + ) + .unwrap_err(); + assert!( + matches!( + err, + Error::UnsupportedProofCommand { + reason: ProofEncodingUnsupportedReason::ContainerCreatedInQueryUsedInAction, + .. + } + ), + "expected ContainerCreatedInQueryUsedInAction, got {err:?}" + ); + } + #[test] fn doc_example_add_function2() { let commands = term_encode( diff --git a/egglog/src/proofs/snapshots/egglog__proofs__proof_tests__tests__doc_example_add_function1.snap b/egglog/src/proofs/snapshots/egglog__proofs__proof_tests__tests__doc_example_add_function1.snap index de728f7..c40d8d2 100644 --- a/egglog/src/proofs/snapshots/egglog__proofs__proof_tests__tests__doc_example_add_function1.snap +++ b/egglog/src/proofs/snapshots/egglog__proofs__proof_tests__tests__doc_example_add_function1.snap @@ -8,24 +8,24 @@ expression: snapshot (ruleset __rebuilding) (ruleset __rebuilding_cleanup) (ruleset __delete_subsume_ruleset) -(sort Math :internal-uf __UF_Math) +(sort Math :internal-uf __UF_Math __UF_Mathf) (function __UF_Math (Math Math) Unit :merge old :unextractable :internal-hidden) (function __UF_Mathf (Math) Math :merge new :unextractable :internal-hidden) -(rule ((__UF_Math a b) - (__UF_Math b c) - (!= b c)) - ((delete (__UF_Math a b)) - (set (__UF_Math a c) ())) +(rule ((__UF_Math __uf_a __uf_b) + (__UF_Math __uf_b __uf_c) + (!= __uf_b __uf_c)) + ((delete (__UF_Math __uf_a __uf_b)) + (set (__UF_Math __uf_a __uf_c) ())) :ruleset __parent :name "__uf_update") -(rule ((__UF_Math a b) - (__UF_Math a c) - (!= b c) - (= (ordering-max b c) b)) - ((delete (__UF_Math a b)) - (set (__UF_Math b c) ())) +(rule ((__UF_Math __uf_a __uf_b) + (__UF_Math __uf_a __uf_c) + (!= __uf_b __uf_c) + (= (ordering-max __uf_b __uf_c) __uf_b)) + ((delete (__UF_Math __uf_a __uf_b)) + (set (__UF_Math __uf_b __uf_c) ())) :ruleset __single_parent :name "singleparent__uf_update") -(rule ((__UF_Math a b)) - ((set (__UF_Mathf a) b)) +(rule ((__UF_Math __uf_a __uf_b)) + ((set (__UF_Mathf __uf_a) __uf_b)) :ruleset __uf_function_index :name "__uf_function_index1") (sort __view) (constructor Add (i64 i64) Math :unextractable :internal-hidden) diff --git a/egglog/src/scheduler.rs b/egglog/src/scheduler.rs index eb5436f..8222c36 100644 --- a/egglog/src/scheduler.rs +++ b/egglog/src/scheduler.rs @@ -351,7 +351,7 @@ impl SchedulerRuleInfo { &egraph.type_info, false, // seminaive query: Pure/Write contexts ); - qrule_builder.query(&rule.body, true); + qrule_builder.query(&rule.body, false); let entries = free_vars .iter() .map(|fv| qrule_builder.entry(&GenericAtomTerm::Var(span!(), fv.clone()))) @@ -478,6 +478,37 @@ mod test { assert_eq!(iter, 12); } + #[test] + fn test_scheduler_does_not_apply_fresh_subsumed_matches() { + let mut egraph = EGraph::default(); + let scheduler_id = egraph.add_scheduler(Box::new(FirstNScheduler { n: 10 })); + let input = r#" + (ruleset analysis) + (ruleset test) + (datatype Math + (Add Math Math) + (Mul Math Math) + (Num i64)) + (relation Hit (i64)) + (let expr (Add (Mul (Num 0) (Num 1)) (Num 2))) + (rewrite (Mul (Num 0) x) (Num 0) :subsume :ruleset analysis) + (rewrite (Add (Num 0) x) x :subsume :ruleset analysis) + (rule ((= e (Add (Mul (Num a) x) (Num b)))) ((Hit a)) :ruleset test :name "hit-subsumed-affine") + (run-schedule (saturate (run analysis))) + "#; + egraph.parse_and_run_program(None, input).unwrap(); + + let report = egraph + .step_rules_with_scheduler(scheduler_id, "test") + .unwrap(); + + assert_eq!(egraph.get_size("Hit"), 0); + assert!( + !report.updated, + "subsumed rows should not be collected as fresh scheduler matches" + ); + } + #[derive(Clone, Default)] struct DelayStopScheduler { can_stop_calls: usize, diff --git a/egglog/src/sort/fn.rs b/egglog/src/sort/fn.rs index e7f3f8e..0f035bf 100644 --- a/egglog/src/sort/fn.rs +++ b/egglog/src/sort/fn.rs @@ -54,7 +54,7 @@ impl Hash for FunctionContainer { } impl ContainerValue for FunctionContainer { - fn rebuild_contents(&mut self, rebuilder: &dyn Rebuilder) -> bool { + fn rebuild_contents(&mut self, rebuilder: &dyn ValueRebuilder) -> bool { let mut changed = false; for (s, old) in &mut self.1 { if s.is_eq_sort() || s.is_eq_container_sort() { diff --git a/egglog/src/sort/map.rs b/egglog/src/sort/map.rs index 37817c2..6d45a34 100644 --- a/egglog/src/sort/map.rs +++ b/egglog/src/sort/map.rs @@ -9,7 +9,7 @@ pub struct MapContainer { } impl ContainerValue for MapContainer { - fn rebuild_contents(&mut self, rebuilder: &dyn Rebuilder) -> bool { + fn rebuild_contents(&mut self, rebuilder: &dyn ValueRebuilder) -> bool { let mut changed = false; if self.do_rebuild_keys { self.data = self @@ -36,6 +36,48 @@ impl ContainerValue for MapContainer { } } +/// The entries of a flat `(map-of k0 v0 ...)` term as a Rust `BTreeMap` in +/// canonical key order, with `MapContainer`'s last-write-wins semantics on +/// duplicate keys; `None` for any other term. +fn map_term_to_btreemap<'a>( + termdag: &'a TermDag, + term_id: TermId, +) -> Option, TermId>> { + match termdag.get(term_id) { + Term::App(head, args) if head == "map-of" => map_of_args_to_btreemap(termdag, args), + _ => None, + } +} + +/// Alternating `[k0, v0, ...]` `map-of` arguments as a `BTreeMap` (see +/// [`map_term_to_btreemap`]); `None` on odd arity. +fn map_of_args_to_btreemap<'a>( + termdag: &'a TermDag, + args: &[TermId], +) -> Option, TermId>> { + if !args.len().is_multiple_of(2) { + return None; + } + Some( + args.chunks_exact(2) + .map(|kv| (termdag.ord_term(kv[0]), kv[1])) + .collect(), + ) +} + +/// Flatten a map back to the `[k0, v0, k1, v1, ...]` argument list of its +/// canonical `(map-of ...)` term (sorted by key order, deduplicated). +fn map_term_args(map: BTreeMap, TermId>) -> Vec { + map.into_iter().flat_map(|(k, v)| [k.id(), v]).collect() +} + +/// Canonicalize alternating `[k0, v0, ...]` arguments to the flat +/// `(map-of ...)` term; `None` on odd arity. +fn normalize_map_term(termdag: &mut TermDag, args: &[TermId]) -> Option { + let flat = map_term_args(map_of_args_to_btreemap(termdag, args)?); + Some(termdag.app("map-of".to_string(), flat)) +} + /// A map from a key type to a value type supporting these primitives: /// - `map-empty` /// - `map-insert` @@ -69,6 +111,7 @@ impl Presort for MapSort { fn reserved_primitives() -> Vec<&'static str> { vec![ "map-empty", + "map-of", "map-insert", "map-get", "map-not-contains", @@ -139,19 +182,75 @@ impl ContainerSort for MapSort { fn register_primitives(&self, eg: &mut EGraph) { let arc = self.clone().to_arcsort(); - add_primitive!(eg, "map-empty" = {self.clone(): MapSort} || -> @MapContainer (arc) { MapContainer { + // The proof "term form" of a map is the flat `(map-of k0 v0 k1 v1 ...)` + // in canonical key order (like `set-of`/`vec-of`), matching + // `reconstruct_termdag`. Each validator round-trips through a Rust + // `BTreeMap` (see `map_term_to_btreemap`), so it evaluates map terms + // with `MapContainer`'s semantics; `None` for a malformed map term + // fails the proof. + let map_empty_validator = |termdag: &mut TermDag, _args: &[TermId]| -> Option { + Some(termdag.app("map-of".into(), vec![])) + }; + let map_insert_validator = |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [map, key, value] = args else { + return None; + }; + let mut map = map_term_to_btreemap(termdag, *map)?; + map.insert(termdag.ord_term(*key), *value); + let flat = map_term_args(map); + Some(termdag.app("map-of".into(), flat)) + }; + let map_get_validator = |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [map, key] = args else { return None }; + map_term_to_btreemap(termdag, *map)? + .get(&termdag.ord_term(*key)) + .copied() + }; + let map_length_validator = |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [map] = args else { return None }; + let len = map_term_to_btreemap(termdag, *map)?.len() as i64; + Some(termdag.lit(Literal::Int(len))) + }; + let map_contains_validator = |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [map, key] = args else { return None }; + let contains = + map_term_to_btreemap(termdag, *map)?.contains_key(&termdag.ord_term(*key)); + contains.then(|| termdag.lit(Literal::Unit)) + }; + let map_not_contains_validator = + |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [map, key] = args else { return None }; + let contains = + map_term_to_btreemap(termdag, *map)?.contains_key(&termdag.ord_term(*key)); + (!contains).then(|| termdag.lit(Literal::Unit)) + }; + + add_primitive_with_validator!(eg, "map-empty" = {self.clone(): MapSort} || -> @MapContainer (arc) { MapContainer { do_rebuild_keys: self.ctx.key.is_eq_sort() || self.ctx.key.is_eq_container_sort(), do_rebuild_vals: self.ctx.value.is_eq_sort() || self.ctx.value.is_eq_container_sort(), data: BTreeMap::new() - } }); + } }, map_empty_validator); + + // `map-of` is the flat constructor used as the canonical term form. It + // takes alternating key/value arguments, so it needs a custom type + // constraint rather than the `add_primitive!` macro. + eg.add_pure_primitive( + MapOf { + name: "map-of".to_string(), + map: arc.clone(), + key: self.key.clone(), + value: self.value.clone(), + }, + Some(std::sync::Arc::new(normalize_map_term)), + ); - add_primitive!(eg, "map-get" = | xs: @MapContainer (arc), x: # (self.key()) | -?> # (self.value()) { xs.data.get(&x).copied() }); - add_primitive!(eg, "map-insert" = |mut xs: @MapContainer (arc), x: # (self.key()), y: # (self.value())| -> @MapContainer (arc) {{ xs.data.insert(x, y); xs }}); + add_primitive_with_validator!(eg, "map-get" = | xs: @MapContainer (arc), x: # (self.key()) | -?> # (self.value()) { xs.data.get(&x).copied() }, map_get_validator); + add_primitive_with_validator!(eg, "map-insert" = |mut xs: @MapContainer (arc), x: # (self.key()), y: # (self.value())| -> @MapContainer (arc) {{ xs.data.insert(x, y); xs }}, map_insert_validator); add_primitive!(eg, "map-remove" = |mut xs: @MapContainer (arc), x: # (self.key()) | -> @MapContainer (arc) {{ xs.data.remove(&x); xs }}); - add_primitive!(eg, "map-length" = |xs: @MapContainer (arc)| -> i64 { xs.data.len() as i64 }); - add_primitive!(eg, "map-contains" = |xs: @MapContainer (arc), x: # (self.key())| -?> () { ( xs.data.contains_key(&x)).then_some(()) }); - add_primitive!(eg, "map-not-contains" = |xs: @MapContainer (arc), x: # (self.key())| -?> () { (!xs.data.contains_key(&x)).then_some(()) }); + add_primitive_with_validator!(eg, "map-length" = |xs: @MapContainer (arc)| -> i64 { xs.data.len() as i64 }, map_length_validator); + add_primitive_with_validator!(eg, "map-contains" = |xs: @MapContainer (arc), x: # (self.key())| -?> () { ( xs.data.contains_key(&x)).then_some(()) }, map_contains_validator); + add_primitive_with_validator!(eg, "map-not-contains" = |xs: @MapContainer (arc), x: # (self.key())| -?> () { (!xs.data.contains_key(&x)).then_some(()) }, map_not_contains_validator); } fn reconstruct_termdag( @@ -161,16 +260,110 @@ impl ContainerSort for MapSort { termdag: &mut TermDag, element_terms: Vec, ) -> TermId { - let mut term = termdag.app("map-empty".into(), vec![]); - - for x in element_terms.chunks(2) { - term = termdag.app("map-insert".into(), vec![term, x[0], x[1]]) - } + // Flat `(map-of k0 v0 k1 v1 ...)` in canonical key order, so proof + // checking can reproduce it from terms alone (and the rebuild proof's + // Congr indices are flat, like `set-of`/`vec-of`). + normalize_map_term(termdag, &element_terms).expect("map elements come in key/value pairs") + } - term + fn rebuild_container_normalizer(&self) -> Option<(String, PrimitiveValidator)> { + Some(("map-of".to_owned(), Arc::new(normalize_map_term))) } fn serialized_name(&self, _container_values: &ContainerValues, _: Value) -> String { - self.name().to_owned() + "map-of".to_owned() + } +} + +/// The flat `map-of` constructor: takes alternating key/value arguments and +/// builds a map. Used as the canonical term form for maps (analogous to +/// `set-of`/`vec-of`). Needs a custom type constraint because its arguments +/// alternate between the key and value sorts. +#[derive(Clone)] +struct MapOf { + name: String, + map: ArcSort, + key: ArcSort, + value: ArcSort, +} + +impl Primitive for MapOf { + fn name(&self) -> &str { + &self.name + } + + fn get_type_constraints(&self, span: &Span) -> Box { + Box::new(MapOfTypeConstraint { + name: self.name.clone(), + key: self.key.clone(), + value: self.value.clone(), + map: self.map.clone(), + span: span.clone(), + }) + } +} + +impl PurePrim for MapOf { + fn apply<'a, 'db>(&self, mut state: PureState<'a, 'db>, args: &[Value]) -> Option { + let mut data = BTreeMap::new(); + for chunk in args.chunks(2) { + if let [k, v] = chunk { + data.insert(*k, *v); + } + } + let mc = MapContainer { + do_rebuild_keys: self.key.is_eq_sort() || self.key.is_eq_container_sort(), + do_rebuild_vals: self.value.is_eq_sort() || self.value.is_eq_container_sort(), + data, + }; + Some(state.register_container(mc)) + } +} + +/// Type constraint for [`MapOf`]: an even number of inputs alternating between +/// the key and value sorts, producing the map sort. +struct MapOfTypeConstraint { + name: String, + key: ArcSort, + value: ArcSort, + map: ArcSort, + span: Span, +} + +impl TypeConstraint for MapOfTypeConstraint { + fn get( + &self, + arguments: &[AtomTerm], + _typeinfo: &TypeInfo, + ) -> Vec>> { + let arity_mismatch = |expected: usize| { + vec![constraint::impossible( + constraint::ImpossibleConstraint::ArityMismatch { + atom: Atom { + span: self.span.clone(), + head: self.name.clone(), + args: arguments.to_vec(), + }, + expected, + }, + )] + }; + let Some((out, inputs)) = arguments.split_last() else { + return arity_mismatch(1); + }; + if inputs.len() % 2 != 0 { + return arity_mismatch(inputs.len() + 2); + } + let mut cs: Vec>> = + vec![constraint::assign(out.clone(), self.map.clone())]; + for (i, arg) in inputs.iter().enumerate() { + let sort = if i % 2 == 0 { + self.key.clone() + } else { + self.value.clone() + }; + cs.push(constraint::assign(arg.clone(), sort)); + } + cs } } diff --git a/egglog/src/sort/mod.rs b/egglog/src/sort/mod.rs index 2dd56d9..1bcc67f 100644 --- a/egglog/src/sort/mod.rs +++ b/egglog/src/sort/mod.rs @@ -8,7 +8,7 @@ use std::{any::Any, sync::Arc}; use crate::core_relations; pub use core_relations::{ - BaseValues, Boxed, ContainerValue, ContainerValues, ExecutionState, Rebuilder, + BaseValues, Boxed, ContainerValue, ContainerValues, ExecutionState, ValueRebuilder, }; pub use egglog_bridge::ColumnTy; @@ -84,6 +84,15 @@ pub trait Sort: Any + Send + Sync + Debug { false } + /// For a container sort that supports proofs: its canonical constructor head + /// and the validator that canonicalizes the term form (e.g. `set-of` sorts + /// and dedups its elements). Proof checking looks this up by head to normalize + /// a container term. `None` (the default) means proofs are unsupported for + /// this container. + fn rebuild_container_normalizer(&self) -> Option<(String, PrimitiveValidator)> { + None + } + /// Return the serialized name of the sort /// /// Only used for container sorts, which cannot be serialized with make_expr so need an explicit name diff --git a/egglog/src/sort/multiset.rs b/egglog/src/sort/multiset.rs index a99d691..e8cb9fa 100644 --- a/egglog/src/sort/multiset.rs +++ b/egglog/src/sort/multiset.rs @@ -9,8 +9,25 @@ pub struct MultiSetContainer { pub data: MultiSet, } +/// Canonical multiset term form `(multiset-of e0 e1 ...)`: elements sorted by +/// [`TermDag::ast_cmp`] with multiplicities kept as repeats, so proof checking +/// can reproduce it from terms. +fn normalize_multiset_term(termdag: &mut TermDag, mut children: Vec) -> TermId { + termdag.sort_terms_by_ast(&mut children); + termdag.app("multiset-of".into(), children) +} + +/// The element terms of a multiset's canonical term form `(multiset-of e0 …)` +/// (multiplicities kept as repeats); `None` for any other term. +fn multiset_term_children(termdag: &TermDag, term: TermId) -> Option> { + match termdag.get(term) { + Term::App(head, children) if head == "multiset-of" => Some(children.clone()), + _ => None, + } +} + impl ContainerValue for MultiSetContainer { - fn rebuild_contents(&mut self, rebuilder: &dyn Rebuilder) -> bool { + fn rebuild_contents(&mut self, rebuilder: &dyn ValueRebuilder) -> bool { // If the contents are an eq-sort then we want to rebuild if self.do_rebuild { let mut xs: Vec<_> = self.data.iter().copied().collect(); @@ -128,10 +145,36 @@ impl ContainerSort for MultiSetSort { fn register_primitives(&self, eg: &mut EGraph) { let arc = self.clone().to_arcsort(); - add_primitive!(eg, "multiset-of" = {self.clone(): MultiSetSort} [xs: # (self.element())] -> @MultiSetContainer (arc) { MultiSetContainer { + // Proof term form of a multiset: `(multiset-of e0 e1 ...)`, matching + // `reconstruct_termdag`. (Count merging for proof checking of + // collapsing multisets is refined in the MultiSet proof stage.) + let multiset_of_validator = |termdag: &mut TermDag, args: &[TermId]| -> Option { + Some(normalize_multiset_term(termdag, args.to_vec())) + }; + let multiset_length_validator = + |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [ms] = args else { return None }; + let len = multiset_term_children(termdag, *ms)?.len() as i64; + Some(termdag.lit(Literal::Int(len))) + }; + let multiset_contains_validator = + |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [ms, value] = args else { return None }; + multiset_term_children(termdag, *ms)? + .contains(value) + .then(|| termdag.lit(Literal::Unit)) + }; + let multiset_not_contains_validator = + |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [ms, value] = args else { return None }; + let contains = multiset_term_children(termdag, *ms)?.contains(value); + (!contains).then(|| termdag.lit(Literal::Unit)) + }; + + add_primitive_with_validator!(eg, "multiset-of" = {self.clone(): MultiSetSort} [xs: # (self.element())] -> @MultiSetContainer (arc) { MultiSetContainer { do_rebuild: self.ctx.is_eq_container_sort(), data: xs.collect() - } }); + } }, multiset_of_validator); add_primitive!(eg, "multiset-single" = {self.clone(): MultiSetSort} |x: # (self.element()), i: i64| -?> @MultiSetContainer (arc) { i.try_into().ok().map(|i| @@ -146,9 +189,9 @@ impl ContainerSort for MultiSetSort { add_primitive!(eg, "multiset-remove-swapped" = |x: # (self.element()), mut xs: @MultiSetContainer (arc)| -?> @MultiSetContainer (arc) { Some(MultiSetContainer { data: xs.data.remove(&x)?, ..xs }) }); add_primitive!(eg, "multiset-subtract" = |mut xs: @MultiSetContainer (arc), other: @MultiSetContainer (arc)| -?> @MultiSetContainer (arc) { Some(MultiSetContainer { data: xs.data.subtract(&other.data)?, ..xs }) }); add_primitive!(eg, "multiset-subtract-swapped" = |other: @MultiSetContainer (arc), mut xs: @MultiSetContainer (arc)| -?> @MultiSetContainer (arc) { Some(MultiSetContainer { data: xs.data.subtract(&other.data)?, ..xs }) }); - add_primitive!(eg, "multiset-length" = |xs: @MultiSetContainer (arc)| -> i64 { xs.data.len() as i64 }); - add_primitive!(eg, "multiset-contains" = |xs: @MultiSetContainer (arc), x: # (self.element())| -?> () { ( xs.data.contains(&x)).then_some(()) }); - add_primitive!(eg, "multiset-not-contains" = |xs: @MultiSetContainer (arc), x: # (self.element())| -?> () { (!xs.data.contains(&x)).then_some(()) }); + add_primitive_with_validator!(eg, "multiset-length" = |xs: @MultiSetContainer (arc)| -> i64 { xs.data.len() as i64 }, multiset_length_validator); + add_primitive_with_validator!(eg, "multiset-contains" = |xs: @MultiSetContainer (arc), x: # (self.element())| -?> () { ( xs.data.contains(&x)).then_some(()) }, multiset_contains_validator); + add_primitive_with_validator!(eg, "multiset-not-contains" = |xs: @MultiSetContainer (arc), x: # (self.element())| -?> () { (!xs.data.contains(&x)).then_some(()) }, multiset_not_contains_validator); add_primitive!(eg, "multiset-contains-swapped" = |x: # (self.element()), xs: @MultiSetContainer (arc)| -?> () { (xs.data.contains(&x)).then_some(()) }); add_primitive!(eg, "multiset-not-contains-swapped" = |x: # (self.element()), xs: @MultiSetContainer (arc)| -?> () { (!xs.data.contains(&x)).then_some(()) }); add_primitive!(eg, "multiset-intersection" = |xs: @MultiSetContainer (arc), ys: @MultiSetContainer (arc)| -> @MultiSetContainer (arc) { MultiSetContainer { data: xs.data.intersection(ys.data), ..xs } }); @@ -214,7 +257,18 @@ impl ContainerSort for MultiSetSort { termdag: &mut TermDag, element_terms: Vec, ) -> TermId { - termdag.app("multiset-of".into(), element_terms) + // Canonical form (sorted by deterministic AST order, multiplicities + // preserved as repeats) so proof checking can reproduce it from terms. + normalize_multiset_term(termdag, element_terms) + } + + fn rebuild_container_normalizer(&self) -> Option<(String, PrimitiveValidator)> { + Some(( + "multiset-of".to_owned(), + Arc::new(|termdag: &mut TermDag, args: &[TermId]| { + Some(normalize_multiset_term(termdag, args.to_vec())) + }), + )) } fn serialized_name(&self, _container_values: &ContainerValues, _: Value) -> String { diff --git a/egglog/src/sort/pair.rs b/egglog/src/sort/pair.rs index a0e13f9..ebd68c1 100644 --- a/egglog/src/sort/pair.rs +++ b/egglog/src/sort/pair.rs @@ -9,7 +9,7 @@ pub struct PairContainer { } impl ContainerValue for PairContainer { - fn rebuild_contents(&mut self, rebuilder: &dyn Rebuilder) -> bool { + fn rebuild_contents(&mut self, rebuilder: &dyn ValueRebuilder) -> bool { let mut changed = false; if self.do_rebuild_first { let new = rebuilder.rebuild_val(self.first); @@ -28,6 +28,27 @@ impl ContainerValue for PairContainer { } } +/// The `(first, second)` children of a `(pair a b)` term; `None` for any +/// other term. +fn pair_term_children(termdag: &TermDag, term: TermId) -> Option<(TermId, TermId)> { + match termdag.get(term) { + Term::App(head, children) if head == "pair" => match children.as_slice() { + [first, second] => Some((*first, *second)), + _ => None, + }, + _ => None, + } +} + +/// Intern the `(pair a b)` term for `args`; `None` unless there are exactly +/// two. The inverse of [`pair_term_children`]. +fn pair_term(termdag: &mut TermDag, args: &[TermId]) -> Option { + if args.len() != 2 { + return None; + } + Some(termdag.app("pair".into(), args.to_vec())) +} + /// A pair of two values supporting these primitives: /// - `pair` /// - `pair-first` @@ -119,17 +140,34 @@ impl ContainerSort for PairSort { fn register_primitives(&self, eg: &mut EGraph) { let arc = self.clone().to_arcsort(); - add_primitive!(eg, "pair" = {self.clone(): PairSort} |x: # (self.first()), y: # (self.second())| -> @PairContainer (arc) { + // The proof "term form" of a pair: an s-expr `(pair a b)` headed by + // the constructing primitive, matching `reconstruct_termdag`. The + // validator lets the proof checker evaluate `pair` applications, and + // `pair-first`/`pair-second` extract a child of a `(pair a b)` term. + let pair_first_validator = |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [pair] = args else { + return None; + }; + pair_term_children(termdag, *pair).map(|(first, _)| first) + }; + let pair_second_validator = |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [pair] = args else { + return None; + }; + pair_term_children(termdag, *pair).map(|(_, second)| second) + }; + + add_primitive_with_validator!(eg, "pair" = {self.clone(): PairSort} |x: # (self.first()), y: # (self.second())| -> @PairContainer (arc) { PairContainer { do_rebuild_first: self.ctx.first.is_eq_sort() || self.ctx.first.is_eq_container_sort(), do_rebuild_second: self.ctx.second.is_eq_sort() || self.ctx.second.is_eq_container_sort(), first: x, second: y, } - }); + }, pair_term); - add_primitive!(eg, "pair-first" = |xs: @PairContainer (arc)| -> # (self.first()) { xs.first }); - add_primitive!(eg, "pair-second" = |xs: @PairContainer (arc)| -> # (self.second()) { xs.second }); + add_primitive_with_validator!(eg, "pair-first" = |xs: @PairContainer (arc)| -> # (self.first()) { xs.first }, pair_first_validator); + add_primitive_with_validator!(eg, "pair-second" = |xs: @PairContainer (arc)| -> # (self.second()) { xs.second }, pair_second_validator); } fn reconstruct_termdag( @@ -143,6 +181,10 @@ impl ContainerSort for PairSort { termdag.app("pair".into(), vec![element_terms[0], element_terms[1]]) } + fn rebuild_container_normalizer(&self) -> Option<(String, PrimitiveValidator)> { + Some(("pair".to_owned(), Arc::new(pair_term))) + } + fn serialized_name(&self, _container_values: &ContainerValues, _: Value) -> String { self.name().to_owned() } diff --git a/egglog/src/sort/set.rs b/egglog/src/sort/set.rs index 79ebd04..4506ae8 100644 --- a/egglog/src/sort/set.rs +++ b/egglog/src/sort/set.rs @@ -8,7 +8,7 @@ pub struct SetContainer { } impl ContainerValue for SetContainer { - fn rebuild_contents(&mut self, rebuilder: &dyn Rebuilder) -> bool { + fn rebuild_contents(&mut self, rebuilder: &dyn ValueRebuilder) -> bool { if self.do_rebuild { let mut xs: Vec<_> = self.data.iter().copied().collect(); let changed = rebuilder.rebuild_slice(&mut xs); @@ -23,6 +23,31 @@ impl ContainerValue for SetContainer { } } +/// The elements of a `(set-of e0 ...)` term as a Rust `BTreeSet` in AST +/// order, matching `SetContainer`'s semantics; `None` for any other term. +fn set_term_to_btreeset<'a>(termdag: &'a TermDag, term: TermId) -> Option>> { + match termdag.get(term) { + Term::App(head, children) if head == "set-of" => { + Some(children.iter().map(|c| termdag.ord_term(*c)).collect()) + } + _ => None, + } +} + +/// Flatten a set back to the element list of its canonical `(set-of ...)` +/// term (sorted by AST order and deduplicated by construction). +fn set_term_args(set: BTreeSet>) -> Vec { + set.into_iter().map(|e| e.id()).collect() +} + +/// Canonicalize `elements` to the `(set-of e0 e1 ...)` term form: sorted by +/// [`TermDag::ast_cmp`] and deduplicated, so proof checking can reproduce it. +fn normalize_set_term(termdag: &mut TermDag, elements: &[TermId]) -> TermId { + let set: BTreeSet<_> = elements.iter().map(|e| termdag.ord_term(*e)).collect(); + let elements = set_term_args(set); + termdag.app("set-of".into(), elements) +} + #[derive(Clone, Debug)] pub struct SetSort { name: String, @@ -110,26 +135,109 @@ impl ContainerSort for SetSort { fn register_primitives(&self, eg: &mut EGraph) { let arc = self.clone().to_arcsort(); - add_primitive!(eg, "set-empty" = {self.clone(): SetSort} | | -> @SetContainer (arc) { SetContainer { + // Proof term form of a set: `(set-of e0 e1 ...)` sorted and + // deduplicated, matching `reconstruct_termdag`. Each validator + // round-trips through a Rust `BTreeSet` (see `set_term_to_btreeset`), + // so it evaluates set terms with `SetContainer`'s semantics. + let set_of_validator = |termdag: &mut TermDag, args: &[TermId]| -> Option { + Some(normalize_set_term(termdag, args)) + }; + let set_empty_validator = |termdag: &mut TermDag, _args: &[TermId]| -> Option { + Some(termdag.app("set-of".into(), vec![])) + }; + let set_insert_validator = |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [set, value] = args else { + return None; + }; + let mut set = set_term_to_btreeset(termdag, *set)?; + set.insert(termdag.ord_term(*value)); + let elements = set_term_args(set); + Some(termdag.app("set-of".into(), elements)) + }; + let set_remove_validator = |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [set, value] = args else { + return None; + }; + let mut set = set_term_to_btreeset(termdag, *set)?; + set.remove(&termdag.ord_term(*value)); + let elements = set_term_args(set); + Some(termdag.app("set-of".into(), elements)) + }; + let set_length_validator = |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [set] = args else { + return None; + }; + let len = set_term_to_btreeset(termdag, *set)?.len() as i64; + Some(termdag.lit(Literal::Int(len))) + }; + let set_contains_validator = |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [set, value] = args else { + return None; + }; + let contains = set_term_to_btreeset(termdag, *set)?.contains(&termdag.ord_term(*value)); + contains.then(|| termdag.lit(Literal::Unit)) + }; + let set_not_contains_validator = |termdag: &mut TermDag, + args: &[TermId]| + -> Option { + let [set, value] = args else { + return None; + }; + let contains = set_term_to_btreeset(termdag, *set)?.contains(&termdag.ord_term(*value)); + (!contains).then(|| termdag.lit(Literal::Unit)) + }; + let set_union_validator = |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [left, right] = args else { + return None; + }; + let mut set = set_term_to_btreeset(termdag, *left)?; + set.extend(set_term_to_btreeset(termdag, *right)?); + let elements = set_term_args(set); + Some(termdag.app("set-of".into(), elements)) + }; + let set_diff_validator = |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [left, right] = args else { + return None; + }; + let mut set = set_term_to_btreeset(termdag, *left)?; + let right = set_term_to_btreeset(termdag, *right)?; + set.retain(|e| !right.contains(e)); + let elements = set_term_args(set); + Some(termdag.app("set-of".into(), elements)) + }; + let set_intersect_validator = |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [left, right] = args else { + return None; + }; + let mut set = set_term_to_btreeset(termdag, *left)?; + let right = set_term_to_btreeset(termdag, *right)?; + set.retain(|e| right.contains(e)); + let elements = set_term_args(set); + Some(termdag.app("set-of".into(), elements)) + }; + + add_primitive_with_validator!(eg, "set-empty" = {self.clone(): SetSort} | | -> @SetContainer (arc) { SetContainer { do_rebuild: self.ctx.is_eq_container_sort(), data: BTreeSet::new() - } }); - add_primitive!(eg, "set-of" = {self.clone(): SetSort} [xs: # (self.element())] -> @SetContainer (arc) { SetContainer { + } }, set_empty_validator); + add_primitive_with_validator!(eg, "set-of" = {self.clone(): SetSort} [xs: # (self.element())] -> @SetContainer (arc) { SetContainer { do_rebuild: self.ctx.is_eq_container_sort(), data: xs.collect() - } }); + } }, set_of_validator); + // No validator: `set-get` indexes the runtime `BTreeSet` order, + // which terms cannot reproduce, so it is unsupported in proof mode. add_primitive!(eg, "set-get" = |xs: @SetContainer (arc), i: i64| -?> # (self.element()) { xs.data.iter().nth(i as usize).copied() }); - add_primitive!(eg, "set-insert" = |mut xs: @SetContainer (arc), x: # (self.element())| -> @SetContainer (arc) {{ xs.data.insert( x); xs }}); - add_primitive!(eg, "set-remove" = |mut xs: @SetContainer (arc), x: # (self.element())| -> @SetContainer (arc) {{ xs.data.remove(&x); xs }}); + add_primitive_with_validator!(eg, "set-insert" = |mut xs: @SetContainer (arc), x: # (self.element())| -> @SetContainer (arc) {{ xs.data.insert( x); xs }}, set_insert_validator); + add_primitive_with_validator!(eg, "set-remove" = |mut xs: @SetContainer (arc), x: # (self.element())| -> @SetContainer (arc) {{ xs.data.remove(&x); xs }}, set_remove_validator); - add_primitive!(eg, "set-length" = |xs: @SetContainer (arc)| -> i64 { xs.data.len() as i64 }); - add_primitive!(eg, "set-contains" = |xs: @SetContainer (arc), x: # (self.element())| -?> () { ( xs.data.contains(&x)).then_some(()) }); - add_primitive!(eg, "set-not-contains" = |xs: @SetContainer (arc), x: # (self.element())| -?> () { (!xs.data.contains(&x)).then_some(()) }); + add_primitive_with_validator!(eg, "set-length" = |xs: @SetContainer (arc)| -> i64 { xs.data.len() as i64 }, set_length_validator); + add_primitive_with_validator!(eg, "set-contains" = |xs: @SetContainer (arc), x: # (self.element())| -?> () { ( xs.data.contains(&x)).then_some(()) }, set_contains_validator); + add_primitive_with_validator!(eg, "set-not-contains" = |xs: @SetContainer (arc), x: # (self.element())| -?> () { (!xs.data.contains(&x)).then_some(()) }, set_not_contains_validator); - add_primitive!(eg, "set-union" = |mut xs: @SetContainer (arc), ys: @SetContainer (arc)| -> @SetContainer (arc) {{ xs.data.extend(ys.data); xs }}); - add_primitive!(eg, "set-diff" = |mut xs: @SetContainer (arc), ys: @SetContainer (arc)| -> @SetContainer (arc) {{ xs.data.retain(|k| !ys.data.contains(k)); xs }}); - add_primitive!(eg, "set-intersect" = |mut xs: @SetContainer (arc), ys: @SetContainer (arc)| -> @SetContainer (arc) {{ xs.data.retain(|k| ys.data.contains(k)); xs }}); + add_primitive_with_validator!(eg, "set-union" = |mut xs: @SetContainer (arc), ys: @SetContainer (arc)| -> @SetContainer (arc) {{ xs.data.extend(ys.data); xs }}, set_union_validator); + add_primitive_with_validator!(eg, "set-diff" = |mut xs: @SetContainer (arc), ys: @SetContainer (arc)| -> @SetContainer (arc) {{ xs.data.retain(|k| !ys.data.contains(k)); xs }}, set_diff_validator); + add_primitive_with_validator!(eg, "set-intersect" = |mut xs: @SetContainer (arc), ys: @SetContainer (arc)| -> @SetContainer (arc) {{ xs.data.retain(|k| ys.data.contains(k)); xs }}, set_intersect_validator); } fn reconstruct_termdag( @@ -139,7 +247,18 @@ impl ContainerSort for SetSort { termdag: &mut TermDag, element_terms: Vec, ) -> TermId { - termdag.app("set-of".into(), element_terms) + // Canonical form (sorted by deterministic AST order, deduped) so proof + // checking can reproduce it from terms alone. + normalize_set_term(termdag, &element_terms) + } + + fn rebuild_container_normalizer(&self) -> Option<(String, PrimitiveValidator)> { + Some(( + "set-of".to_owned(), + Arc::new(|termdag: &mut TermDag, args: &[TermId]| { + Some(normalize_set_term(termdag, args)) + }), + )) } fn serialized_name(&self, _container_values: &ContainerValues, _: Value) -> String { diff --git a/egglog/src/sort/vec.rs b/egglog/src/sort/vec.rs index d29679d..2b1a9a8 100644 --- a/egglog/src/sort/vec.rs +++ b/egglog/src/sort/vec.rs @@ -11,7 +11,7 @@ pub struct VecContainer { } impl ContainerValue for VecContainer { - fn rebuild_contents(&mut self, rebuilder: &dyn Rebuilder) -> bool { + fn rebuild_contents(&mut self, rebuilder: &dyn ValueRebuilder) -> bool { if self.do_rebuild { rebuilder.rebuild_slice(&mut self.data) } else { @@ -35,6 +35,26 @@ impl VecSort { } } +/// The element terms of a vec's canonical term form (`(vec-of e0 …)`, or +/// `(vec-empty)` for the empty vec); `None` for any other term. +fn vec_term_children(termdag: &TermDag, term: TermId) -> Option> { + match termdag.get(term) { + Term::App(head, children) if head == "vec-of" => Some(children.clone()), + Term::App(head, _) if head == "vec-empty" => Some(vec![]), + _ => None, + } +} + +/// Intern the canonical vec term for `children`: `(vec-of e0 ...)`, or +/// `(vec-empty)` when empty. The inverse of [`vec_term_children`]. +fn vec_term(termdag: &mut TermDag, children: Vec) -> TermId { + if children.is_empty() { + termdag.app("vec-empty".into(), vec![]) + } else { + termdag.app("vec-of".into(), children) + } +} + impl Presort for VecSort { fn presort_name() -> &'static str { "Vec" @@ -113,14 +133,49 @@ impl ContainerSort for VecSort { fn register_primitives(&self, eg: &mut EGraph) { let arc: Arc = self.clone().to_arcsort(); - add_primitive!(eg, "vec-empty" = {self.clone(): VecSort} | | -> @VecContainer (arc) { VecContainer { + // The proof "term form" of a vec: `(vec-of e0 e1 ...)`, or `(vec-empty)` + // when empty, matching `reconstruct_termdag`. The validator lets the + // proof checker evaluate `vec-of`/`vec-empty` applications. + let vec_of_validator = |termdag: &mut TermDag, args: &[TermId]| -> Option { + Some(vec_term(termdag, args.to_vec())) + }; + let vec_empty_validator = |termdag: &mut TermDag, _args: &[TermId]| -> Option { + Some(termdag.app("vec-empty".into(), vec![])) + }; + let vec_length_validator = |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [vec] = args else { return None }; + let len = vec_term_children(termdag, *vec)?.len() as i64; + Some(termdag.lit(Literal::Int(len))) + }; + let vec_get_validator = |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [vec, index] = args else { return None }; + let Term::Lit(Literal::Int(index)) = termdag.get(*index) else { + return None; + }; + let index = usize::try_from(*index).ok()?; + vec_term_children(termdag, *vec)?.get(index).copied() + }; + let vec_contains_validator = |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [vec, value] = args else { return None }; + vec_term_children(termdag, *vec)? + .contains(value) + .then(|| termdag.lit(Literal::Unit)) + }; + let vec_not_contains_validator = + |termdag: &mut TermDag, args: &[TermId]| -> Option { + let [vec, value] = args else { return None }; + let contains = vec_term_children(termdag, *vec)?.contains(value); + (!contains).then(|| termdag.lit(Literal::Unit)) + }; + + add_primitive_with_validator!(eg, "vec-empty" = {self.clone(): VecSort} | | -> @VecContainer (arc) { VecContainer { do_rebuild: self.ctx.is_eq_container_sort(), data: Vec::new() - } }); - add_primitive!(eg, "vec-of" = {self.clone(): VecSort} [xs: # (self.element()) ] -> @VecContainer (arc) { VecContainer { + } }, vec_empty_validator); + add_primitive_with_validator!(eg, "vec-of" = {self.clone(): VecSort} [xs: # (self.element()) ] -> @VecContainer (arc) { VecContainer { do_rebuild: self.ctx.is_eq_container_sort(), data: xs .collect() - } }); + } }, vec_of_validator); add_primitive!(eg, "vec-append" = {self.clone(): VecSort} [xs: @VecContainer (arc)] -> @VecContainer (arc) { VecContainer { do_rebuild: self.ctx.is_eq_container_sort(), data: xs.flat_map(|x| x.data).collect() @@ -129,11 +184,11 @@ impl ContainerSort for VecSort { add_primitive!(eg, "vec-push" = |mut xs: @VecContainer (arc), x: # (self.element())| -> @VecContainer (arc) {{ xs.data.push(x); xs }}); add_primitive!(eg, "vec-pop" = |mut xs: @VecContainer (arc) | -> @VecContainer (arc) {{ xs.data.pop(); xs }}); - add_primitive!(eg, "vec-length" = |xs: @VecContainer (arc)| -> i64 { xs.data.len() as i64 }); - add_primitive!(eg, "vec-contains" = |xs: @VecContainer (arc), x: # (self.element())| -?> () { ( xs.data.contains(&x)).then_some(()) }); - add_primitive!(eg, "vec-not-contains" = |xs: @VecContainer (arc), x: # (self.element())| -?> () { (!xs.data.contains(&x)).then_some(()) }); + add_primitive_with_validator!(eg, "vec-length" = |xs: @VecContainer (arc)| -> i64 { xs.data.len() as i64 }, vec_length_validator); + add_primitive_with_validator!(eg, "vec-contains" = |xs: @VecContainer (arc), x: # (self.element())| -?> () { ( xs.data.contains(&x)).then_some(()) }, vec_contains_validator); + add_primitive_with_validator!(eg, "vec-not-contains" = |xs: @VecContainer (arc), x: # (self.element())| -?> () { (!xs.data.contains(&x)).then_some(()) }, vec_not_contains_validator); - add_primitive!(eg, "vec-get" = | xs: @VecContainer (arc), i: i64 | -?> # (self.element()) { xs.data.get(i as usize).copied() }); + add_primitive_with_validator!(eg, "vec-get" = | xs: @VecContainer (arc), i: i64 | -?> # (self.element()) { xs.data.get(i as usize).copied() }, vec_get_validator); add_primitive!(eg, "vec-set" = |mut xs: @VecContainer (arc), i: i64, x: # (self.element())| -> @VecContainer (arc) {{ xs.data[i as usize] = x; xs }}); add_primitive!(eg, "vec-remove" = |mut xs: @VecContainer (arc), i: i64 | -> @VecContainer (arc) {{ xs.data.remove(i as usize); xs }}); if self.element.is_eq_sort() { @@ -177,11 +232,16 @@ impl ContainerSort for VecSort { termdag: &mut TermDag, element_terms: Vec, ) -> TermId { - if element_terms.is_empty() { - termdag.app("vec-empty".into(), vec![]) - } else { - termdag.app("vec-of".into(), element_terms) - } + vec_term(termdag, element_terms) + } + + fn rebuild_container_normalizer(&self) -> Option<(String, PrimitiveValidator)> { + Some(( + "vec-of".to_owned(), + Arc::new(|termdag: &mut TermDag, args: &[TermId]| { + Some(vec_term(termdag, args.to_vec())) + }), + )) } fn serialized_name(&self, _container_values: &ContainerValues, _: Value) -> String { diff --git a/egglog/src/termdag.rs b/egglog/src/termdag.rs index 55ff0c9..0160d10 100644 --- a/egglog/src/termdag.rs +++ b/egglog/src/termdag.rs @@ -23,6 +23,44 @@ pub struct TermDag { nodes: IndexSet, } +/// A [`TermId`] paired with its [`TermDag`] so it can be ordered by +/// [`TermDag::ast_cmp`], for use in ordered collections like +/// `BTreeMap`/`BTreeSet` (see [`TermDag::ord_term`]). Only compare wrappers +/// from the same [`TermDag`]. +#[derive(Copy, Clone)] +pub struct OrdTerm<'a> { + termdag: &'a TermDag, + id: TermId, +} + +impl OrdTerm<'_> { + /// The wrapped [`TermId`]. + pub fn id(&self) -> TermId { + self.id + } +} + +impl PartialEq for OrdTerm<'_> { + fn eq(&self, other: &Self) -> bool { + // Terms are hashconsed, so id equality is structural equality. + self.id == other.id + } +} + +impl Eq for OrdTerm<'_> {} + +impl PartialOrd for OrdTerm<'_> { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for OrdTerm<'_> { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + self.termdag.ast_cmp(self.id, other.id) + } +} + const MAX_PRETTY_LINE_WIDTH: usize = 80; const PRETTY_INDENT_STEP: usize = 2; const MIN_SHARED_TERM_SIZE: usize = 4; @@ -124,6 +162,65 @@ impl TermDag { self.nodes.get_index(id).unwrap() } + /// A deterministic total order on terms by their AST *structure*, rather + /// than by insertion order (which is what comparing raw [`TermId`]s would + /// give). Literals order among themselves by value, variables by name, and + /// applications by head symbol, then arity, then children left-to-right; + /// across kinds, `Lit < Var < App`. + /// + /// Useful for canonicalizing the elements of an unordered structure (e.g. a + /// set or multiset) into a stable, reproducible term order. + /// + /// `App` children are compared structurally, not by raw [`TermId`] order, + /// so [`Term`] does not derive `Ord` and the leaf arms are written out + /// rather than calling `l.cmp(r)`. Uses an explicit worklist because terms + /// can be deeply nested. + pub fn ast_cmp(&self, a: TermId, b: TermId) -> std::cmp::Ordering { + use std::cmp::Ordering; + let mut worklist = vec![(a, b)]; + while let Some((a, b)) = worklist.pop() { + if a == b { + // Hashconsed: identical ids are structurally equal. + continue; + } + let ord = match (self.get(a), self.get(b)) { + (Term::Lit(x), Term::Lit(y)) => x.cmp(y), + (Term::Lit(_), _) => Ordering::Less, + (_, Term::Lit(_)) => Ordering::Greater, + (Term::Var(x), Term::Var(y)) => x.cmp(y), + (Term::Var(_), _) => Ordering::Less, + (_, Term::Var(_)) => Ordering::Greater, + (Term::App(hx, ax), Term::App(hy, ay)) => { + match hx.cmp(hy).then_with(|| ax.len().cmp(&ay.len())) { + Ordering::Equal => { + // Children compare left to right: push reversed so + // the leftmost pair pops first. + worklist.extend(ax.iter().copied().zip(ay.iter().copied()).rev()); + continue; + } + ord => ord, + } + } + }; + if ord.is_ne() { + return ord; + } + } + Ordering::Equal + } + + /// Sort child terms in place by [`ast_cmp`](Self::ast_cmp). A reusable + /// building block for canonicalizing container elements. + pub fn sort_terms_by_ast(&self, terms: &mut [TermId]) { + terms.sort_by(|a, b| self.ast_cmp(*a, *b)); + } + + /// Wrap `id` so it is ordered by [`ast_cmp`](Self::ast_cmp), e.g. as a key + /// in a `BTreeMap`/`BTreeSet` when canonicalizing container terms. + pub fn ord_term(&self, id: TermId) -> OrdTerm<'_> { + OrdTerm { termdag: self, id } + } + /// Make and return a [`Term::App`] with the given head symbol and children, /// and insert into the DAG if it is not already present. /// @@ -465,6 +562,35 @@ mod tests { (td, t) } + #[test] + fn test_ast_cmp() { + use std::cmp::Ordering; + let mut td = TermDag::default(); + let i1 = td.lit(Literal::Int(1)); + let i2 = td.lit(Literal::Int(2)); + let vx = td.var("x".into()); + let f_i1 = td.app("f".into(), vec![i1]); + let f_i2 = td.app("f".into(), vec![i2]); + let g_i1 = td.app("g".into(), vec![i1]); + let f_i1_i1 = td.app("f".into(), vec![i1, i1]); + + // Cross-kind: Lit < Var < App. + assert_eq!(td.ast_cmp(i1, vx), Ordering::Less); + assert_eq!(td.ast_cmp(vx, f_i1), Ordering::Less); + assert_eq!(td.ast_cmp(i1, f_i1), Ordering::Less); + // Literals by value. + assert_eq!(td.ast_cmp(i1, i2), Ordering::Less); + // Apps: same head, compare children. + assert_eq!(td.ast_cmp(f_i1, f_i2), Ordering::Less); + // Apps: by head symbol first. + assert_eq!(td.ast_cmp(f_i1, g_i1), Ordering::Less); + // Apps: by arity when head equal and shorter is a prefix. + assert_eq!(td.ast_cmp(f_i1, f_i1_i1), Ordering::Less); + // Reflexive / total. + assert_eq!(td.ast_cmp(f_i1, f_i1), Ordering::Equal); + assert_eq!(td.ast_cmp(f_i2, f_i1), Ordering::Greater); + } + #[test] fn test_to_from_expr() { let s = r#"(f (g x y) x y (g x y))"#; diff --git a/egglog/src/typechecking.rs b/egglog/src/typechecking.rs index 53cf2b4..39f3749 100644 --- a/egglog/src/typechecking.rs +++ b/egglog/src/typechecking.rs @@ -1,6 +1,7 @@ use std::hash::Hasher; use crate::Context; +use crate::proofs::proof_container_rebuild::register_container_rebuild_from_spec; use crate::{ core::{CoreActionContext, CoreRule, GenericActionsExt, ResolvedCall}, *, @@ -415,6 +416,8 @@ impl EGraph { presort_and_args, uf, proof_func, + container_rebuild, + proof_constructors, unionable, } => { // Note this is bad since typechecking should be pure and idempotent @@ -424,12 +427,51 @@ impl EGraph { if !unionable { self.type_info.non_unionable_sorts.insert(name.clone()); } + // Record this sort's UF / proof tables in proof_state (as + // run_command also does) so the container rebuild registration + // below can recover them — including this container's own proof + // table, which has not run yet. + if let Some((uf_ctor, uf_index)) = uf { + self.proof_state + .uf_parent + .insert(name.clone(), uf_ctor.clone()); + if let Some(uf_index) = uf_index { + self.proof_state + .uf_function + .insert(name.clone(), uf_index.clone()); + } + } + if let Some(pf) = proof_func { + self.proof_state + .proof_func_parent + .insert(name.clone(), pf.clone()); + } + // The Proof sort records the global proof constructors; restore + // them into proof_state so container rebuild can recover them + // (the `Proof` datatype name is this sort's own name). + if let Some(pc) = proof_constructors { + let names = &mut self.proof_state.proof_names; + names.proof_datatype = name.clone(); + names.congr_constructor = pc.congr.clone(); + names.eq_trans_constructor = pc.trans.clone(); + names.eq_sym_constructor = pc.sym.clone(); + names.container_normalize_constructor = pc.normalize.clone(); + } + // A container sort under the term/proof encoding carries a spec + // for its rebuild primitives; register them here so they are + // available both during encoding and when the desugared program + // is re-parsed. + if let Some(spec) = container_rebuild { + register_container_rebuild_from_spec(self, name, spec); + } ResolvedNCommand::Sort { span: span.clone(), name: name.clone(), presort_and_args: presort_and_args.clone(), uf: uf.clone(), proof_func: proof_func.clone(), + container_rebuild: container_rebuild.clone(), + proof_constructors: proof_constructors.clone(), unionable: *unionable, } } diff --git a/egglog/tests/container-proofs.egg b/egglog/tests/container-proofs.egg new file mode 100644 index 0000000..0f90825 --- /dev/null +++ b/egglog/tests/container-proofs.egg @@ -0,0 +1,105 @@ +; Containers in queries and in rule bodies, exercised under proofs. +; +; The file-test harness runs every .egg in proof mode and turns each `check` +; into a proof obligation, so the checks below are proof-checked automatically. +; Elements are an eq-sort, so every container here is an eq-container (rebuild +; applies). Containers are matched, read, and constructed in the body (as side +; conditions); only validator-backed container primitives are used. A container +; built in the body is never carried into an action (that is rejected). + +(datatype N (Z) (S N)) + +; ===== containers built in actions, then checked ===== +(sort SetN (Set N)) +(relation HasSet (SetN)) +(HasSet (set-of (Z) (S (Z)))) +; set canonical form is order/duplicate-insensitive +(check (HasSet (set-of (S (Z)) (Z) (S (Z))))) + +(sort PairN (Pair N N)) +(relation HasPair (PairN)) +(HasPair (pair (Z) (S (Z)))) +(check (HasPair (pair (Z) (S (Z))))) + +(sort VecN (Vec N)) +(relation HasVec (VecN)) +(HasVec (vec-of (Z) (S (Z)))) +(check (HasVec (vec-of (Z) (S (Z))))) + +(sort MapN (Map N N)) +(relation HasMap (MapN)) +(HasMap (map-insert (map-empty) (Z) (S (Z)))) +(check (HasMap (map-insert (map-empty) (Z) (S (Z))))) + +(sort MSN (MultiSet N)) +(relation HasMS (MSN)) +(HasMS (multiset-of (Z) (Z) (S (Z)))) +(check (HasMS (multiset-of (Z) (S (Z)) (Z)))) + +; ===== matched containers read in a query (exercises the reader validators) ===== +(relation VLen (i64)) +(relation VGet (N)) +(rule ((HasVec v) (= n (vec-length v))) ((VLen n))) +(rule ((HasVec v) (= e (vec-get v 1))) ((VGet e))) +(run 1) +(check (VLen 2)) +(check (VGet (S (Z)))) + +(relation MapLen (i64)) +(relation MapGet (N)) +(rule ((HasMap m) (= n (map-length m))) ((MapLen n))) +(rule ((HasMap m) (= w (map-get m (Z)))) ((MapGet w))) +(run 1) +(check (MapLen 1)) +(check (MapGet (S (Z)))) + +(relation MSLen (i64)) +(rule ((HasMS m) (= n (multiset-length m))) ((MSLen n))) +(run 1) +(check (MSLen 3)) + +; eq-sort primitive result in a body fact (pair-first returns an element) +(relation PFirst (N)) +(rule ((HasPair p) (= a (pair-first p))) ((PFirst a))) +(run 1) +(check (PFirst (Z))) + +; ===== containers constructed in the query (Eval-justified) ===== +; A container built by a primitive in the rule body has no anchored term-proof; +; `Eval` justifies it from its arguments' existence proofs, re-derived with the +; typed primitive when the rule fires. +(relation HasElem (N)) +(HasElem (Z)) +(HasElem (S (Z))) + +; build a vec in the body and read its length (a base-sorted result) +(relation QVecLen (i64)) +(rule ((HasElem a) (= xs (vec-of a a)) (= n (vec-length xs))) ((QVecLen n))) +(run 1) +(check (QVecLen 2)) + +; build a vec in the body and read an element back out (an eq-sort result) +(relation QVecGet (N)) +(rule ((HasElem a) (HasElem b) (= xs (vec-of a b)) (= e (vec-get xs 1))) ((QVecGet e))) +(run 1) +(check (QVecGet (Z))) +(check (QVecGet (S (Z)))) + +; join two containers built in the body (neither bound nor used in an action); +; `set-of` is injective on singletons, so this matches only when a = b +(relation QSame (N N)) +(rule ((HasElem a) (HasElem b) (= (set-of a) (set-of b))) ((QSame a b))) +(run 1) +(check (QSame (Z) (Z))) +(check (QSame (S (Z)) (S (Z)))) +(fail (check (QSame (Z) (S (Z))))) + +; a container built in the body, nested inside a constructor matched against the +; e-graph: proof normal form lifts the container into its own side condition, so +; the constructor is matched on the resulting variable +(datatype WrapV (WrapVec VecN)) +(relation OutWrap (WrapV)) +(WrapVec (vec-of (Z) (Z))) +(rule ((HasElem a) (= w (WrapVec (vec-of a a)))) ((OutWrap w))) +(run 1) +(check (OutWrap (WrapVec (vec-of (Z) (Z))))) diff --git a/egglog/tests/container_rebuild.rs b/egglog/tests/container_rebuild.rs new file mode 100644 index 0000000..6e120f4 --- /dev/null +++ b/egglog/tests/container_rebuild.rs @@ -0,0 +1,403 @@ +//! End-to-end tests for container support in the term/proof encoding. + +use egglog::EGraph; + +/// Term-only: a `(Vec Math)` column should canonicalize its elements during +/// rebuilding. After unioning two Math terms, the two vecs `(vec-of A)` and +/// `(vec-of B)` canonicalize to the same vec, so the constructors holding them +/// become congruent. +#[test] +fn vec_rebuild_term_only() { + let mut egraph = EGraph::new_with_term_encoding(); + egraph + .parse_and_run_program( + None, + r#" + (sort Math) + (constructor A () Math) + (constructor B () Math) + (sort MathVec (Vec Math)) + (constructor Holds (MathVec) Math) + (Holds (vec-of (A))) + (Holds (vec-of (B))) + (union (A) (B)) + (run 1) + (check (= (Holds (vec-of (A))) (Holds (vec-of (B))))) + "#, + ) + .unwrap(); +} + +/// Term-only: a collapsing `(Set Math)` column. After unioning A and B, the +/// set `{A, B}` collapses to a singleton, matching `{B}` (a one-element set), +/// so the two holders become congruent. +#[test] +fn set_rebuild_collapse_term_only() { + let mut egraph = EGraph::new_with_term_encoding(); + egraph + .parse_and_run_program( + None, + r#" + (sort Math) + (constructor A () Math) + (constructor B () Math) + (sort MathSet (Set Math)) + (constructor Holds (MathSet) Math) + (Holds (set-of (A) (B))) + (Holds (set-of (B))) + (union (A) (B)) + (run 1) + (check (= (Holds (set-of (A) (B))) (Holds (set-of (B))))) + "#, + ) + .unwrap(); +} + +/// Term-only: a `(Map Math Math)` column canonicalizes keys and values. +#[test] +fn map_rebuild_term_only() { + let mut egraph = EGraph::new_with_term_encoding(); + egraph + .parse_and_run_program( + None, + r#" + (sort Math) + (constructor A () Math) + (constructor B () Math) + (sort MathMap (Map Math Math)) + (constructor Holds (MathMap) Math) + (Holds (map-insert (map-empty) (A) (A))) + (Holds (map-insert (map-empty) (B) (B))) + (union (A) (B)) + (run 1) + (check (= (Holds (map-insert (map-empty) (A) (A))) + (Holds (map-insert (map-empty) (B) (B))))) + "#, + ) + .unwrap(); +} + +/// Term-only: a `(MultiSet Math)` column canonicalizes elements. +#[test] +fn multiset_rebuild_term_only() { + let mut egraph = EGraph::new_with_term_encoding(); + egraph + .parse_and_run_program( + None, + r#" + (sort Math) + (constructor A () Math) + (constructor B () Math) + (sort MathMS (MultiSet Math)) + (constructor Holds (MathMS) Math) + (Holds (multiset-of (A))) + (Holds (multiset-of (B))) + (union (A) (B)) + (run 1) + (check (= (Holds (multiset-of (A))) (Holds (multiset-of (B))))) + "#, + ) + .unwrap(); +} + +/// Term-only: a nested `(Vec (Vec Math))` column. Canonicalizing the deep +/// element must propagate through the inner vec to the outer vec. +#[test] +fn nested_vec_rebuild_term_only() { + let mut egraph = EGraph::new_with_term_encoding(); + egraph + .parse_and_run_program( + None, + r#" + (sort Math) + (constructor A () Math) + (constructor B () Math) + (sort MathVec (Vec Math)) + (sort MathVecVec (Vec MathVec)) + (constructor Holds (MathVecVec) Math) + (Holds (vec-of (vec-of (A)))) + (Holds (vec-of (vec-of (B)))) + (union (A) (B)) + (run 1) + (check (= (Holds (vec-of (vec-of (A)))) (Holds (vec-of (vec-of (B)))))) + "#, + ) + .unwrap(); +} + +/// Proof mode: a nested `(Vec (Vec Math))` column, with proof checking. +#[test] +fn nested_vec_rebuild_proof_mode() { + let mut egraph = EGraph::new_with_proofs().with_proof_testing(); + egraph + .parse_and_run_program( + None, + r#" + (sort Math) + (constructor A () Math) + (constructor B () Math) + (sort MathVec (Vec Math)) + (sort MathVecVec (Vec MathVec)) + (constructor Holds (MathVecVec) Math) + (Holds (vec-of (vec-of (A)))) + (Holds (vec-of (vec-of (B)))) + (union (A) (B)) + (run 1) + (check (= (Holds (vec-of (vec-of (A)))) (Holds (vec-of (vec-of (B)))))) + "#, + ) + .unwrap(); +} + +/// Proof mode: a `(Pair Math Math)` column. The container rebuild produces a +/// `Congr` proof, and `with_proof_testing` extracts and checks the proof for +/// the `check`. +#[test] +fn pair_rebuild_proof_mode() { + let mut egraph = EGraph::new_with_proofs().with_proof_testing(); + egraph + .parse_and_run_program( + None, + r#" + (sort Math) + (constructor A () Math) + (constructor B () Math) + (sort MathPair (Pair Math Math)) + (constructor Holds (MathPair) Math) + (Holds (pair (A) (A))) + (Holds (pair (B) (B))) + (union (A) (B)) + (run 1) + (check (= (Holds (pair (A) (A))) (Holds (pair (B) (B))))) + "#, + ) + .unwrap(); +} + +/// Proof mode: a `(Vec Math)` column. +#[test] +fn vec_rebuild_proof_mode() { + let mut egraph = EGraph::new_with_proofs().with_proof_testing(); + egraph + .parse_and_run_program( + None, + r#" + (sort Math) + (constructor A () Math) + (constructor B () Math) + (sort MathVec (Vec Math)) + (constructor Holds (MathVec) Math) + (Holds (vec-of (A))) + (Holds (vec-of (B))) + (union (A) (B)) + (run 1) + (check (= (Holds (vec-of (A))) (Holds (vec-of (B))))) + "#, + ) + .unwrap(); +} + +/// Term-only: a `(Pair Math Math)` column should canonicalize both elements. +#[test] +fn pair_rebuild_term_only() { + let mut egraph = EGraph::new_with_term_encoding(); + egraph + .parse_and_run_program( + None, + r#" + (sort Math) + (constructor A () Math) + (constructor B () Math) + (sort MathPair (Pair Math Math)) + (constructor Holds (MathPair) Math) + (Holds (pair (A) (A))) + (Holds (pair (B) (B))) + (union (A) (B)) + (run 1) + (check (= (Holds (pair (A) (A))) (Holds (pair (B) (B))))) + "#, + ) + .unwrap(); +} + +/// Proof mode: a `(MultiSet Math)` merge. Counts are preserved as repeated +/// elements, so canonicalization is arity-preserving and the flat `Congr` +/// chain checks. +#[test] +fn multiset_rebuild_proof_mode() { + let mut egraph = EGraph::new_with_proofs().with_proof_testing(); + egraph + .parse_and_run_program( + None, + r#" + (sort Math) + (constructor A () Math) + (constructor B () Math) + (sort MathMS (MultiSet Math)) + (constructor Holds (MathMS) Math) + (Holds (multiset-of (A))) + (Holds (multiset-of (B))) + (union (A) (B)) + (run 1) + (check (= (Holds (multiset-of (A))) (Holds (multiset-of (B))))) + "#, + ) + .unwrap(); +} + +/// Proof mode: a `(Set Math)` rebuild that does NOT collapse (the changed +/// element stays distinct from the others), so arity is preserved and it +/// checks. +#[test] +fn set_rebuild_noncollapse_proof_mode() { + let mut egraph = EGraph::new_with_proofs().with_proof_testing(); + egraph + .parse_and_run_program( + None, + r#" + (sort Math) + (constructor A () Math) + (constructor B () Math) + (constructor C () Math) + (sort MathSet (Set Math)) + (constructor Holds (MathSet) Math) + (Holds (set-of (A) (C))) + (Holds (set-of (B) (C))) + (union (A) (B)) + (run 1) + (check (= (Holds (set-of (A) (C))) (Holds (set-of (B) (C))))) + "#, + ) + .unwrap(); +} + +/// Proof mode: a `(Map Math Math)` rebuild that does NOT collapse (a value +/// changes, keys stay distinct), so arity is preserved and it checks. +#[test] +fn map_rebuild_noncollapse_proof_mode() { + let mut egraph = EGraph::new_with_proofs().with_proof_testing(); + egraph + .parse_and_run_program( + None, + r#" + (sort Math) + (constructor A () Math) + (constructor B () Math) + (constructor K () Math) + (sort MathMap (Map Math Math)) + (constructor Holds (MathMap) Math) + (Holds (map-insert (map-empty) (K) (A))) + (Holds (map-insert (map-empty) (K) (B))) + (union (A) (B)) + (run 1) + (check (= (Holds (map-insert (map-empty) (K) (A))) + (Holds (map-insert (map-empty) (K) (B))))) + "#, + ) + .unwrap(); +} + +/// Proof mode: a collapsing `(Set Math)`. Unioning A and B collapses `{A,B}` to +/// a singleton; the `Congr` chain rebuilds to the (non-canonical) `set-of(A,A)` +/// and the container normalization gives `set-of(A)`, matching `{A}`. +#[test] +fn set_rebuild_collapse_proof_mode() { + let mut egraph = EGraph::new_with_proofs().with_proof_testing(); + egraph + .parse_and_run_program( + None, + r#" + (sort Math) + (constructor A () Math) + (constructor B () Math) + (sort MathSet (Set Math)) + (constructor Holds (MathSet) Math) + (Holds (set-of (A) (B))) + (Holds (set-of (B))) + (union (A) (B)) + (run 1) + (check (= (Holds (set-of (A) (B))) (Holds (set-of (B))))) + "#, + ) + .unwrap(); +} + +/// Proof mode: a `(Set Math)` rebuild where a leader sorts to a different slot +/// (reorder without collapse). `A`'s `:cost` forces the merged class to +/// extract as `(E)`, so `{(A), (C)}` rebuilds to `{(C), (E)}`: the changed +/// element moves from slot 0 to slot 1 and the container normalization +/// re-sorts the raw `Congr` result to canonical order. +#[test] +fn set_rebuild_reorder_proof_mode() { + let mut egraph = EGraph::new_with_proofs().with_proof_testing(); + egraph + .parse_and_run_program( + None, + r#" + (sort Math) + (constructor A () Math :cost 100) + (constructor C () Math) + (constructor E () Math) + (sort MathSet (Set Math)) + (constructor Holds (MathSet) Math) + (Holds (set-of (A) (C))) + (Holds (set-of (E) (C))) + (union (A) (E)) + (run 1) + (check (= (Holds (set-of (A) (C))) (Holds (set-of (E) (C))))) + "#, + ) + .unwrap(); +} + +/// Proof mode: a `(MultiSet Math)` merge that adds counts (`{A:2}` after +/// unioning two distinct elements). Multiplicities are preserved as repeated +/// elements, so the normalization just re-sorts. +#[test] +fn multiset_rebuild_merge_counts_proof_mode() { + let mut egraph = EGraph::new_with_proofs().with_proof_testing(); + egraph + .parse_and_run_program( + None, + r#" + (sort Math) + (constructor A () Math) + (constructor B () Math) + (sort MathMS (MultiSet Math)) + (constructor Holds (MathMS) Math) + (Holds (multiset-of (A) (A))) + (Holds (multiset-of (B) (B))) + (union (A) (B)) + (run 1) + (check (= (Holds (multiset-of (A) (A))) (Holds (multiset-of (B) (B))))) + "#, + ) + .unwrap(); +} + +/// Proof mode: a collapsing `(Map Math Math)` — two keys merge into one +/// (last-write-wins). The flat `map-of` term form makes the rebuild Congr +/// indices flat, and the container normalization re-sorts and merges keys (last-write-wins). +#[test] +fn map_rebuild_collapse_proof_mode() { + let mut egraph = EGraph::new_with_proofs().with_proof_testing(); + egraph + .parse_and_run_program( + None, + r#" + (sort Math) + (constructor A () Math) + (constructor B () Math) + (constructor V () Math) + (sort MathMap (Map Math Math)) + (constructor Holds (MathMap) Math) + (Holds (map-insert (map-insert (map-empty) (A) (V)) (B) (V))) + (Holds (map-insert (map-empty) (B) (V))) + (union (A) (B)) + (run 1) + (check (= (Holds (map-insert (map-insert (map-empty) (A) (V)) (B) (V))) + (Holds (map-insert (map-empty) (B) (V))))) + "#, + ) + .unwrap(); +} diff --git a/egglog/tests/files.rs b/egglog/tests/files.rs index e94dc40..83b4cae 100644 --- a/egglog/tests/files.rs +++ b/egglog/tests/files.rs @@ -4,6 +4,35 @@ use egglog::{file_supports_proofs, *}; use hashbrown::HashSet; use libtest_mimic::Trial; +struct ManualProofDisable { + file: &'static str, + reason: &'static str, +} + +const MANUAL_PROOF_DISABLED_FILES: &[ManualProofDisable] = &[ + ManualProofDisable { + file: "eggcc-2mm.egg", + reason: "uses :no-merge declarations such as DUMMYCTX; proof encoding requires a merge function", + }, + ManualProofDisable { + file: "subsume.egg", + reason: "proof-testing rewrites a check on a subsumed expression into a prove query that no longer matches", + }, + ManualProofDisable { + file: "subsume-relation.egg", + reason: "proof-testing rewrites a check on a subsumed relation row into a prove query that no longer matches", + }, +]; + +const PROOF_INTEGRATION_FILES: &[&str] = &[ + "tests/integer_math.egg", + "tests/web-demo/math.egg", + "tests/math-microbenchmark.egg", + "tests/web-demo/resolution.egg", + "tests/web-demo/rw-analysis.egg", + "tests/web-demo/eqsolve.egg", +]; + #[derive(Clone)] struct Run { path: PathBuf, @@ -22,6 +51,26 @@ impl Run { self.path.parent().unwrap().ends_with("proofs") } + fn is_proof_mode_trial(&self) -> bool { + self.term_encoding || self.proofs || self.proof_testing + } + + fn is_curated_proof_integration(&self) -> bool { + PROOF_INTEGRATION_FILES + .iter() + .any(|file| self.path.ends_with(file)) + } + + fn proof_filter_prefix(&self) -> Option<&'static str> { + if self.requires_proofs() && self.is_proof_mode_trial() { + Some("proof_unit") + } else if self.is_curated_proof_integration() && self.proof_testing { + Some("proof_integration") + } else { + None + } + } + fn filename_for_test_run(&self) -> Option { if self.should_fail() { // Fail-typecheck errors are snapshot-tested. Pass a stable display @@ -73,6 +122,30 @@ impl Run { }; // Debug mode enables parallelism which can lead to non-deterministic output ordering + if let Some(snapshot_name) = self.proof_testing_snapshot_name() { + match &result { + Ok(outputs) => { + let proof_snapshot = CommandOutput::snapshot_proofs_only(outputs); + if !proof_snapshot.is_empty() { + insta::assert_snapshot!(snapshot_name, proof_snapshot); + } + + let shared_snapshot = + CommandOutput::snapshot_non_proof_stable_under_proof_encoding(outputs); + if !shared_snapshot.is_empty() { + insta::assert_snapshot!( + self.snapshot_name_across_treatments(), + shared_snapshot + ); + } + } + Err(err_msg) => { + panic!("proof fixture failed: {err_msg}"); + } + } + return; + } + if !self.should_skip_snapshot() { match &result { Ok(outputs) => { @@ -223,12 +296,22 @@ impl Run { name } + fn proof_testing_snapshot_name(&self) -> Option { + if self.is_curated_proof_integration() && self.proof_testing { + Some(self.name().to_string()) + } else { + None + } + } + /// Full test name with mode suffixes for test identification fn name(&self) -> impl std::fmt::Display + '_ { struct Wrapper<'a>(&'a Run); impl std::fmt::Display for Wrapper<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - if self.0.path.parent().unwrap().ends_with("fail-typecheck") { + if let Some(prefix) = self.0.proof_filter_prefix() { + write!(f, "{prefix}/")?; + } else if self.0.path.parent().unwrap().ends_with("fail-typecheck") { write!(f, "fail-typecheck/")?; } let stem = self.0.path.file_stem().unwrap(); @@ -264,29 +347,20 @@ impl Run { fn should_skip_snapshot(&self) -> bool { if self.threads > 1 { // Skip snapshots for parallel tests due to non-deterministic output ordering - true - } else { - // Skip tests with known non-deterministic output - let filename = self.path.file_stem().unwrap().to_string_lossy(); - const SKIP_PATTERNS: [&str; 6] = [ - "extract-vec-bench", - "python_array_optimize", - "stresstest_large_expr", - "towers-of-hanoi", - "taylor51", - "factoring-multisets", - ]; - if SKIP_PATTERNS.iter().any(|pat| filename.contains(pat)) { - return true; - } - - // bug with egglog producing nondeterministic output in certain modes - let proof_skip_list = ["math-microbenchmark", "eqsolve"]; - let in_list = proof_skip_list - .iter() - .any(|f| self.path.to_string_lossy().contains(f)); - in_list && (self.proofs || self.term_encoding || self.proof_testing) + return true; } + + // Skip tests with known non-deterministic output + let filename = self.path.file_stem().unwrap().to_string_lossy(); + const SKIP_PATTERNS: [&str; 6] = [ + "extract-vec-bench", + "python_array_optimize", + "stresstest_large_expr", + "towers-of-hanoi", + "taylor51", + "factoring-multisets", + ]; + SKIP_PATTERNS.iter().any(|pat| filename.contains(pat)) } /// only assert snapshot if the snapshot is non-empty @@ -299,6 +373,13 @@ impl Run { } } +fn manual_proof_disable_reason(path: &std::path::Path) -> Option<&'static str> { + MANUAL_PROOF_DISABLED_FILES + .iter() + .find(|disabled| path.ends_with(disabled.file)) + .map(|disabled| disabled.reason) +} + fn generate_tests(glob: &str) -> Vec { let mut trials = vec![]; let mut push_trial = |run: Run| trials.push(run.into_trial()); @@ -314,20 +395,8 @@ fn generate_tests(glob: &str) -> Vec { }; let should_fail = run.should_fail(); let requires_proofs = run.requires_proofs(); - // TODO: math-microbenchmark is too slow right now - // TODO: subsume.egg fails because we used a `check` on something subsumed. Need a way to run rules over subsumed things. Same with subsume-relation.egg. - let proof_unsupported_file_list = [ - "math-microbenchmark.egg", - "rectangle.egg", - "eggcc-2mm.egg", - "eqsolve.egg", - "subsume.egg", - "subsume-relation.egg", - ]; - let supports_proofs = file_supports_proofs(&run.path) - && !proof_unsupported_file_list - .iter() - .any(|f| run.path.ends_with(f)); + let proof_manually_disabled = manual_proof_disable_reason(&run.path).is_some(); + let supports_proofs = file_supports_proofs(&run.path) && !proof_manually_disabled; if !requires_proofs { push_trial(run.clone()); @@ -358,26 +427,44 @@ fn generate_tests(glob: &str) -> Vec { }); } - if !should_fail && supports_proofs { + if !should_fail + && !proof_manually_disabled + && (supports_proofs || run.is_curated_proof_integration()) + { // proof_testing mode adds automatic prove-exists, which has different output push_trial(Run { proof_testing: true, ..run.clone() }); - // Complex mode: desugar using proof encoding, then run normally. - // Yes this mode is important! It has found multiple bugs. - push_trial(Run { - proof_testing: true, - desugar: true, - ..run.clone() - }); + if supports_proofs { + // Complex mode: desugar using proof encoding, then run normally. + // Yes this mode is important! It has found multiple bugs. + push_trial(Run { + proof_testing: true, + desugar: true, + ..run.clone() + }); + } } } trials } +fn generate_manual_proof_disable_snapshot_test() -> Trial { + Trial::test("proof_manual_disabled_files", || { + let mut snapshot = MANUAL_PROOF_DISABLED_FILES + .iter() + .map(|disabled| format!("{}: {}", disabled.file, disabled.reason)) + .collect::>(); + snapshot.sort(); + insta::assert_snapshot!("proof_manual_disabled_files", snapshot.join("\n")); + + Ok(()) + }) +} + fn generate_proof_support_snapshot_test() -> Trial { Trial::test("proof_support_snapshot", || { let mut supported_files = Vec::new(); @@ -408,6 +495,7 @@ fn main() { // Add the proof support snapshot test tests.push(generate_proof_support_snapshot_test()); + tests.push(generate_manual_proof_disable_snapshot_test()); // ensure all the tests have unique names let mut names = HashSet::new(); diff --git a/egglog/tests/proofs/container-set-collapse.egg b/egglog/tests/proofs/container-set-collapse.egg new file mode 100644 index 0000000..b1e7b02 --- /dev/null +++ b/egglog/tests/proofs/container-set-collapse.egg @@ -0,0 +1,23 @@ +;; Container proof: a collapsing (Set Math). +;; +;; `(set-of (A) (B))` and `(set-of (B))` start as distinct sets, each held by a +;; `Holds` constructor. Unioning A and B collapses `{A, B}` to a singleton, so +;; the two sets (and the two `Holds` terms) become equal. +;; +;; The proof exercises the container rebuild path: a `Congr` chain rebuilds the +;; set's element to its union-find leader, producing the (non-canonical) +;; `set-of(A, A)`, and the container normalization (sort + dedup) reduces it to +;; `set-of(A)` to match the canonical value. + +(sort Math) +(constructor A () Math) +(constructor B () Math) +(sort MathSet (Set Math)) +(constructor Holds (MathSet) Math) + +(Holds (set-of (A) (B))) +(Holds (set-of (B))) +(union (A) (B)) +(run 1) + +(prove (= (Holds (set-of (A) (B))) (Holds (set-of (B))))) diff --git a/egglog/tests/proofs/rule-head-fast-path.egg b/egglog/tests/proofs/rule-head-fast-path.egg index 4ed5655..af2bb28 100644 --- a/egglog/tests/proofs/rule-head-fast-path.egg +++ b/egglog/tests/proofs/rule-head-fast-path.egg @@ -41,4 +41,4 @@ (Trigger) (run 1) -(check (= (A) (B))) +(prove (= (A) (B))) diff --git a/egglog/tests/snapshots/files__proof_integration__eqsolve_desugar_proof_testing.snap b/egglog/tests/snapshots/files__proof_integration__eqsolve_desugar_proof_testing.snap new file mode 100644 index 0000000..7063ce7 --- /dev/null +++ b/egglog/tests/snapshots/files__proof_integration__eqsolve_desugar_proof_testing.snap @@ -0,0 +1,6857 @@ +--- +source: egglog/tests/files.rs +expression: proof_snapshot +--- +(let t0 (Add (Num 6) (Neg (Var "y")))) +(let t1 (Mul (Num 3) (Var "z"))) +(let t2 (Add (Var "z") (Var "y"))) +(let t3 (Add (Var "x") (Neg (Num 2)))) +(let t4 (Mul t3 (Var "z"))) +(let t5 (Add (Num 1) (Num 2))) +(let t6 (Mul t5 (Var "z"))) +(let t7 (Mul (Num 1) (Var "z"))) +(let t8 (Mul (Num 2) (Var "z"))) +(let prf0 (Fiat (= t2 t2))) +(let prf1 + (Sym + (= (Var "z") t7) + (Rule + (= t7 (Var "z")) + (name + "(rule ((= x (Var v))) + ((union (Mul (Num 1) x) x)) + )") + (premises (Fiat (= (Var "z") (Var "z")))) + (substitution (v "z") (x (Var "z")))))) +(let t9 (Add (Num 1) (Num 1))) +(let t10 (Mul t9 (Var "z"))) +(let t11 (Add (Var "z") (Var "z"))) +(let t12 + (premises + (Congr + (= (Var "y") (Add t7 t7)) + (Congr + (= (Var "y") (Add t7 (Var "z"))) + (Sym + (= (Var "y") t11) + (Fiat (= t11 (Var "y")))) + prf1 + 0) + prf1 + 1))) +(let t13 + (substitution + (z (Num 1)) + (@rewrite_var__5 (Var "y")) + (y (Num 1)) + (x (Var "z")))) +(let prf2 + (Sym + (= (Var "y") t10) + (Rule + (= t10 (Var "y")) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t12 + t13))) +(let prf3 + (Rule + (= t9 (Num 2)) + (name "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Rule + (= t9 t9) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t12 + t13)) + (substitution (@rewrite_var__2 t9) (x 1) (y 1)))) +(let t14 + (premises + (Congr + (= t2 (Add t7 t8)) + (Congr (= t2 (Add t7 (Var "y"))) prf0 prf1 0) + (Congr (= (Var "y") t8) prf2 prf3 0) + 1))) +(let t15 (@rewrite_var__5 t2)) +(let t16 (substitution (z (Num 2)) t15 (y (Num 1)) (x (Var "z")))) +(let t17 (Add t9 (Num 1))) +(let t18 (Add (Var "y") (Var "z"))) +(let t19 (premises prf0)) +(let t20 + (premises + (Congr + (= t17 (Add (Num 2) (Num 1))) + (Rule + (= t17 t17) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + (premises + (Congr + (= t2 (Add t10 t7)) + (Congr + (= t2 (Add t10 (Var "z"))) + (Sym + (= t2 t18) + (Rule + (= t18 t2) + (name "(rewrite (Add x y) (Add y x))") + t19 + (substitution + (y (Var "y")) + (x (Var "z")) + (@rewrite_var__ t2)))) + prf2 + 0) + prf1 + 1)) + (substitution (z (Num 1)) t15 (y t9) (x (Var "z")))) + prf3 + 0))) +(let t21 (Add (Num 2) (Var "x"))) +(let t22 (Add (Var "x") (Num 2))) +(let t23 (Add t22 (Neg (Num 2)))) +(let t24 (premises (Fiat (= t22 t22)))) +(let t25 + (substitution + (z t22) + (x (Var "x")) + (y (Num 2)))) +(let prf4 + (Sym + (= (Var "x") t23) + (Rule + (= t23 (Var "x")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t24 + t25))) +(let t26 (Add (Neg (Num 2)) t22)) +(let prf5 + (Sym + (= (Neg (Num 2)) (Num -2)) + (Rule + (= (Num -2) (Neg (Num 2))) + (name + "(rewrite (Neg (Num n)) (Num (- 0 n)))") + (premises + (Rule + (= (Neg (Num 2)) (Neg (Num 2))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t24 + t25)) + (substitution + (@rewrite_var__4 (Neg (Num 2))) + (n 2))))) +(let prf6 + (Rule + (= (Num 3) t3) + (name "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t3 (Add (Num 5) (Num -2))) + (Congr + (= t3 (Add (Num 5) (Neg (Num 2)))) + (Rule + (= t3 t3) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= (Var "x") (Add t21 (Neg (Num 2)))) + prf4 + (Sym + (= t22 t21) + (Rule + (= t21 t22) + (name "(rewrite (Add x y) (Add y x))") + t24 + (substitution + (y (Num 2)) + (x (Var "x")) + (@rewrite_var__ t22)))) + 0)) + (substitution + (z (Neg (Num 2))) + (y (Var "x")) + (@rewrite_var__1 (Var "x")) + (x (Num 2)))) + (Sym + (= (Var "x") (Num 5)) + (Rule + (= (Num 5) (Var "x")) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= (Var "x") (Add (Num -2) (Num 7))) + (Congr + (= (Var "x") (Add (Num -2) t22)) + (Sym + (= (Var "x") t26) + (Rule + (= t26 (Var "x")) + (name "(rewrite (Add x y) (Add y x))") + (premises prf4) + (substitution + (y (Neg (Num 2))) + (x t22) + (@rewrite_var__ (Var "x"))))) + prf5 + 0) + (Sym (= t22 (Num 7)) (Fiat (= (Num 7) t22))) + 1)) + (substitution + (@rewrite_var__2 (Var "x")) + (x -2) + (y 7)))) + 0) + prf5 + 1)) + (substitution (@rewrite_var__2 t3) (x 5) (y -2)))) +(let prf7 (Sym (= t2 (Num 6)) (Fiat (= (Num 6) t2)))) +(let prf8 + (Rule + (= (Var "z") (Num 2)) + (name + "(rule ((= (Mul (Num x) y) (Num z)) + (= (% z x) 0)) + ((union y (Num (/ z x)))) + )") + (premises + (Trans + (= t1 (Num 6)) + (Sym + (= t1 t2) + (Congr + (= t2 t1) + (Trans + (= t2 t4) + (Sym + (= t2 t6) + (Rule + (= t6 t2) + (name "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t14 + t16)) + (Congr + (= t6 t4) + (Rule + (= t6 t6) + (name "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t14 + t16) + (Trans + (= t5 t3) + (Rule + (= t5 t17) + (name "(rewrite (Add x y) (Add y x))") + t20 + (substitution (y (Num 1)) (x (Num 2)) (@rewrite_var__ t17))) + (Trans + (= t17 t3) + (Sym + (= t17 (Num 3)) + (Rule + (= (Num 3) t17) + (name "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + t20 + (substitution (@rewrite_var__2 t17) (x 2) (y 1)))) + prf6)) + 0)) + (Sym (= t3 (Num 3)) prf6) + 0)) + prf7) + (Fiat (= 0 0))) + (substitution (z 6) (x 3) (y (Var "z"))))) +(let t27 (Add t2 (Neg (Var "y")))) +(Trans + (= (Var "z") t0) + prf8 + (Congr + (= (Num 2) t0) + (Trans + (= (Num 2) t27) + (Sym (= (Num 2) (Var "z")) prf8) + (Sym + (= (Var "z") t27) + (Rule + (= t27 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t19 + (substitution (z t2) (x (Var "z")) (y (Var "y")))))) + prf7 + 0)) +(let t0 (Add (Num 6) (Neg (Var "y")))) +(let t1 (Add (Num 2) (Num 2))) +(let t2 (Add (Var "z") (Var "z"))) +(let prf0 (Fiat (= t2 (Var "y")))) +(let prf1 (Sym (= (Var "y") t2) prf0)) +(let t3 (Add (Var "z") (Neg (Var "z")))) +(let t4 (Neg t3)) +(let t5 (Add t4 (Var "z"))) +(let t6 (Add (Var "z") t4)) +(let t7 (Add (Var "y") (Neg (Var "z")))) +(let t8 (Mul (Num 3) (Var "z"))) +(let t9 (Add (Var "z") (Var "y"))) +(let t10 (Add (Var "x") (Neg (Num 2)))) +(let t11 (Mul t10 (Var "z"))) +(let t12 (Add (Num 1) (Num 2))) +(let t13 (Mul t12 (Var "z"))) +(let t14 (Mul (Num 1) (Var "z"))) +(let t15 (Mul (Num 2) (Var "z"))) +(let prf2 (Fiat (= t9 t9))) +(let prf3 + (Sym + (= (Var "z") t14) + (Rule + (= t14 (Var "z")) + (name + "(rule ((= x (Var v))) + ((union (Mul (Num 1) x) x)) + )") + (premises (Fiat (= (Var "z") (Var "z")))) + (substitution (v "z") (x (Var "z")))))) +(let t16 (Add (Num 1) (Num 1))) +(let t17 (Mul t16 (Var "z"))) +(let t18 + (premises + (Congr + (= (Var "y") (Add t14 t14)) + (Congr + (= (Var "y") (Add t14 (Var "z"))) + prf1 + prf3 + 0) + prf3 + 1))) +(let t19 + (substitution + (z (Num 1)) + (@rewrite_var__5 (Var "y")) + (y (Num 1)) + (x (Var "z")))) +(let prf4 + (Sym + (= (Var "y") t17) + (Rule + (= t17 (Var "y")) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t18 + t19))) +(let prf5 + (Rule + (= t16 (Num 2)) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Rule + (= t16 t16) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t18 + t19)) + (substitution + (@rewrite_var__2 t16) + (x 1) + (y 1)))) +(let t20 + (premises + (Congr + (= t9 (Add t14 t15)) + (Congr (= t9 (Add t14 (Var "y"))) prf2 prf3 0) + (Congr (= (Var "y") t15) prf4 prf5 0) + 1))) +(let t21 (@rewrite_var__5 t9)) +(let t22 + (substitution + (z (Num 2)) + t21 + (y (Num 1)) + (x (Var "z")))) +(let t23 (Add t16 (Num 1))) +(let t24 (Add (Var "y") (Var "z"))) +(let t25 (premises prf2)) +(let t26 + (premises + (Congr + (= t23 (Add (Num 2) (Num 1))) + (Rule + (= t23 t23) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + (premises + (Congr + (= t9 (Add t17 t14)) + (Congr + (= t9 (Add t17 (Var "z"))) + (Sym + (= t9 t24) + (Rule + (= t24 t9) + (name + "(rewrite (Add x y) (Add y x))") + t25 + (substitution + (y (Var "y")) + (x (Var "z")) + (@rewrite_var__ t9)))) + prf4 + 0) + prf3 + 1)) + (substitution + (z (Num 1)) + t21 + (y t16) + (x (Var "z")))) + prf5 + 0))) +(let t27 (Add (Num 2) (Var "x"))) +(let t28 (Add (Var "x") (Num 2))) +(let t29 (Add t28 (Neg (Num 2)))) +(let t30 (premises (Fiat (= t28 t28)))) +(let t31 + (substitution + (z t28) + (x (Var "x")) + (y (Num 2)))) +(let prf6 + (Sym + (= (Var "x") t29) + (Rule + (= t29 (Var "x")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t30 + t31))) +(let t32 (Add (Neg (Num 2)) t28)) +(let prf7 + (Sym + (= (Neg (Num 2)) (Num -2)) + (Rule + (= (Num -2) (Neg (Num 2))) + (name + "(rewrite (Neg (Num n)) (Num (- 0 n)))") + (premises + (Rule + (= + (Neg (Num 2)) + (Neg (Num 2))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t30 + t31)) + (substitution + (@rewrite_var__4 + (Neg (Num 2))) + (n 2))))) +(let prf8 + (Rule + (= (Num 3) t10) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t10 (Add (Num 5) (Num -2))) + (Congr + (= t10 (Add (Num 5) (Neg (Num 2)))) + (Rule + (= t10 t10) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= (Var "x") (Add t27 (Neg (Num 2)))) + prf6 + (Sym + (= t28 t27) + (Rule + (= t27 t28) + (name + "(rewrite (Add x y) (Add y x))") + t30 + (substitution + (y (Num 2)) + (x (Var "x")) + (@rewrite_var__ t28)))) + 0)) + (substitution + (z (Neg (Num 2))) + (y (Var "x")) + (@rewrite_var__1 (Var "x")) + (x (Num 2)))) + (Sym + (= (Var "x") (Num 5)) + (Rule + (= (Num 5) (Var "x")) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= (Var "x") (Add (Num -2) (Num 7))) + (Congr + (= (Var "x") (Add (Num -2) t28)) + (Sym + (= (Var "x") t32) + (Rule + (= t32 (Var "x")) + (name + "(rewrite (Add x y) (Add y x))") + (premises prf6) + (substitution + (y (Neg (Num 2))) + (x t28) + (@rewrite_var__ (Var "x"))))) + prf7 + 0) + (Sym + (= t28 (Num 7)) + (Fiat (= (Num 7) t28))) + 1)) + (substitution + (@rewrite_var__2 (Var "x")) + (x -2) + (y 7)))) + 0) + prf7 + 1)) + (substitution (@rewrite_var__2 t10) (x 5) (y -2)))) +(let prf9 (Sym (= t9 (Num 6)) (Fiat (= (Num 6) t9)))) +(let prf10 + (Rule + (= (Var "z") (Num 2)) + (name + "(rule ((= (Mul (Num x) y) (Num z)) + (= (% z x) 0)) + ((union y (Num (/ z x)))) + )") + (premises + (Trans + (= t8 (Num 6)) + (Sym + (= t8 t9) + (Congr + (= t9 t8) + (Trans + (= t9 t11) + (Sym + (= t9 t13) + (Rule + (= t13 t9) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t20 + t22)) + (Congr + (= t13 t11) + (Rule + (= t13 t13) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t20 + t22) + (Trans + (= t12 t10) + (Rule + (= t12 t23) + (name "(rewrite (Add x y) (Add y x))") + t26 + (substitution + (y (Num 1)) + (x (Num 2)) + (@rewrite_var__ t23))) + (Trans + (= t23 t10) + (Sym + (= t23 (Num 3)) + (Rule + (= (Num 3) t23) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + t26 + (substitution (@rewrite_var__2 t23) (x 2) (y 1)))) + prf8)) + 0)) + (Sym (= t10 (Num 3)) prf8) + 0)) + prf9) + (Fiat (= 0 0))) + (substitution (z 6) (x 3) (y (Var "z"))))) +(let t33 (Add t9 (Neg (Var "y")))) +(let prf11 + (Congr + (= (Num 2) t0) + (Trans + (= (Num 2) t33) + (Sym (= (Num 2) (Var "z")) prf10) + (Sym + (= (Var "z") t33) + (Rule + (= t33 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t25 + (substitution (z t9) (x (Var "z")) (y (Var "y")))))) + prf9 + 0)) +(Congr + (= (Var "y") (Add t0 t0)) + (Congr + (= (Var "y") (Add t0 (Num 2))) + (Trans + (= (Var "y") t1) + prf1 + (Congr + (= t2 t1) + (Congr + (= t2 (Add (Num 2) (Var "z"))) + (Rule + (= t2 t2) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= (Var "y") (Add t5 (Var "z"))) + prf1 + (Sym + (= (Var "z") t5) + (Rule + (= t5 (Var "z")) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Sym + (= (Var "z") t6) + (Rule + (= t6 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises + (Rule + (= (Add (Var "z") t3) (Var "z")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= (Var "z") (Add t2 (Neg (Var "z")))) + (Sym + (= (Var "z") t7) + (Rule + (= t7 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf0) + (substitution + (z (Var "y")) + (x (Var "z")) + (y (Var "z"))))) + prf1 + 0)) + (substitution + (z (Neg (Var "z"))) + (y (Var "z")) + (@rewrite_var__1 (Var "z")) + (x (Var "z"))))) + (substitution (z (Var "z")) (x (Var "z")) (y t3))))) + (substitution + (y t4) + (x (Var "z")) + (@rewrite_var__ (Var "z"))))) + 0)) + (substitution + (z (Var "z")) + (y (Var "z")) + (@rewrite_var__1 (Var "y")) + (x t4))) + prf10 + 0) + prf10 + 1)) + prf11 + 0) + prf11 + 1) +(let t0 (Add (Num 12) (Neg (Var "y")))) +(let t1 (Add (Var "y") (Var "y"))) +(let t2 (Add t1 (Neg (Var "y")))) +(let t3 (Add (Var "z") (Var "y"))) +(let t4 (Add t3 (Var "z"))) +(let t5 (Add t4 (Neg (Var "y")))) +(let t6 (Add (Neg (Var "y")) t4)) +(let t7 (Add (Neg (Var "y")) t3)) +(let t8 (Add (Var "z") (Var "z"))) +(let prf0 (Fiat (= t8 (Var "y")))) +(let prf1 (Sym (= (Var "y") t8) prf0)) +(let t9 (Add t3 (Neg (Var "y")))) +(let prf2 (Fiat (= t3 t3))) +(let t10 (premises prf2)) +(let t11 (z t3)) +(let prf3 + (Sym + (= (Var "z") t9) + (Rule + (= t9 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t10 + (substitution t11 (x (Var "z")) (y (Var "y")))))) +(let t12 (y (Neg (Var "y")))) +(let t13 (x t3)) +(let prf4 + (Sym + (= (Var "z") t7) + (Rule + (= t7 (Var "z")) + (name "(rewrite (Add x y) (Add y x))") + (premises prf3) + (substitution t12 t13 (@rewrite_var__ (Var "z")))))) +(let t14 (premises (Congr (= (Var "y") (Add t7 (Var "z"))) prf1 prf4 0))) +(let t15 (y t3)) +(let t16 (x (Neg (Var "y")))) +(let t17 (substitution (z (Var "z")) t15 (@rewrite_var__1 (Var "y")) t16)) +(let prf5 + (Sym + (= (Var "y") t6) + (Rule + (= t6 (Var "y")) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t14 + t17))) +(let t18 (y t4)) +(let t19 (Add (Neg (Var "z")) (Var "z"))) +(let t20 (Add (Var "z") (Neg (Var "y")))) +(let t21 (Add t20 (Neg (Var "z")))) +(let t22 (Add (Var "y") t21)) +(let t23 (Add (Var "z") (Neg (Var "z")))) +(let t24 (Add (Var "y") (Neg (Var "z")))) +(let prf6 + (Sym + (= (Var "z") t24) + (Rule + (= t24 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf0) + (substitution + (z (Var "y")) + (x (Var "z")) + (y (Var "z")))))) +(let t25 (y (Neg (Var "z")))) +(let t26 (x (Neg (Var "z")))) +(let prf7 + (Rule + (= t23 t19) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Rule + (= t19 t19) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr (= (Var "y") (Add t24 (Var "z"))) prf1 prf6 0)) + (substitution + (z (Var "z")) + t25 + (@rewrite_var__1 (Var "y")) + (x (Var "y"))))) + (substitution (y (Var "z")) t26 (@rewrite_var__ t19)))) +(let t27 (Add (Var "y") t20)) +(let t28 + (premises + (Congr + (= (Var "z") (Add t8 (Neg (Var "z")))) + prf6 + prf1 + 0))) +(let t29 (z (Neg (Var "z")))) +(let t30 + (substitution + t29 + (y (Var "z")) + (@rewrite_var__1 (Var "z")) + (x (Var "z")))) +(let t31 (Add (Var "y") (Var "z"))) +(let prf8 + (Rule + (= t31 t3) + (name "(rewrite (Add x y) (Add y x))") + t10 + (substitution + (y (Var "y")) + (x (Var "z")) + (@rewrite_var__ t3)))) +(let prf9 (Sym (= t3 t31) prf8)) +(let t32 (z (Neg (Var "y")))) +(let t33 + (premises + (Congr + (= t23 (Add t27 (Neg (Var "z")))) + (Rule + (= t23 t23) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t28 + t30) + (Sym + (= (Var "z") t27) + (Rule + (= t27 (Var "z")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= (Var "z") (Add t31 (Neg (Var "y")))) + prf3 + prf9 + 0)) + (substitution + t32 + (y (Var "z")) + (@rewrite_var__1 (Var "z")) + (x (Var "y"))))) + 0))) +(let t34 + (substitution + t29 + (y t20) + (@rewrite_var__1 t23) + (x (Var "y")))) +(let t35 (Add (Neg (Var "z")) (Neg (Var "z")))) +(let t36 (Add (Neg (Var "z")) (Var "y"))) +(let prf10 + (Rule + (= t36 (Var "z")) + (name "(rewrite (Add x y) (Add y x))") + (premises prf6) + (substitution + t25 + (x (Var "y")) + (@rewrite_var__ (Var "z"))))) +(let prf11 + (Rule + (= t20 (Neg (Var "z"))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf10) + (substitution (z (Var "z")) t26 (y (Var "y"))))) +(let t37 (Add (Neg (Var "y")) (Var "z"))) +(let t38 (Add t37 (Neg (Var "z")))) +(let t39 (Add t3 t37)) +(let t40 + (premises + (Congr + (= (Var "y") (Add t9 (Var "z"))) + prf1 + prf3 + 0))) +(let t41 + (substitution + (z (Var "z")) + t12 + (@rewrite_var__1 (Var "y")) + t13)) +(let t42 + (premises + (Rule + (= t37 t37) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t40 + t41))) +(let t43 (Add (Var "z") t3)) +(let prf12 + (Rule + (= t4 t4) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t14 + t17)) +(let prf13 + (Rule + (= t43 t4) + (name "(rewrite (Add x y) (Add y x))") + (premises prf12) + (substitution (y (Var "z")) t13 (@rewrite_var__ t4)))) +(let t44 (@rewrite_var__1 t3)) +(let prf14 + (Rule + (= t1 t1) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t3 (Add t36 (Var "y"))) + prf2 + (Sym (= (Var "z") t36) prf10) + 0)) + (substitution (z (Var "y")) (y (Var "y")) t44 t26))) +(let t45 (@rewrite_var__1 t1)) +(let prf15 + (Rule + (= t43 t1) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t1 (Add t8 (Var "y"))) prf14 prf1 0)) + (substitution (z (Var "y")) (y (Var "z")) t45 (x (Var "z"))))) +(let prf16 (Trans (= t4 t1) (Sym (= t4 t43) prf13) prf15)) +(let t46 (Add (Var "x") (Num 2))) +(let t47 (Add t46 (Var "x"))) +(let t48 (Add t4 (Var "y"))) +(let t49 (Add t48 (Neg (Var "y")))) +(let t50 (Add (Neg (Var "y")) t48)) +(let t51 (premises (Congr (= t1 (Add t6 (Var "y"))) prf14 prf5 0))) +(let t52 (substitution (z (Var "y")) t18 t45 t16)) +(let t53 (@rewrite_var__ t1)) +(let t54 (Add t3 (Var "y"))) +(let t55 (Add (Num 2) t54)) +(let t56 (Add (Var "z") t54)) +(let prf17 (Sym (= t1 t43) prf15)) +(let t57 (Add t54 (Var "z"))) +(let t58 (Add (Neg (Var "y")) t54)) +(let t59 + (premises + (Congr (= t3 (Add t7 (Var "y"))) prf2 prf4 0))) +(let t60 (substitution (z (Var "y")) t15 t44 t16)) +(let t61 (@rewrite_var__1 t4)) +(let t62 (Mul (Num 3) (Var "z"))) +(let t63 (Add (Var "x") (Neg (Num 2)))) +(let t64 (Mul t63 (Var "z"))) +(let t65 (Add (Num 1) (Num 2))) +(let t66 (Mul t65 (Var "z"))) +(let t67 (Mul (Num 1) (Var "z"))) +(let t68 (Mul (Num 2) (Var "z"))) +(let prf18 + (Sym + (= (Var "z") t67) + (Rule + (= t67 (Var "z")) + (name + "(rule ((= x (Var v))) + ((union (Mul (Num 1) x) x)) + )") + (premises (Fiat (= (Var "z") (Var "z")))) + (substitution (v "z") (x (Var "z")))))) +(let prf19 (Congr (= t3 (Add t67 (Var "y"))) prf2 prf18 0)) +(let t69 (Add (Num 1) (Num 1))) +(let t70 (Mul t69 (Var "z"))) +(let t71 + (premises + (Congr + (= (Var "y") (Add t67 t67)) + (Congr + (= (Var "y") (Add t67 (Var "z"))) + prf1 + prf18 + 0) + prf18 + 1))) +(let t72 + (substitution + (z (Num 1)) + (@rewrite_var__5 (Var "y")) + (y (Num 1)) + (x (Var "z")))) +(let prf20 + (Sym + (= (Var "y") t70) + (Rule + (= t70 (Var "y")) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t71 + t72))) +(let prf21 + (Rule + (= t69 (Num 2)) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Rule + (= t69 t69) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t71 + t72)) + (substitution + (@rewrite_var__2 t69) + (x 1) + (y 1)))) +(let t73 + (premises + (Congr + (= t3 (Add t67 t68)) + prf19 + (Congr (= (Var "y") t68) prf20 prf21 0) + 1))) +(let t74 (@rewrite_var__5 t3)) +(let t75 + (substitution + (z (Num 2)) + t74 + (y (Num 1)) + (x (Var "z")))) +(let t76 (Add t69 (Num 1))) +(let t77 (Add (Num 2) (Num 1))) +(let t78 + (premises + (Congr + (= t76 t77) + (Rule + (= t76 t76) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + (premises + (Congr + (= t3 (Add t70 t67)) + (Congr + (= t3 (Add t70 (Var "z"))) + prf9 + prf20 + 0) + prf18 + 1)) + (substitution + (z (Num 1)) + t74 + (y t69) + (x (Var "z")))) + prf21 + 0))) +(let t79 (Add (Num 2) (Var "x"))) +(let t80 (Add t46 (Neg (Num 2)))) +(let t81 (premises (Fiat (= t46 t46)))) +(let t82 (z t46)) +(let t83 + (substitution + t82 + (x (Var "x")) + (y (Num 2)))) +(let prf22 + (Rule + (= t80 (Var "x")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t81 + t83)) +(let prf23 (Sym (= (Var "x") t80) prf22)) +(let prf24 + (Rule + (= t79 t46) + (name + "(rewrite (Add x y) (Add y x))") + t81 + (substitution + (y (Num 2)) + (x (Var "x")) + (@rewrite_var__ t46)))) +(let prf25 (Sym (= t46 t79) prf24)) +(let t84 + (premises + (Congr + (= + (Var "x") + (Add t79 (Neg (Num 2)))) + prf23 + prf25 + 0))) +(let t85 (z (Neg (Num 2)))) +(let t86 + (substitution + t85 + (y (Var "x")) + (@rewrite_var__1 (Var "x")) + (x (Num 2)))) +(let prf26 + (Rule + (= t63 t63) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t84 + t86)) +(let t87 (Add (Neg (Num 2)) t46)) +(let t88 (premises prf23)) +(let t89 (y (Neg (Num 2)))) +(let t90 (x t46)) +(let prf27 + (Sym + (= (Neg (Num 2)) (Num -2)) + (Rule + (= (Num -2) (Neg (Num 2))) + (name + "(rewrite (Neg (Num n)) (Num (- 0 n)))") + (premises + (Rule + (= + (Neg (Num 2)) + (Neg (Num 2))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t81 + t83)) + (substitution + (@rewrite_var__4 + (Neg (Num 2))) + (n 2))))) +(let prf28 + (Sym + (= t46 (Num 7)) + (Fiat (= (Num 7) t46)))) +(let prf29 + (Sym + (= (Var "x") (Num 5)) + (Rule + (= (Num 5) (Var "x")) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= + (Var "x") + (Add (Num -2) (Num 7))) + (Congr + (= (Var "x") (Add (Num -2) t46)) + (Sym + (= (Var "x") t87) + (Rule + (= t87 (Var "x")) + (name + "(rewrite (Add x y) (Add y x))") + t88 + (substitution + t89 + t90 + (@rewrite_var__ (Var "x"))))) + prf27 + 0) + prf28 + 1)) + (substitution + (@rewrite_var__2 (Var "x")) + (x -2) + (y 7))))) +(let prf30 + (Rule + (= (Num 3) t63) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t63 (Add (Num 5) (Num -2))) + (Congr + (= t63 (Add (Num 5) (Neg (Num 2)))) + prf26 + prf29 + 0) + prf27 + 1)) + (substitution + (@rewrite_var__2 t63) + (x 5) + (y -2)))) +(let prf31 (Fiat (= (Num 6) t3))) +(let prf32 + (Rule + (= (Var "z") (Num 2)) + (name + "(rule ((= (Mul (Num x) y) (Num z)) + (= (% z x) 0)) + ((union y (Num (/ z x)))) + )") + (premises + (Trans + (= t62 (Num 6)) + (Sym + (= t62 t3) + (Congr + (= t3 t62) + (Trans + (= t3 t64) + (Sym + (= t3 t66) + (Rule + (= t66 t3) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t73 + t75)) + (Congr + (= t66 t64) + (Rule + (= t66 t66) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t73 + t75) + (Trans + (= t65 t63) + (Rule + (= t65 t76) + (name "(rewrite (Add x y) (Add y x))") + t78 + (substitution + (y (Num 1)) + (x (Num 2)) + (@rewrite_var__ t76))) + (Trans + (= t76 t63) + (Sym + (= t76 (Num 3)) + (Rule + (= (Num 3) t76) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + t78 + (substitution + (@rewrite_var__2 t76) + (x 2) + (y 1)))) + prf30)) + 0)) + (Sym (= t63 (Num 3)) prf30) + 0)) + (Sym (= t3 (Num 6)) prf31)) + (Fiat (= 0 0))) + (substitution (z 6) (x 3) (y (Var "z"))))) +(let t91 (Add t46 t63)) +(let t92 (Add (Num 2) t91)) +(let t93 (Add (Neg (Var "x")) (Neg (Num 2)))) +(let t94 (Add t93 (Num 2))) +(let t95 (Add (Neg (Var "x")) t91)) +(let t96 (Add (Neg (Var "x")) t46)) +(let t97 (Add (Num 2) t63)) +(let prf33 + (Rule + (= t97 (Var "x")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t84 + t86)) +(let prf34 (Sym (= (Var "x") t97) prf33)) +(let t98 (Add t46 (Neg (Var "x")))) +(let prf35 + (Sym + (= (Num 2) t98) + (Rule + (= t98 (Num 2)) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf24) + (substitution + t82 + (x (Num 2)) + (y (Var "x")))))) +(let t99 (y (Neg (Var "x")))) +(let prf36 + (Sym + (= (Num 2) t96) + (Rule + (= t96 (Num 2)) + (name "(rewrite (Add x y) (Add y x))") + (premises prf35) + (substitution t99 t90 (@rewrite_var__ (Num 2)))))) +(let t100 + (premises + (Congr (= (Var "x") (Add t96 t63)) prf34 prf36 0))) +(let t101 (z t63)) +(let t102 (y t46)) +(let t103 (x (Neg (Var "x")))) +(let t104 + (substitution + t101 + t102 + (@rewrite_var__1 (Var "x")) + t103)) +(let t105 (Neg (Neg (Num 2)))) +(let t106 (Add t93 t105)) +(let t107 (Add (Num 2) (Neg (Num 2)))) +(let t108 + (premises + (Rule + (= t93 t93) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t107 (Add t98 (Neg (Num 2)))) + (Rule + (= t107 t107) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t88 + (substitution + t85 + (y (Num 2)) + (@rewrite_var__1 (Var "x")) + (x (Var "x")))) + prf35 + 0)) + (substitution t85 t99 (@rewrite_var__1 t107) t90)))) +(let t109 (substitution (z t93) t103 t89)) +(let t110 (Add (Num 2) t1)) +(let t111 (Add (Var "x") t63)) +(let t112 (Add (Num 2) t111)) +(let prf37 + (Rule + (= t91 t91) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t100 + t104)) +(let t113 (@rewrite_var__1 t91)) +(let t114 (Add t63 (Neg (Num 2)))) +(let t115 (Add t46 t114)) +(let t116 (Add (Var "x") t77)) +(let t117 (Add (Num 2) t114)) +(let t118 (@rewrite_var__1 t63)) +(let t119 (Add (Num 1) t69)) +(let t120 (Add t119 (Neg (Num 2)))) +(let prf38 + (Congr + (= t119 t65) + (Rule + (= t119 t119) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + (premises + (Congr + (= t3 (Add t67 t70)) + prf19 + prf20 + 1)) + (substitution + (z t69) + t74 + (y (Num 1)) + (x (Var "z")))) + prf21 + 1)) +(let t121 (premises (Sym (= t65 t119) prf38))) +(let t122 + (substitution + (z t119) + (x (Num 1)) + (y (Num 2)))) +(let t123 (premises prf38)) +(let prf39 + (Trans + (= t119 t63) + (Sym + (= t119 (Num 3)) + (Rule + (= (Num 3) t119) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + t123 + (substitution + (@rewrite_var__2 t119) + (x 1) + (y 2)))) + prf30)) +(let prf40 + (Congr + (= t115 (Add t46 (Num 1))) + (Rule + (= t115 t115) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t63 (Add t96 t114)) + (Sym + (= t63 t117) + (Rule + (= t117 t63) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t63 (Add t97 (Neg (Num 2)))) + prf26 + prf34 + 0)) + (substitution + t85 + (y t63) + t118 + (x (Num 2))))) + prf36 + 0)) + (substitution (z t114) t102 t118 t103)) + (Trans + (= t114 (Num 1)) + (Sym + (= t114 t120) + (Congr + (= t120 t114) + (Rule + (= t120 t120) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t121 + t122) + prf39 + 0)) + (Rule + (= t120 (Num 1)) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t121 + t122)) + 1)) +(let t124 (premises prf40)) +(let t125 (@rewrite_var__1 t115)) +(let t126 + (substitution + (z (Num 1)) + (y (Num 2)) + t125 + (x (Var "x")))) +(let t127 (Add (Num 2) t3)) +(let t128 (Add (Var "x") (Num 1))) +(let t129 (Add (Num 2) t128)) +(let t130 + (premises + (Congr (= t115 (Add t79 (Num 1))) prf40 prf25 0))) +(let t131 + (substitution + (z (Num 1)) + (y (Var "x")) + t125 + (x (Num 2)))) +(let t132 (Add (Num 1) (Var "x"))) +(let t133 (@rewrite_var__1 t46)) +(let prf41 + (Rule + (= t132 t132) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t46 (Add t69 (Var "x"))) + prf25 + (Sym (= (Num 2) t69) prf21) + 0)) + (substitution + (z (Var "x")) + (y (Num 1)) + t133 + (x (Num 1))))) +(let prop0 (= t1 t4)) +(let t134 (Add t19 (Var "z"))) +(let t135 (Add t3 t134)) +(let prop1 (= t135 t4)) +(let t136 (Add t3 t19)) +(let t137 (Add t3 (Neg (Var "z")))) +(let t138 + (premises + (Congr + (= t4 (Add t136 (Var "z"))) + prf12 + (Sym + (= t3 t136) + (Rule + (= t136 t3) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t3 (Add t137 (Var "z"))) + prf9 + (Sym + (= (Var "y") t137) + (Rule + (= t137 (Var "y")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf8) + (substitution + t11 + (x (Var "y")) + (y (Var "z"))))) + 0)) + (substitution + (z (Var "z")) + t25 + t44 + t13))) + 0))) +(let t139 + (substitution + (z (Var "z")) + (y t19) + t61 + t13)) +(let t140 (Add t23 (Var "z"))) +(let t141 (Add (Var "z") t23)) +(let t142 + (premises + (Sym + (= (Var "z") t141) + (Rule + (= t141 (Var "z")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t28 + t30)))) +(let t143 + (substitution + (y t23) + (x (Var "z")) + (@rewrite_var__ (Var "z")))) +(let t144 (Add (Var "z") t1)) +(let t145 (Add t4 (Var "z"))) +(let t146 (Add (Var "x") (Var "x"))) +(let t147 (Add (Num 2) t146)) +(let prf42 + (Rule + (= t47 t47) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr (= t46 (Add t96 (Var "x"))) prf25 prf36 0)) + (substitution (z (Var "x")) t102 t133 t103))) +(let t148 (Add (Var "x") t97)) +(let t149 (premises prf37)) +(let t150 (substitution t101 (y (Num 2)) t113 (x (Var "x")))) +(Congr + (= (Var "y") (Add t0 (Neg (Var "y")))) + (Trans + (= (Var "y") t2) + (Sym + (= (Var "y") t5) + (Rule + (= t5 (Var "y")) + (name "(rewrite (Add x y) (Add y x))") + (premises prf5) + (substitution t18 t16 (@rewrite_var__ (Var "y"))))) + (Congr + (= t5 t2) + (Rule + (= t5 t5) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t19 (Add t6 (Neg (Var "y")))) + (Congr + (= t19 (Add (Var "y") (Neg (Var "y")))) + (Trans + (= t19 t22) + (Sym (= t19 t23) prf7) + (Sym + (= t23 t22) + (Rule + (= t22 t23) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t33 + t34))) + (Trans + (= t21 (Neg (Var "y"))) + (Congr + (= t21 t35) + (Rule + (= t21 t21) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t33 + t34) + prf11 + 0) + (Trans + (= t35 (Neg (Var "y"))) + (Sym + (= t35 t38) + (Congr + (= t38 t35) + (Rule + (= t38 t38) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= (Var "z") (Add t39 (Neg (Var "z")))) + prf6 + (Sym + (= (Var "y") t39) + (Rule + (= t39 (Var "y")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t40 + t41)) + 0)) + (substitution + t29 + (y t37) + (@rewrite_var__1 (Var "z")) + t13)) + (Trans + (= t37 (Neg (Var "z"))) + (Sym + (= t37 t20) + (Rule + (= t20 t37) + (name "(rewrite (Add x y) (Add y x))") + t42 + (substitution + (y (Var "z")) + t16 + (@rewrite_var__ t37)))) + prf11) + 0)) + (Rule + (= t38 (Neg (Var "y"))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t42 + (substitution (z t37) t16 (y (Var "z")))))) + 1) + prf5 + 0)) + (substitution t32 t18 (@rewrite_var__1 t19) t16)) + prf16 + 0)) + (Congr + (= t1 t0) + (Congr + (= t1 (Add t47 (Neg (Var "y")))) + (Sym + (= t1 t49) + (Rule + (= t49 t1) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Sym + (= t1 t50) + (Rule + (= t50 t1) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t51 + t52))) + (substitution (y t48) t16 t53))) + (Trans + (= t48 t47) + (Trans + (= t48 t55) + (Sym + (= t48 t56) + (Rule + (= t56 t48) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t48 (Add t43 (Var "y"))) + (Congr + (= t48 (Add t1 (Var "y"))) + (Rule + (= t48 t48) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t51 + t52) + prf16 + 0) + prf17 + 0)) + (substitution + (z (Var "y")) + t15 + (@rewrite_var__1 t48) + (x (Var "z"))))) + (Congr + (= t56 t55) + (Rule + (= t56 t56) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Rule + (= t57 t57) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t4 (Add t58 (Var "z"))) + prf12 + (Sym + (= t3 t58) + (Rule + (= t58 t3) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t59 + t60)) + 0)) + (substitution (z (Var "z")) (y t54) t61 t16))) + (substitution (y (Var "z")) (x t54) (@rewrite_var__ t57))) + prf32 + 0)) + (Trans + (= t55 t47) + (Sym + (= t55 t92) + (Congr + (= t92 t55) + (Rule + (= t92 t92) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= (Var "x") (Add t94 t91)) + (Sym + (= (Var "x") t95) + (Rule + (= t95 (Var "x")) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t100 + t104)) + (Trans + (= (Neg (Var "x")) t94) + (Sym + (= (Neg (Var "x")) t106) + (Rule + (= t106 (Neg (Var "x"))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t108 + t109)) + (Congr + (= t106 t94) + (Rule + (= t106 t106) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t108 + t109) + (Rule + (= t105 (Num 2)) + (name "(rewrite (Neg (Neg x)) x)") + (premises + (Rule + (= t105 t105) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf22) + (substitution (z (Var "x")) t90 t89))) + (substitution (x (Num 2)) (@rewrite_var__3 t105))) + 1)) + 0)) + (substitution + (z t91) + (y (Num 2)) + (@rewrite_var__1 (Var "x")) + (x t93))) + (Trans + (= t91 t54) + (Congr + (= t91 t110) + (Sym + (= t91 t112) + (Rule + (= t112 t91) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t91 (Add t79 t63)) prf37 prf25 0)) + (substitution t101 (y (Var "x")) t113 (x (Num 2))))) + (Trans + (= t111 t1) + (Trans + (= t111 t115) + (Sym + (= t111 t116) + (Congr + (= t116 t111) + (Rule + (= t116 t116) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t124 + t126) + (Trans + (= t77 t63) + (Rule + (= t77 t119) + (name "(rewrite (Add x y) (Add y x))") + t123 + (substitution + (y (Num 2)) + (x (Num 1)) + (@rewrite_var__ t119))) + prf39) + 1)) + (Rule + (= t116 t115) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t124 + t126)) + (Trans + (= t115 t1) + (Trans + (= t115 t127) + (Sym + (= t115 t129) + (Rule + (= t129 t115) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t130 + t131)) + (Congr + (= t129 t127) + (Rule + (= t129 t129) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t130 + t131) + (Trans + (= t128 t3) + (Trans + (= t128 (Num 6)) + (Rule + (= t128 t132) + (name "(rewrite (Add x y) (Add y x))") + (premises prf41) + (substitution + (y (Var "x")) + (x (Num 1)) + (@rewrite_var__ t132))) + (Rule + (= t132 (Num 6)) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t132 (Add (Num 1) (Num 5))) + prf41 + prf29 + 1)) + (substitution + (@rewrite_var__2 t132) + (x 1) + (y 5)))) + prf31) + 1)) + (Trans + (= t127 t1) + (Sym + (= t127 t43) + (Congr + (= t43 t127) + (Rule + (= t43 t43) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Trans + prop0 + (Trans + (= t1 t135) + (Trans prop0 prf17 prf13) + (Sym + (= t4 t135) + (Rule + prop1 + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t138 + t139))) + (Congr + prop1 + (Rule + (= t135 t135) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t138 + t139) + (Trans + (= t134 (Var "z")) + (Sym + (= t134 t140) + (Congr + (= t140 t134) + (Rule + (= t140 t140) + (name + "(rewrite (Add x y) (Add y x))") + t142 + t143) + prf7 + 0)) + (Rule + (= t140 (Var "z")) + (name "(rewrite (Add x y) (Add y x))") + t142 + t143)) + 1))) + (substitution (y (Var "z")) t13 t53)) + prf32 + 0)) + prf15))) + 1) + (Trans + (= t110 t54) + (Sym + (= t110 t144) + (Congr + (= t144 t110) + (Rule + (= t144 t144) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Congr + (= t145 (Add t1 (Var "z"))) + (Rule + (= t145 t145) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr (= t3 (Add t6 (Var "z"))) prf9 prf5 0)) + (substitution (z (Var "z")) t18 t44 t16)) + prf16 + 0)) + (substitution + (y (Var "z")) + (x t1) + (@rewrite_var__ t145))) + prf32 + 0)) + (Rule + (= t144 t54) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Rule + (= t54 t54) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t59 + t60)) + (substitution + (z (Var "y")) + (y (Var "y")) + (@rewrite_var__1 t54) + (x (Var "z")))))) + 1)) + (Sym + (= t92 t47) + (Congr + (= t47 t92) + (Sym + (= t47 t147) + (Rule + (= t147 t47) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t47 (Add t79 (Var "x"))) prf42 prf25 0)) + (substitution + (z (Var "x")) + (y (Var "x")) + (@rewrite_var__1 t47) + (x (Num 2))))) + (Trans + (= t146 t91) + (Sym + (= t146 t148) + (Congr + (= t148 t146) + (Rule + (= t148 t148) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t149 + t150) + prf33 + 1)) + (Rule + (= t148 t91) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t149 + t150)) + 1)))) + 0) + (Sym + (= t47 (Num 12)) + (Rule + (= (Num 12) t47) + (name "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t47 (Add (Num 7) (Num 5))) + (Congr (= t47 (Add (Num 7) (Var "x"))) prf42 prf28 0) + prf29 + 1)) + (substitution (@rewrite_var__2 t47) (x 7) (y 5)))) + 0) + 0) +(let t0 (Add (Var "y") (Var "y"))) +(let t1 (Add (Var "x") (Num 2))) +(let t2 (Add t1 (Var "x"))) +(let t3 (Add (Var "z") (Var "y"))) +(let t4 (Add t3 (Var "z"))) +(let t5 (Add t4 (Var "y"))) +(let t6 (Add t5 (Neg (Var "y")))) +(let t7 (Add (Neg (Var "y")) t5)) +(let t8 (Add (Neg (Var "y")) t4)) +(let t9 (Add (Neg (Var "z")) (Var "y"))) +(let prf0 (Fiat (= t3 t3))) +(let t10 (Add (Var "y") (Neg (Var "z")))) +(let t11 (Add (Var "z") (Var "z"))) +(let prf1 (Fiat (= t11 (Var "y")))) +(let prf2 + (Sym + (= (Var "z") t10) + (Rule + (= t10 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf1) + (substitution + (z (Var "y")) + (x (Var "z")) + (y (Var "z")))))) +(let t12 (y (Neg (Var "z")))) +(let t13 (@rewrite_var__1 t3)) +(let t14 (x (Neg (Var "z")))) +(let prf3 + (Rule + (= t0 t0) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t3 (Add t9 (Var "y"))) + prf0 + (Sym + (= (Var "z") t9) + (Rule + (= t9 (Var "z")) + (name "(rewrite (Add x y) (Add y x))") + (premises prf2) + (substitution + t12 + (x (Var "y")) + (@rewrite_var__ (Var "z"))))) + 0)) + (substitution (z (Var "y")) (y (Var "y")) t13 t14))) +(let t15 (Add (Neg (Var "y")) t3)) +(let prf4 (Sym (= (Var "y") t11) prf1)) +(let t16 (Add t3 (Neg (Var "y")))) +(let t17 (premises prf0)) +(let t18 (z t3)) +(let t19 (x t3)) +(let prf5 + (Sym + (= (Var "z") t15) + (Rule + (= t15 (Var "z")) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Sym + (= (Var "z") t16) + (Rule + (= t16 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t17 + (substitution + t18 + (x (Var "z")) + (y (Var "y")))))) + (substitution + (y (Neg (Var "y"))) + t19 + (@rewrite_var__ (Var "z")))))) +(let t20 + (premises + (Congr (= (Var "y") (Add t15 (Var "z"))) prf4 prf5 0))) +(let t21 (y t3)) +(let t22 (x (Neg (Var "y")))) +(let t23 + (substitution + (z (Var "z")) + t21 + (@rewrite_var__1 (Var "y")) + t22)) +(let prf6 + (Sym + (= (Var "y") t8) + (Rule + (= t8 (Var "y")) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t20 + t23))) +(let t24 (premises (Congr (= t0 (Add t8 (Var "y"))) prf3 prf6 0))) +(let t25 (y t4)) +(let t26 (@rewrite_var__1 t0)) +(let t27 (substitution (z (Var "y")) t25 t26 t22)) +(let t28 (@rewrite_var__ t0)) +(let t29 (Add t3 (Var "y"))) +(let t30 (Add (Num 2) t29)) +(let t31 (Add (Var "z") t29)) +(let t32 (Add (Var "z") t3)) +(let prf7 + (Rule + (= t4 t4) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t20 + t23)) +(let prf8 + (Rule + (= t32 t4) + (name "(rewrite (Add x y) (Add y x))") + (premises prf7) + (substitution (y (Var "z")) t19 (@rewrite_var__ t4)))) +(let prf9 + (Rule + (= t32 t0) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t0 (Add t11 (Var "y"))) prf3 prf4 0)) + (substitution + (z (Var "y")) + (y (Var "z")) + t26 + (x (Var "z"))))) +(let prf10 (Trans (= t4 t0) (Sym (= t4 t32) prf8) prf9)) +(let prf11 (Sym (= t0 t32) prf9)) +(let t33 (Add t29 (Var "z"))) +(let t34 (Add (Neg (Var "y")) t29)) +(let t35 + (premises + (Congr (= t3 (Add t15 (Var "y"))) prf0 prf5 0))) +(let t36 (substitution (z (Var "y")) t21 t13 t22)) +(let t37 (@rewrite_var__1 t4)) +(let t38 (Mul (Num 3) (Var "z"))) +(let t39 (Add (Var "x") (Neg (Num 2)))) +(let t40 (Mul t39 (Var "z"))) +(let t41 (Add (Num 1) (Num 2))) +(let t42 (Mul t41 (Var "z"))) +(let t43 (Mul (Num 1) (Var "z"))) +(let t44 (Mul (Num 2) (Var "z"))) +(let prf12 + (Sym + (= (Var "z") t43) + (Rule + (= t43 (Var "z")) + (name + "(rule ((= x (Var v))) + ((union (Mul (Num 1) x) x)) + )") + (premises (Fiat (= (Var "z") (Var "z")))) + (substitution (v "z") (x (Var "z")))))) +(let prf13 (Congr (= t3 (Add t43 (Var "y"))) prf0 prf12 0)) +(let t45 (Add (Num 1) (Num 1))) +(let t46 (Mul t45 (Var "z"))) +(let t47 + (premises + (Congr + (= (Var "y") (Add t43 t43)) + (Congr + (= (Var "y") (Add t43 (Var "z"))) + prf4 + prf12 + 0) + prf12 + 1))) +(let t48 + (substitution + (z (Num 1)) + (@rewrite_var__5 (Var "y")) + (y (Num 1)) + (x (Var "z")))) +(let prf14 + (Sym + (= (Var "y") t46) + (Rule + (= t46 (Var "y")) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t47 + t48))) +(let prf15 + (Rule + (= t45 (Num 2)) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Rule + (= t45 t45) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t47 + t48)) + (substitution + (@rewrite_var__2 t45) + (x 1) + (y 1)))) +(let t49 + (premises + (Congr + (= t3 (Add t43 t44)) + prf13 + (Congr (= (Var "y") t44) prf14 prf15 0) + 1))) +(let t50 (@rewrite_var__5 t3)) +(let t51 + (substitution + (z (Num 2)) + t50 + (y (Num 1)) + (x (Var "z")))) +(let t52 (Add t45 (Num 1))) +(let t53 (Add (Num 2) (Num 1))) +(let t54 (Add (Var "y") (Var "z"))) +(let prf16 + (Rule + (= t54 t3) + (name + "(rewrite (Add x y) (Add y x))") + t17 + (substitution + (y (Var "y")) + (x (Var "z")) + (@rewrite_var__ t3)))) +(let prf17 (Sym (= t3 t54) prf16)) +(let t55 + (premises + (Congr + (= t52 t53) + (Rule + (= t52 t52) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + (premises + (Congr + (= t3 (Add t46 t43)) + (Congr + (= t3 (Add t46 (Var "z"))) + prf17 + prf14 + 0) + prf12 + 1)) + (substitution + (z (Num 1)) + t50 + (y t45) + (x (Var "z")))) + prf15 + 0))) +(let t56 (Add (Num 2) (Var "x"))) +(let t57 (Add t1 (Neg (Num 2)))) +(let t58 (premises (Fiat (= t1 t1)))) +(let t59 (z t1)) +(let t60 + (substitution + t59 + (x (Var "x")) + (y (Num 2)))) +(let prf18 + (Rule + (= t57 (Var "x")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t58 + t60)) +(let prf19 (Sym (= (Var "x") t57) prf18)) +(let prf20 + (Rule + (= t56 t1) + (name + "(rewrite (Add x y) (Add y x))") + t58 + (substitution + (y (Num 2)) + (x (Var "x")) + (@rewrite_var__ t1)))) +(let prf21 (Sym (= t1 t56) prf20)) +(let t61 + (premises + (Congr + (= (Var "x") (Add t56 (Neg (Num 2)))) + prf19 + prf21 + 0))) +(let t62 (z (Neg (Num 2)))) +(let t63 + (substitution + t62 + (y (Var "x")) + (@rewrite_var__1 (Var "x")) + (x (Num 2)))) +(let prf22 + (Rule + (= t39 t39) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t61 + t63)) +(let t64 (Add (Neg (Num 2)) t1)) +(let t65 (premises prf19)) +(let t66 (y (Neg (Num 2)))) +(let t67 (x t1)) +(let prf23 + (Sym + (= (Neg (Num 2)) (Num -2)) + (Rule + (= (Num -2) (Neg (Num 2))) + (name + "(rewrite (Neg (Num n)) (Num (- 0 n)))") + (premises + (Rule + (= + (Neg (Num 2)) + (Neg (Num 2))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t58 + t60)) + (substitution + (@rewrite_var__4 + (Neg (Num 2))) + (n 2))))) +(let prf24 + (Sym + (= t1 (Num 7)) + (Fiat (= (Num 7) t1)))) +(let prf25 + (Sym + (= (Var "x") (Num 5)) + (Rule + (= (Num 5) (Var "x")) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= (Var "x") (Add (Num -2) (Num 7))) + (Congr + (= (Var "x") (Add (Num -2) t1)) + (Sym + (= (Var "x") t64) + (Rule + (= t64 (Var "x")) + (name + "(rewrite (Add x y) (Add y x))") + t65 + (substitution + t66 + t67 + (@rewrite_var__ (Var "x"))))) + prf23 + 0) + prf24 + 1)) + (substitution + (@rewrite_var__2 (Var "x")) + (x -2) + (y 7))))) +(let prf26 + (Rule + (= (Num 3) t39) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t39 (Add (Num 5) (Num -2))) + (Congr + (= t39 (Add (Num 5) (Neg (Num 2)))) + prf22 + prf25 + 0) + prf23 + 1)) + (substitution (@rewrite_var__2 t39) (x 5) (y -2)))) +(let prf27 (Fiat (= (Num 6) t3))) +(let prf28 + (Rule + (= (Var "z") (Num 2)) + (name + "(rule ((= (Mul (Num x) y) (Num z)) + (= (% z x) 0)) + ((union y (Num (/ z x)))) + )") + (premises + (Trans + (= t38 (Num 6)) + (Sym + (= t38 t3) + (Congr + (= t3 t38) + (Trans + (= t3 t40) + (Sym + (= t3 t42) + (Rule + (= t42 t3) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t49 + t51)) + (Congr + (= t42 t40) + (Rule + (= t42 t42) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t49 + t51) + (Trans + (= t41 t39) + (Rule + (= t41 t52) + (name "(rewrite (Add x y) (Add y x))") + t55 + (substitution + (y (Num 1)) + (x (Num 2)) + (@rewrite_var__ t52))) + (Trans + (= t52 t39) + (Sym + (= t52 (Num 3)) + (Rule + (= (Num 3) t52) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + t55 + (substitution (@rewrite_var__2 t52) (x 2) (y 1)))) + prf26)) + 0)) + (Sym (= t39 (Num 3)) prf26) + 0)) + (Sym (= t3 (Num 6)) prf27)) + (Fiat (= 0 0))) + (substitution (z 6) (x 3) (y (Var "z"))))) +(let t68 (Add t1 t39)) +(let t69 (Add (Num 2) t68)) +(let t70 (Add (Neg (Var "x")) (Neg (Num 2)))) +(let t71 (Add t70 (Num 2))) +(let t72 (Add (Neg (Var "x")) t68)) +(let t73 (Add (Neg (Var "x")) t1)) +(let t74 (Add (Num 2) t39)) +(let prf29 + (Rule + (= t74 (Var "x")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t61 + t63)) +(let prf30 (Sym (= (Var "x") t74) prf29)) +(let t75 (Add t1 (Neg (Var "x")))) +(let prf31 + (Sym + (= (Num 2) t75) + (Rule + (= t75 (Num 2)) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf20) + (substitution t59 (x (Num 2)) (y (Var "x")))))) +(let t76 (y (Neg (Var "x")))) +(let prf32 + (Sym + (= (Num 2) t73) + (Rule + (= t73 (Num 2)) + (name "(rewrite (Add x y) (Add y x))") + (premises prf31) + (substitution t76 t67 (@rewrite_var__ (Num 2)))))) +(let t77 + (premises + (Congr (= (Var "x") (Add t73 t39)) prf30 prf32 0))) +(let t78 (z t39)) +(let t79 (y t1)) +(let t80 (x (Neg (Var "x")))) +(let t81 (substitution t78 t79 (@rewrite_var__1 (Var "x")) t80)) +(let t82 (Neg (Neg (Num 2)))) +(let t83 (Add t70 t82)) +(let t84 (Add (Num 2) (Neg (Num 2)))) +(let t85 + (premises + (Rule + (= t70 t70) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t84 (Add t75 (Neg (Num 2)))) + (Rule + (= t84 t84) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t65 + (substitution + t62 + (y (Num 2)) + (@rewrite_var__1 (Var "x")) + (x (Var "x")))) + prf31 + 0)) + (substitution t62 t76 (@rewrite_var__1 t84) t67)))) +(let t86 (substitution (z t70) t80 t66)) +(let t87 (Add (Num 2) t0)) +(let t88 (Add (Var "x") t39)) +(let t89 (Add (Num 2) t88)) +(let prf33 + (Rule + (= t68 t68) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t77 + t81)) +(let t90 (@rewrite_var__1 t68)) +(let t91 (Add t39 (Neg (Num 2)))) +(let t92 (Add t1 t91)) +(let t93 (Add (Var "x") t53)) +(let t94 (Add (Num 2) t91)) +(let t95 (@rewrite_var__1 t39)) +(let t96 (Add (Num 1) t45)) +(let t97 (Add t96 (Neg (Num 2)))) +(let prf34 + (Congr + (= t96 t41) + (Rule + (= t96 t96) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + (premises + (Congr + (= t3 (Add t43 t46)) + prf13 + prf14 + 1)) + (substitution + (z t45) + t50 + (y (Num 1)) + (x (Var "z")))) + prf15 + 1)) +(let t98 (premises (Sym (= t41 t96) prf34))) +(let t99 + (substitution + (z t96) + (x (Num 1)) + (y (Num 2)))) +(let t100 (premises prf34)) +(let prf35 + (Trans + (= t96 t39) + (Sym + (= t96 (Num 3)) + (Rule + (= (Num 3) t96) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + t100 + (substitution + (@rewrite_var__2 t96) + (x 1) + (y 2)))) + prf26)) +(let prf36 + (Congr + (= t92 (Add t1 (Num 1))) + (Rule + (= t92 t92) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t39 (Add t73 t91)) + (Sym + (= t39 t94) + (Rule + (= t94 t39) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t39 (Add t74 (Neg (Num 2)))) + prf22 + prf30 + 0)) + (substitution + t62 + (y t39) + t95 + (x (Num 2))))) + prf32 + 0)) + (substitution (z t91) t79 t95 t80)) + (Trans + (= t91 (Num 1)) + (Sym + (= t91 t97) + (Congr + (= t97 t91) + (Rule + (= t97 t97) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t98 + t99) + prf35 + 0)) + (Rule + (= t97 (Num 1)) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t98 + t99)) + 1)) +(let t101 (premises prf36)) +(let t102 (@rewrite_var__1 t92)) +(let t103 + (substitution + (z (Num 1)) + (y (Num 2)) + t102 + (x (Var "x")))) +(let t104 (Add (Num 2) t3)) +(let t105 (Add (Var "x") (Num 1))) +(let t106 (Add (Num 2) t105)) +(let t107 + (premises + (Congr (= t92 (Add t56 (Num 1))) prf36 prf21 0))) +(let t108 + (substitution + (z (Num 1)) + (y (Var "x")) + t102 + (x (Num 2)))) +(let t109 (Add (Num 1) (Var "x"))) +(let t110 (@rewrite_var__1 t1)) +(let prf37 + (Rule + (= t109 t109) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t1 (Add t45 (Var "x"))) + prf21 + (Sym (= (Num 2) t45) prf15) + 0)) + (substitution + (z (Var "x")) + (y (Num 1)) + t110 + (x (Num 1))))) +(let prop0 (= t0 t4)) +(let t111 (Add (Neg (Var "z")) (Var "z"))) +(let t112 (Add t111 (Var "z"))) +(let t113 (Add t3 t112)) +(let prop1 (= t113 t4)) +(let t114 (Add t3 t111)) +(let t115 (Add t3 (Neg (Var "z")))) +(let t116 + (premises + (Congr + (= t4 (Add t114 (Var "z"))) + prf7 + (Sym + (= t3 t114) + (Rule + (= t114 t3) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t3 (Add t115 (Var "z"))) + prf17 + (Sym + (= (Var "y") t115) + (Rule + (= t115 (Var "y")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf16) + (substitution + t18 + (x (Var "y")) + (y (Var "z"))))) + 0)) + (substitution + (z (Var "z")) + t12 + t13 + t19))) + 0))) +(let t117 + (substitution + (z (Var "z")) + (y t111) + t37 + t19)) +(let t118 (Add (Var "z") (Neg (Var "z")))) +(let t119 (Add t118 (Var "z"))) +(let t120 (Add (Var "z") t118)) +(let t121 + (premises + (Sym + (= (Var "z") t120) + (Rule + (= t120 (Var "z")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= + (Var "z") + (Add t11 (Neg (Var "z")))) + prf2 + prf4 + 0)) + (substitution + (z (Neg (Var "z"))) + (y (Var "z")) + (@rewrite_var__1 (Var "z")) + (x (Var "z"))))))) +(let t122 + (substitution + (y t118) + (x (Var "z")) + (@rewrite_var__ (Var "z")))) +(let t123 (Add (Var "z") t0)) +(let t124 (Add t4 (Var "z"))) +(let t125 (Add (Var "x") (Var "x"))) +(let t126 (Add (Num 2) t125)) +(let prf38 + (Rule + (= t2 t2) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr (= t1 (Add t73 (Var "x"))) prf21 prf32 0)) + (substitution (z (Var "x")) t79 t110 t80))) +(let t127 (Add (Var "x") t74)) +(let t128 (premises prf33)) +(let t129 (substitution t78 (y (Num 2)) t90 (x (Var "x")))) +(Congr + (= t0 (Add (Num 12) (Neg (Var "y")))) + (Congr + (= t0 (Add t2 (Neg (Var "y")))) + (Sym + (= t0 t6) + (Rule + (= t6 t0) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Sym + (= t0 t7) + (Rule + (= t7 t0) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t24 + t27))) + (substitution (y t5) t22 t28))) + (Trans + (= t5 t2) + (Trans + (= t5 t30) + (Sym + (= t5 t31) + (Rule + (= t31 t5) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t5 (Add t32 (Var "y"))) + (Congr + (= t5 (Add t0 (Var "y"))) + (Rule + (= t5 t5) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t24 + t27) + prf10 + 0) + prf11 + 0)) + (substitution (z (Var "y")) t21 (@rewrite_var__1 t5) (x (Var "z"))))) + (Congr + (= t31 t30) + (Rule + (= t31 t31) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Rule + (= t33 t33) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t4 (Add t34 (Var "z"))) + prf7 + (Sym + (= t3 t34) + (Rule + (= t34 t3) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t35 + t36)) + 0)) + (substitution (z (Var "z")) (y t29) t37 t22))) + (substitution (y (Var "z")) (x t29) (@rewrite_var__ t33))) + prf28 + 0)) + (Trans + (= t30 t2) + (Sym + (= t30 t69) + (Congr + (= t69 t30) + (Rule + (= t69 t69) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= (Var "x") (Add t71 t68)) + (Sym + (= (Var "x") t72) + (Rule + (= t72 (Var "x")) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t77 + t81)) + (Trans + (= (Neg (Var "x")) t71) + (Sym + (= (Neg (Var "x")) t83) + (Rule + (= t83 (Neg (Var "x"))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t85 + t86)) + (Congr + (= t83 t71) + (Rule + (= t83 t83) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t85 + t86) + (Rule + (= t82 (Num 2)) + (name "(rewrite (Neg (Neg x)) x)") + (premises + (Rule + (= t82 t82) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf18) + (substitution (z (Var "x")) t67 t66))) + (substitution (x (Num 2)) (@rewrite_var__3 t82))) + 1)) + 0)) + (substitution + (z t68) + (y (Num 2)) + (@rewrite_var__1 (Var "x")) + (x t70))) + (Trans + (= t68 t29) + (Congr + (= t68 t87) + (Sym + (= t68 t89) + (Rule + (= t89 t68) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t68 (Add t56 t39)) prf33 prf21 0)) + (substitution t78 (y (Var "x")) t90 (x (Num 2))))) + (Trans + (= t88 t0) + (Trans + (= t88 t92) + (Sym + (= t88 t93) + (Congr + (= t93 t88) + (Rule + (= t93 t93) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t101 + t103) + (Trans + (= t53 t39) + (Rule + (= t53 t96) + (name "(rewrite (Add x y) (Add y x))") + t100 + (substitution + (y (Num 2)) + (x (Num 1)) + (@rewrite_var__ t96))) + prf35) + 1)) + (Rule + (= t93 t92) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t101 + t103)) + (Trans + (= t92 t0) + (Trans + (= t92 t104) + (Sym + (= t92 t106) + (Rule + (= t106 t92) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t107 + t108)) + (Congr + (= t106 t104) + (Rule + (= t106 t106) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t107 + t108) + (Trans + (= t105 t3) + (Trans + (= t105 (Num 6)) + (Rule + (= t105 t109) + (name "(rewrite (Add x y) (Add y x))") + (premises prf37) + (substitution + (y (Var "x")) + (x (Num 1)) + (@rewrite_var__ t109))) + (Rule + (= t109 (Num 6)) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t109 (Add (Num 1) (Num 5))) + prf37 + prf25 + 1)) + (substitution (@rewrite_var__2 t109) (x 1) (y 5)))) + prf27) + 1)) + (Trans + (= t104 t0) + (Sym + (= t104 t32) + (Congr + (= t32 t104) + (Rule + (= t32 t32) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Trans + prop0 + (Trans + (= t0 t113) + (Trans prop0 prf11 prf8) + (Sym + (= t4 t113) + (Rule + prop1 + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t116 + t117))) + (Congr + prop1 + (Rule + (= t113 t113) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t116 + t117) + (Trans + (= t112 (Var "z")) + (Sym + (= t112 t119) + (Congr + (= t119 t112) + (Rule + (= t119 t119) + (name "(rewrite (Add x y) (Add y x))") + t121 + t122) + (Rule + (= t118 t111) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Rule + (= t111 t111) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= + (Var "y") + (Add t10 (Var "z"))) + prf4 + prf2 + 0)) + (substitution + (z (Var "z")) + t12 + (@rewrite_var__1 (Var "y")) + (x (Var "y"))))) + (substitution + (y (Var "z")) + t14 + (@rewrite_var__ t111))) + 0)) + (Rule + (= t119 (Var "z")) + (name "(rewrite (Add x y) (Add y x))") + t121 + t122)) + 1))) + (substitution (y (Var "z")) t19 t28)) + prf28 + 0)) + prf9))) + 1) + (Trans + (= t87 t29) + (Sym + (= t87 t123) + (Congr + (= t123 t87) + (Rule + (= t123 t123) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Congr + (= t124 (Add t0 (Var "z"))) + (Rule + (= t124 t124) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr (= t3 (Add t8 (Var "z"))) prf17 prf6 0)) + (substitution (z (Var "z")) t25 t13 t22)) + prf10 + 0)) + (substitution (y (Var "z")) (x t0) (@rewrite_var__ t124))) + prf28 + 0)) + (Rule + (= t123 t29) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Rule + (= t29 t29) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t35 + t36)) + (substitution + (z (Var "y")) + (y (Var "y")) + (@rewrite_var__1 t29) + (x (Var "z")))))) + 1)) + (Sym + (= t69 t2) + (Congr + (= t2 t69) + (Sym + (= t2 t126) + (Rule + (= t126 t2) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t2 (Add t56 (Var "x"))) prf38 prf21 0)) + (substitution + (z (Var "x")) + (y (Var "x")) + (@rewrite_var__1 t2) + (x (Num 2))))) + (Trans + (= t125 t68) + (Sym + (= t125 t127) + (Congr + (= t127 t125) + (Rule + (= t127 t127) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t128 + t129) + prf29 + 1)) + (Rule + (= t127 t68) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t128 + t129)) + 1)))) + 0) + (Sym + (= t2 (Num 12)) + (Rule + (= (Num 12) t2) + (name "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t2 (Add (Num 7) (Num 5))) + (Congr (= t2 (Add (Num 7) (Var "x"))) prf38 prf24 0) + prf25 + 1)) + (substitution (@rewrite_var__2 t2) (x 7) (y 5)))) + 0) +(let t0 (Add (Var "y") (Var "y"))) +(let t1 (Add t0 (Var "y"))) +(let t2 (Add (Var "x") (Num 2))) +(let t3 (Add t2 (Var "x"))) +(let t4 (Add (Var "z") (Var "y"))) +(let t5 (Add t4 (Var "z"))) +(let t6 (Add t5 (Var "y"))) +(let t7 (Add (Neg (Var "y")) t5)) +(let t8 (Add (Neg (Var "z")) (Var "y"))) +(let prf0 (Fiat (= t4 t4))) +(let t9 (Add (Var "y") (Neg (Var "z")))) +(let t10 (Add (Var "z") (Var "z"))) +(let prf1 (Fiat (= t10 (Var "y")))) +(let prf2 + (Sym + (= (Var "z") t9) + (Rule + (= t9 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf1) + (substitution + (z (Var "y")) + (x (Var "z")) + (y (Var "z")))))) +(let t11 (y (Neg (Var "z")))) +(let t12 (@rewrite_var__1 t4)) +(let t13 (x (Neg (Var "z")))) +(let prf3 + (Rule + (= t0 t0) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t4 (Add t8 (Var "y"))) + prf0 + (Sym + (= (Var "z") t8) + (Rule + (= t8 (Var "z")) + (name "(rewrite (Add x y) (Add y x))") + (premises prf2) + (substitution + t11 + (x (Var "y")) + (@rewrite_var__ (Var "z"))))) + 0)) + (substitution (z (Var "y")) (y (Var "y")) t12 t13))) +(let t14 (Add (Neg (Var "y")) t4)) +(let prf4 (Sym (= (Var "y") t10) prf1)) +(let t15 (Add t4 (Neg (Var "y")))) +(let t16 (premises prf0)) +(let t17 (z t4)) +(let t18 (x t4)) +(let prf5 + (Sym + (= (Var "z") t14) + (Rule + (= t14 (Var "z")) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Sym + (= (Var "z") t15) + (Rule + (= t15 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t16 + (substitution t17 (x (Var "z")) (y (Var "y")))))) + (substitution + (y (Neg (Var "y"))) + t18 + (@rewrite_var__ (Var "z")))))) +(let t19 + (premises + (Congr (= (Var "y") (Add t14 (Var "z"))) prf4 prf5 0))) +(let t20 (y t4)) +(let t21 (x (Neg (Var "y")))) +(let t22 + (substitution + (z (Var "z")) + t20 + (@rewrite_var__1 (Var "y")) + t21)) +(let prf6 + (Sym + (= (Var "y") t7) + (Rule + (= t7 (Var "y")) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t19 + t22))) +(let t23 (y t5)) +(let t24 (@rewrite_var__1 t0)) +(let t25 (Add (Var "z") t4)) +(let prf7 + (Rule + (= t5 t5) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t19 + t22)) +(let prf8 + (Rule + (= t25 t5) + (name "(rewrite (Add x y) (Add y x))") + (premises prf7) + (substitution (y (Var "z")) t18 (@rewrite_var__ t5)))) +(let prf9 + (Rule + (= t25 t0) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t0 (Add t10 (Var "y"))) prf3 prf4 0)) + (substitution (z (Var "y")) (y (Var "z")) t24 (x (Var "z"))))) +(let prf10 (Trans (= t5 t0) (Sym (= t5 t25) prf8) prf9)) +(let prf11 + (Congr + (= t6 t1) + (Rule + (= t6 t6) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t0 (Add t7 (Var "y"))) prf3 prf6 0)) + (substitution (z (Var "y")) t23 t24 t21)) + prf10 + 0)) +(let t26 (Add t4 (Var "y"))) +(let t27 (Add (Num 2) t26)) +(let t28 (Add (Var "z") t26)) +(let prf12 (Sym (= t0 t25) prf9)) +(let t29 (Add t26 (Var "z"))) +(let t30 (Add (Neg (Var "y")) t26)) +(let t31 + (premises + (Congr (= t4 (Add t14 (Var "y"))) prf0 prf5 0))) +(let t32 (substitution (z (Var "y")) t20 t12 t21)) +(let t33 (@rewrite_var__1 t5)) +(let t34 (Mul (Num 3) (Var "z"))) +(let t35 (Add (Var "x") (Neg (Num 2)))) +(let t36 (Mul t35 (Var "z"))) +(let t37 (Add (Num 1) (Num 2))) +(let t38 (Mul t37 (Var "z"))) +(let t39 (Mul (Num 1) (Var "z"))) +(let t40 (Mul (Num 2) (Var "z"))) +(let prf13 + (Sym + (= (Var "z") t39) + (Rule + (= t39 (Var "z")) + (name + "(rule ((= x (Var v))) + ((union (Mul (Num 1) x) x)) + )") + (premises (Fiat (= (Var "z") (Var "z")))) + (substitution (v "z") (x (Var "z")))))) +(let prf14 (Congr (= t4 (Add t39 (Var "y"))) prf0 prf13 0)) +(let t41 (Add (Num 1) (Num 1))) +(let t42 (Mul t41 (Var "z"))) +(let t43 + (premises + (Congr + (= (Var "y") (Add t39 t39)) + (Congr + (= (Var "y") (Add t39 (Var "z"))) + prf4 + prf13 + 0) + prf13 + 1))) +(let t44 + (substitution + (z (Num 1)) + (@rewrite_var__5 (Var "y")) + (y (Num 1)) + (x (Var "z")))) +(let prf15 + (Sym + (= (Var "y") t42) + (Rule + (= t42 (Var "y")) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t43 + t44))) +(let prf16 + (Rule + (= t41 (Num 2)) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Rule + (= t41 t41) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t43 + t44)) + (substitution + (@rewrite_var__2 t41) + (x 1) + (y 1)))) +(let t45 + (premises + (Congr + (= t4 (Add t39 t40)) + prf14 + (Congr (= (Var "y") t40) prf15 prf16 0) + 1))) +(let t46 (@rewrite_var__5 t4)) +(let t47 + (substitution + (z (Num 2)) + t46 + (y (Num 1)) + (x (Var "z")))) +(let t48 (Add t41 (Num 1))) +(let t49 (Add (Num 2) (Num 1))) +(let t50 (Add (Var "y") (Var "z"))) +(let prf17 + (Rule + (= t50 t4) + (name + "(rewrite (Add x y) (Add y x))") + t16 + (substitution + (y (Var "y")) + (x (Var "z")) + (@rewrite_var__ t4)))) +(let prf18 (Sym (= t4 t50) prf17)) +(let t51 + (premises + (Congr + (= t48 t49) + (Rule + (= t48 t48) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + (premises + (Congr + (= t4 (Add t42 t39)) + (Congr + (= t4 (Add t42 (Var "z"))) + prf18 + prf15 + 0) + prf13 + 1)) + (substitution + (z (Num 1)) + t46 + (y t41) + (x (Var "z")))) + prf16 + 0))) +(let t52 (Add (Num 2) (Var "x"))) +(let t53 (Add t2 (Neg (Num 2)))) +(let t54 (premises (Fiat (= t2 t2)))) +(let t55 (z t2)) +(let t56 + (substitution + t55 + (x (Var "x")) + (y (Num 2)))) +(let prf19 + (Rule + (= t53 (Var "x")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t54 + t56)) +(let prf20 (Sym (= (Var "x") t53) prf19)) +(let prf21 + (Rule + (= t52 t2) + (name + "(rewrite (Add x y) (Add y x))") + t54 + (substitution + (y (Num 2)) + (x (Var "x")) + (@rewrite_var__ t2)))) +(let prf22 (Sym (= t2 t52) prf21)) +(let t57 + (premises + (Congr + (= (Var "x") (Add t52 (Neg (Num 2)))) + prf20 + prf22 + 0))) +(let t58 (z (Neg (Num 2)))) +(let t59 + (substitution + t58 + (y (Var "x")) + (@rewrite_var__1 (Var "x")) + (x (Num 2)))) +(let prf23 + (Rule + (= t35 t35) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t57 + t59)) +(let t60 (Add (Neg (Num 2)) t2)) +(let t61 (premises prf20)) +(let t62 (y (Neg (Num 2)))) +(let t63 (x t2)) +(let prf24 + (Sym + (= (Neg (Num 2)) (Num -2)) + (Rule + (= (Num -2) (Neg (Num 2))) + (name + "(rewrite (Neg (Num n)) (Num (- 0 n)))") + (premises + (Rule + (= + (Neg (Num 2)) + (Neg (Num 2))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t54 + t56)) + (substitution + (@rewrite_var__4 + (Neg (Num 2))) + (n 2))))) +(let prf25 + (Sym + (= t2 (Num 7)) + (Fiat (= (Num 7) t2)))) +(let prf26 + (Sym + (= (Var "x") (Num 5)) + (Rule + (= (Num 5) (Var "x")) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= (Var "x") (Add (Num -2) (Num 7))) + (Congr + (= (Var "x") (Add (Num -2) t2)) + (Sym + (= (Var "x") t60) + (Rule + (= t60 (Var "x")) + (name + "(rewrite (Add x y) (Add y x))") + t61 + (substitution + t62 + t63 + (@rewrite_var__ (Var "x"))))) + prf24 + 0) + prf25 + 1)) + (substitution + (@rewrite_var__2 (Var "x")) + (x -2) + (y 7))))) +(let prf27 + (Rule + (= (Num 3) t35) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t35 (Add (Num 5) (Num -2))) + (Congr + (= t35 (Add (Num 5) (Neg (Num 2)))) + prf23 + prf26 + 0) + prf24 + 1)) + (substitution (@rewrite_var__2 t35) (x 5) (y -2)))) +(let prf28 (Fiat (= (Num 6) t4))) +(let prf29 + (Rule + (= (Var "z") (Num 2)) + (name + "(rule ((= (Mul (Num x) y) (Num z)) + (= (% z x) 0)) + ((union y (Num (/ z x)))) + )") + (premises + (Trans + (= t34 (Num 6)) + (Sym + (= t34 t4) + (Congr + (= t4 t34) + (Trans + (= t4 t36) + (Sym + (= t4 t38) + (Rule + (= t38 t4) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t45 + t47)) + (Congr + (= t38 t36) + (Rule + (= t38 t38) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t45 + t47) + (Trans + (= t37 t35) + (Rule + (= t37 t48) + (name "(rewrite (Add x y) (Add y x))") + t51 + (substitution + (y (Num 1)) + (x (Num 2)) + (@rewrite_var__ t48))) + (Trans + (= t48 t35) + (Sym + (= t48 (Num 3)) + (Rule + (= (Num 3) t48) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + t51 + (substitution (@rewrite_var__2 t48) (x 2) (y 1)))) + prf27)) + 0)) + (Sym (= t35 (Num 3)) prf27) + 0)) + (Sym (= t4 (Num 6)) prf28)) + (Fiat (= 0 0))) + (substitution (z 6) (x 3) (y (Var "z"))))) +(let t64 (Add t2 t35)) +(let t65 (Add (Num 2) t64)) +(let t66 (Add (Neg (Var "x")) (Neg (Num 2)))) +(let t67 (Add t66 (Num 2))) +(let t68 (Add (Neg (Var "x")) t64)) +(let t69 (Add (Neg (Var "x")) t2)) +(let t70 (Add (Num 2) t35)) +(let prf30 + (Rule + (= t70 (Var "x")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t57 + t59)) +(let prf31 (Sym (= (Var "x") t70) prf30)) +(let t71 (Add t2 (Neg (Var "x")))) +(let prf32 + (Sym + (= (Num 2) t71) + (Rule + (= t71 (Num 2)) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf21) + (substitution t55 (x (Num 2)) (y (Var "x")))))) +(let t72 (y (Neg (Var "x")))) +(let prf33 + (Sym + (= (Num 2) t69) + (Rule + (= t69 (Num 2)) + (name "(rewrite (Add x y) (Add y x))") + (premises prf32) + (substitution t72 t63 (@rewrite_var__ (Num 2)))))) +(let t73 + (premises + (Congr (= (Var "x") (Add t69 t35)) prf31 prf33 0))) +(let t74 (z t35)) +(let t75 (y t2)) +(let t76 (x (Neg (Var "x")))) +(let t77 (substitution t74 t75 (@rewrite_var__1 (Var "x")) t76)) +(let t78 (Neg (Neg (Num 2)))) +(let t79 (Add t66 t78)) +(let t80 (Add (Num 2) (Neg (Num 2)))) +(let t81 + (premises + (Rule + (= t66 t66) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t80 (Add t71 (Neg (Num 2)))) + (Rule + (= t80 t80) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t61 + (substitution + t58 + (y (Num 2)) + (@rewrite_var__1 (Var "x")) + (x (Var "x")))) + prf32 + 0)) + (substitution t58 t72 (@rewrite_var__1 t80) t63)))) +(let t82 (substitution (z t66) t76 t62)) +(let t83 (Add (Num 2) t0)) +(let t84 (Add (Var "x") t35)) +(let t85 (Add (Num 2) t84)) +(let prf34 + (Rule + (= t64 t64) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t73 + t77)) +(let t86 (@rewrite_var__1 t64)) +(let t87 (Add t35 (Neg (Num 2)))) +(let t88 (Add t2 t87)) +(let t89 (Add (Var "x") t49)) +(let t90 (Add (Num 2) t87)) +(let t91 (@rewrite_var__1 t35)) +(let t92 (Add (Num 1) t41)) +(let t93 (Add t92 (Neg (Num 2)))) +(let prf35 + (Congr + (= t92 t37) + (Rule + (= t92 t92) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + (premises + (Congr + (= t4 (Add t39 t42)) + prf14 + prf15 + 1)) + (substitution + (z t41) + t46 + (y (Num 1)) + (x (Var "z")))) + prf16 + 1)) +(let t94 (premises (Sym (= t37 t92) prf35))) +(let t95 + (substitution + (z t92) + (x (Num 1)) + (y (Num 2)))) +(let t96 (premises prf35)) +(let prf36 + (Trans + (= t92 t35) + (Sym + (= t92 (Num 3)) + (Rule + (= (Num 3) t92) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + t96 + (substitution + (@rewrite_var__2 t92) + (x 1) + (y 2)))) + prf27)) +(let prf37 + (Congr + (= t88 (Add t2 (Num 1))) + (Rule + (= t88 t88) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t35 (Add t69 t87)) + (Sym + (= t35 t90) + (Rule + (= t90 t35) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t35 (Add t70 (Neg (Num 2)))) + prf23 + prf31 + 0)) + (substitution + t58 + (y t35) + t91 + (x (Num 2))))) + prf33 + 0)) + (substitution (z t87) t75 t91 t76)) + (Trans + (= t87 (Num 1)) + (Sym + (= t87 t93) + (Congr + (= t93 t87) + (Rule + (= t93 t93) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t94 + t95) + prf36 + 0)) + (Rule + (= t93 (Num 1)) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t94 + t95)) + 1)) +(let t97 (premises prf37)) +(let t98 (@rewrite_var__1 t88)) +(let t99 + (substitution + (z (Num 1)) + (y (Num 2)) + t98 + (x (Var "x")))) +(let t100 (Add (Num 2) t4)) +(let t101 (Add (Var "x") (Num 1))) +(let t102 (Add (Num 2) t101)) +(let t103 + (premises + (Congr (= t88 (Add t52 (Num 1))) prf37 prf22 0))) +(let t104 + (substitution + (z (Num 1)) + (y (Var "x")) + t98 + (x (Num 2)))) +(let t105 (Add (Num 1) (Var "x"))) +(let t106 (@rewrite_var__1 t2)) +(let prf38 + (Rule + (= t105 t105) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t2 (Add t41 (Var "x"))) + prf22 + (Sym (= (Num 2) t41) prf16) + 0)) + (substitution + (z (Var "x")) + (y (Num 1)) + t106 + (x (Num 1))))) +(let prop0 (= t0 t5)) +(let t107 (Add (Neg (Var "z")) (Var "z"))) +(let t108 (Add t107 (Var "z"))) +(let t109 (Add t4 t108)) +(let prop1 (= t109 t5)) +(let t110 (Add t4 t107)) +(let t111 (Add t4 (Neg (Var "z")))) +(let t112 + (premises + (Congr + (= t5 (Add t110 (Var "z"))) + prf7 + (Sym + (= t4 t110) + (Rule + (= t110 t4) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t4 (Add t111 (Var "z"))) + prf18 + (Sym + (= (Var "y") t111) + (Rule + (= t111 (Var "y")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf17) + (substitution + t17 + (x (Var "y")) + (y (Var "z"))))) + 0)) + (substitution + (z (Var "z")) + t11 + t12 + t18))) + 0))) +(let t113 + (substitution + (z (Var "z")) + (y t107) + t33 + t18)) +(let t114 (Add (Var "z") (Neg (Var "z")))) +(let t115 (Add t114 (Var "z"))) +(let t116 (Add (Var "z") t114)) +(let t117 + (premises + (Sym + (= (Var "z") t116) + (Rule + (= t116 (Var "z")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= + (Var "z") + (Add t10 (Neg (Var "z")))) + prf2 + prf4 + 0)) + (substitution + (z (Neg (Var "z"))) + (y (Var "z")) + (@rewrite_var__1 (Var "z")) + (x (Var "z"))))))) +(let t118 + (substitution + (y t114) + (x (Var "z")) + (@rewrite_var__ (Var "z")))) +(let t119 (Add (Var "z") t0)) +(let t120 (Add t5 (Var "z"))) +(let t121 (Add (Var "x") (Var "x"))) +(let t122 (Add (Num 2) t121)) +(let prf39 + (Rule + (= t3 t3) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr (= t2 (Add t69 (Var "x"))) prf22 prf33 0)) + (substitution (z (Var "x")) t75 t106 t76))) +(let t123 (Add (Var "x") t70)) +(let t124 (premises prf34)) +(let t125 (substitution t74 (y (Num 2)) t86 (x (Var "x")))) +(Trans + (= t1 (Num 12)) + (Trans + (= t1 t3) + (Sym (= t1 t6) prf11) + (Trans + (= t6 t3) + (Trans + (= t6 t27) + (Sym + (= t6 t28) + (Rule + (= t28 t6) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t6 (Add t25 (Var "y"))) prf11 prf12 0)) + (substitution (z (Var "y")) t20 (@rewrite_var__1 t6) (x (Var "z"))))) + (Congr + (= t28 t27) + (Rule + (= t28 t28) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Rule + (= t29 t29) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t5 (Add t30 (Var "z"))) + prf7 + (Sym + (= t4 t30) + (Rule + (= t30 t4) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t31 + t32)) + 0)) + (substitution (z (Var "z")) (y t26) t33 t21))) + (substitution (y (Var "z")) (x t26) (@rewrite_var__ t29))) + prf29 + 0)) + (Trans + (= t27 t3) + (Sym + (= t27 t65) + (Congr + (= t65 t27) + (Rule + (= t65 t65) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= (Var "x") (Add t67 t64)) + (Sym + (= (Var "x") t68) + (Rule + (= t68 (Var "x")) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t73 + t77)) + (Trans + (= (Neg (Var "x")) t67) + (Sym + (= (Neg (Var "x")) t79) + (Rule + (= t79 (Neg (Var "x"))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t81 + t82)) + (Congr + (= t79 t67) + (Rule + (= t79 t79) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t81 + t82) + (Rule + (= t78 (Num 2)) + (name "(rewrite (Neg (Neg x)) x)") + (premises + (Rule + (= t78 t78) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf19) + (substitution (z (Var "x")) t63 t62))) + (substitution (x (Num 2)) (@rewrite_var__3 t78))) + 1)) + 0)) + (substitution + (z t64) + (y (Num 2)) + (@rewrite_var__1 (Var "x")) + (x t66))) + (Trans + (= t64 t26) + (Congr + (= t64 t83) + (Sym + (= t64 t85) + (Rule + (= t85 t64) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t64 (Add t52 t35)) prf34 prf22 0)) + (substitution t74 (y (Var "x")) t86 (x (Num 2))))) + (Trans + (= t84 t0) + (Trans + (= t84 t88) + (Sym + (= t84 t89) + (Congr + (= t89 t84) + (Rule + (= t89 t89) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t97 + t99) + (Trans + (= t49 t35) + (Rule + (= t49 t92) + (name "(rewrite (Add x y) (Add y x))") + t96 + (substitution + (y (Num 2)) + (x (Num 1)) + (@rewrite_var__ t92))) + prf36) + 1)) + (Rule + (= t89 t88) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t97 + t99)) + (Trans + (= t88 t0) + (Trans + (= t88 t100) + (Sym + (= t88 t102) + (Rule + (= t102 t88) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t103 + t104)) + (Congr + (= t102 t100) + (Rule + (= t102 t102) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t103 + t104) + (Trans + (= t101 t4) + (Trans + (= t101 (Num 6)) + (Rule + (= t101 t105) + (name "(rewrite (Add x y) (Add y x))") + (premises prf38) + (substitution + (y (Var "x")) + (x (Num 1)) + (@rewrite_var__ t105))) + (Rule + (= t105 (Num 6)) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t105 (Add (Num 1) (Num 5))) + prf38 + prf26 + 1)) + (substitution (@rewrite_var__2 t105) (x 1) (y 5)))) + prf28) + 1)) + (Trans + (= t100 t0) + (Sym + (= t100 t25) + (Congr + (= t25 t100) + (Rule + (= t25 t25) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Trans + prop0 + (Trans + (= t0 t109) + (Trans prop0 prf12 prf8) + (Sym + (= t5 t109) + (Rule + prop1 + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t112 + t113))) + (Congr + prop1 + (Rule + (= t109 t109) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t112 + t113) + (Trans + (= t108 (Var "z")) + (Sym + (= t108 t115) + (Congr + (= t115 t108) + (Rule + (= t115 t115) + (name "(rewrite (Add x y) (Add y x))") + t117 + t118) + (Rule + (= t114 t107) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Rule + (= t107 t107) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= + (Var "y") + (Add t9 (Var "z"))) + prf4 + prf2 + 0)) + (substitution + (z (Var "z")) + t11 + (@rewrite_var__1 (Var "y")) + (x (Var "y"))))) + (substitution + (y (Var "z")) + t13 + (@rewrite_var__ t107))) + 0)) + (Rule + (= t115 (Var "z")) + (name "(rewrite (Add x y) (Add y x))") + t117 + t118)) + 1))) + (substitution (y (Var "z")) t18 (@rewrite_var__ t0))) + prf29 + 0)) + prf9))) + 1) + (Trans + (= t83 t26) + (Sym + (= t83 t119) + (Congr + (= t119 t83) + (Rule + (= t119 t119) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Congr + (= t120 (Add t0 (Var "z"))) + (Rule + (= t120 t120) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr (= t4 (Add t7 (Var "z"))) prf18 prf6 0)) + (substitution (z (Var "z")) t23 t12 t21)) + prf10 + 0)) + (substitution (y (Var "z")) (x t0) (@rewrite_var__ t120))) + prf29 + 0)) + (Rule + (= t119 t26) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Rule + (= t26 t26) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t31 + t32)) + (substitution + (z (Var "y")) + (y (Var "y")) + (@rewrite_var__1 t26) + (x (Var "z")))))) + 1)) + (Sym + (= t65 t3) + (Congr + (= t3 t65) + (Sym + (= t3 t122) + (Rule + (= t122 t3) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t3 (Add t52 (Var "x"))) prf39 prf22 0)) + (substitution + (z (Var "x")) + (y (Var "x")) + (@rewrite_var__1 t3) + (x (Num 2))))) + (Trans + (= t121 t64) + (Sym + (= t121 t123) + (Congr + (= t123 t121) + (Rule + (= t123 t123) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t124 + t125) + prf30 + 1)) + (Rule + (= t123 t64) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t124 + t125)) + 1))))) + (Sym + (= t3 (Num 12)) + (Rule + (= (Num 12) t3) + (name "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t3 (Add (Num 7) (Num 5))) + (Congr (= t3 (Add (Num 7) (Var "x"))) prf39 prf25 0) + prf26 + 1)) + (substitution (@rewrite_var__2 t3) (x 7) (y 5))))) +(let t0 (Mul (Num 2) (Var "y"))) +(let t1 (Add t0 (Var "y"))) +(let t2 (Add (Var "x") (Num 2))) +(let t3 (Add t2 (Var "x"))) +(let t4 (Add (Var "y") (Var "y"))) +(let t5 (Add t4 (Var "y"))) +(let t6 (Add (Var "z") (Var "y"))) +(let t7 (Add t6 (Var "z"))) +(let t8 (Add t7 (Var "y"))) +(let t9 (Add t6 (Var "y"))) +(let t10 (Add (Num 2) t9)) +(let t11 (Add (Var "x") (Neg (Num 2)))) +(let t12 (Add t2 t11)) +(let t13 (Add (Num 2) t12)) +(let t14 (Add (Var "x") (Var "x"))) +(let t15 (Add (Num 2) t14)) +(let t16 (Add (Num 2) (Var "x"))) +(let t17 (Add (Neg (Var "x")) t2)) +(let t18 (premises (Fiat (= t2 t2)))) +(let prf0 + (Rule + (= t16 t2) + (name "(rewrite (Add x y) (Add y x))") + t18 + (substitution + (y (Num 2)) + (x (Var "x")) + (@rewrite_var__ t2)))) +(let prf1 (Sym (= t2 t16) prf0)) +(let t19 (Add t2 (Neg (Var "x")))) +(let t20 (z t2)) +(let prf2 + (Sym + (= (Num 2) t19) + (Rule + (= t19 (Num 2)) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf0) + (substitution + t20 + (x (Num 2)) + (y (Var "x")))))) +(let t21 (y (Neg (Var "x")))) +(let t22 (x t2)) +(let prf3 + (Sym + (= (Num 2) t17) + (Rule + (= t17 (Num 2)) + (name "(rewrite (Add x y) (Add y x))") + (premises prf2) + (substitution t21 t22 (@rewrite_var__ (Num 2)))))) +(let t23 (y t2)) +(let t24 (@rewrite_var__1 t2)) +(let t25 (x (Neg (Var "x")))) +(let prf4 + (Rule + (= t3 t3) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr (= t2 (Add t17 (Var "x"))) prf1 prf3 0)) + (substitution (z (Var "x")) t23 t24 t25))) +(let t26 (Add (Num 2) t11)) +(let t27 (Add (Var "x") t26)) +(let t28 (Add t2 (Neg (Num 2)))) +(let t29 + (substitution + t20 + (x (Var "x")) + (y (Num 2)))) +(let prf5 + (Rule + (= t28 (Var "x")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t18 + t29)) +(let prf6 (Sym (= (Var "x") t28) prf5)) +(let t30 + (premises + (Congr + (= (Var "x") (Add t16 (Neg (Num 2)))) + prf6 + prf1 + 0))) +(let t31 (z (Neg (Num 2)))) +(let t32 + (substitution + t31 + (y (Var "x")) + (@rewrite_var__1 (Var "x")) + (x (Num 2)))) +(let prf7 + (Rule + (= t26 (Var "x")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t30 + t32)) +(let prf8 (Sym (= (Var "x") t26) prf7)) +(let t33 + (premises + (Congr (= (Var "x") (Add t17 t11)) prf8 prf3 0))) +(let t34 (z t11)) +(let t35 (substitution t34 t23 (@rewrite_var__1 (Var "x")) t25)) +(let prf9 + (Rule + (= t12 t12) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t33 + t35)) +(let t36 (premises prf9)) +(let t37 (@rewrite_var__1 t12)) +(let t38 (substitution t34 (y (Num 2)) t37 (x (Var "x")))) +(let t39 (Add (Neg (Var "x")) (Neg (Num 2)))) +(let t40 (Add t39 (Num 2))) +(let t41 (Add (Neg (Var "x")) t12)) +(let t42 (Neg (Neg (Num 2)))) +(let t43 (Add t39 t42)) +(let t44 (Add (Num 2) (Neg (Num 2)))) +(let t45 (premises prf6)) +(let t46 + (premises + (Rule + (= t39 t39) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t44 (Add t19 (Neg (Num 2)))) + (Rule + (= t44 t44) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t45 + (substitution + t31 + (y (Num 2)) + (@rewrite_var__1 (Var "x")) + (x (Var "x")))) + prf2 + 0)) + (substitution t31 t21 (@rewrite_var__1 t44) t22)))) +(let t47 (y (Neg (Num 2)))) +(let t48 (substitution (z t39) t25 t47)) +(let t49 (Add (Num 2) t4)) +(let t50 (Add (Var "x") t11)) +(let t51 (Add (Num 2) t50)) +(let t52 (Add t11 (Neg (Num 2)))) +(let t53 (Add t2 t52)) +(let t54 (Add (Num 2) (Num 1))) +(let t55 (Add (Var "x") t54)) +(let t56 (Add (Num 2) t52)) +(let prf10 + (Rule + (= t11 t11) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t30 + t32)) +(let t57 (@rewrite_var__1 t11)) +(let t58 (Add (Num 1) (Num 1))) +(let t59 (Add (Num 1) t58)) +(let t60 (Add t59 (Neg (Num 2)))) +(let t61 (Add (Num 1) (Num 2))) +(let t62 (Mul (Num 1) (Var "z"))) +(let t63 (Mul t58 (Var "z"))) +(let prf11 (Fiat (= t6 t6))) +(let prf12 + (Sym + (= (Var "z") t62) + (Rule + (= t62 (Var "z")) + (name + "(rule ((= x (Var v))) + ((union (Mul (Num 1) x) x)) + )") + (premises + (Fiat + (= + (Var "z") + (Var "z")))) + (substitution + (v "z") + (x (Var "z")))))) +(let prf13 + (Congr + (= t6 (Add t62 (Var "y"))) + prf11 + prf12 + 0)) +(let t64 + (Add + (Var "z") + (Var "z"))) +(let prf14 + (Fiat + (= + t64 + (Var "y")))) +(let prf15 + (Sym + (= + (Var "y") + t64) + prf14)) +(let t65 + (premises + (Congr + (= + (Var "y") + (Add t62 t62)) + (Congr + (= + (Var "y") + (Add + t62 + (Var "z"))) + prf15 + prf12 + 0) + prf12 + 1))) +(let t66 + (substitution + (z (Num 1)) + (@rewrite_var__5 + (Var "y")) + (y (Num 1)) + (x (Var "z")))) +(let prf16 + (Sym + (= (Var "y") t63) + (Rule + (= t63 (Var "y")) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t65 + t66))) +(let t67 (@rewrite_var__5 t6)) +(let prf17 + (Rule + (= t58 (Num 2)) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Rule + (= t58 t58) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t65 + t66)) + (substitution + (@rewrite_var__2 t58) + (x 1) + (y 1)))) +(let prf18 + (Congr + (= t59 t61) + (Rule + (= t59 t59) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + (premises + (Congr + (= t6 (Add t62 t63)) + prf13 + prf16 + 1)) + (substitution + (z t58) + t67 + (y (Num 1)) + (x (Var "z")))) + prf17 + 1)) +(let t68 (premises (Sym (= t61 t59) prf18))) +(let t69 + (substitution + (z t59) + (x (Num 1)) + (y (Num 2)))) +(let t70 (premises prf18)) +(let t71 + (Add + (Neg (Num 2)) + t2)) +(let prf19 + (Sym + (= + (Neg (Num 2)) + (Num -2)) + (Rule + (= + (Num -2) + (Neg (Num 2))) + (name + "(rewrite (Neg (Num n)) (Num (- 0 n)))") + (premises + (Rule + (= + (Neg + (Num 2)) + (Neg + (Num 2))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t18 + t29)) + (substitution + (@rewrite_var__4 + (Neg (Num 2))) + (n 2))))) +(let prf20 + (Sym + (= t2 (Num 7)) + (Fiat (= (Num 7) t2)))) +(let prf21 + (Sym + (= (Var "x") (Num 5)) + (Rule + (= (Num 5) (Var "x")) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= + (Var "x") + (Add (Num -2) (Num 7))) + (Congr + (= + (Var "x") + (Add (Num -2) t2)) + (Sym + (= (Var "x") t71) + (Rule + (= t71 (Var "x")) + (name + "(rewrite (Add x y) (Add y x))") + t45 + (substitution + t47 + t22 + (@rewrite_var__ + (Var "x"))))) + prf19 + 0) + prf20 + 1)) + (substitution + (@rewrite_var__2 + (Var "x")) + (x -2) + (y 7))))) +(let prf22 + (Rule + (= (Num 3) t11) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t11 (Add (Num 5) (Num -2))) + (Congr + (= + t11 + (Add (Num 5) (Neg (Num 2)))) + prf10 + prf21 + 0) + prf19 + 1)) + (substitution + (@rewrite_var__2 t11) + (x 5) + (y -2)))) +(let prf23 + (Trans + (= t59 t11) + (Sym + (= t59 (Num 3)) + (Rule + (= (Num 3) t59) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + t70 + (substitution + (@rewrite_var__2 t59) + (x 1) + (y 2)))) + prf22)) +(let prf24 + (Congr + (= t53 (Add t2 (Num 1))) + (Rule + (= t53 t53) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t11 (Add t17 t52)) + (Sym + (= t11 t56) + (Rule + (= t56 t11) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t11 (Add t26 (Neg (Num 2)))) + prf10 + prf8 + 0)) + (substitution + t31 + (y t11) + t57 + (x (Num 2))))) + prf3 + 0)) + (substitution (z t52) t23 t57 t25)) + (Trans + (= t52 (Num 1)) + (Sym + (= t52 t60) + (Congr + (= t60 t52) + (Rule + (= t60 t60) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t68 + t69) + prf23 + 0)) + (Rule + (= t60 (Num 1)) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t68 + t69)) + 1)) +(let t72 (premises prf24)) +(let t73 (@rewrite_var__1 t53)) +(let t74 + (substitution + (z (Num 1)) + (y (Num 2)) + t73 + (x (Var "x")))) +(let t75 (Add (Num 2) t6)) +(let t76 (Add (Var "x") (Num 1))) +(let t77 (Add (Num 2) t76)) +(let t78 + (premises + (Congr (= t53 (Add t16 (Num 1))) prf24 prf1 0))) +(let t79 + (substitution + (z (Num 1)) + (y (Var "x")) + t73 + (x (Num 2)))) +(let t80 (Add (Num 1) (Var "x"))) +(let prf25 + (Rule + (= t80 t80) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t2 (Add t58 (Var "x"))) + prf1 + (Sym (= (Num 2) t58) prf17) + 0)) + (substitution + (z (Var "x")) + (y (Num 1)) + t24 + (x (Num 1))))) +(let prf26 (Fiat (= (Num 6) t6))) +(let t81 (Add (Var "z") t6)) +(let prop0 (= t4 t7)) +(let t82 (Add (Neg (Var "z")) (Var "z"))) +(let t83 (Add t82 (Var "z"))) +(let t84 (Add t6 t83)) +(let t85 + (Add + (Neg (Var "z")) + (Var "y"))) +(let t86 + (Add + (Var "y") + (Neg (Var "z")))) +(let prf27 + (Sym + (= (Var "z") t86) + (Rule + (= t86 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf14) + (substitution + (z (Var "y")) + (x (Var "z")) + (y (Var "z")))))) +(let t87 (y (Neg (Var "z")))) +(let t88 (@rewrite_var__1 t6)) +(let t89 (x (Neg (Var "z")))) +(let prf28 + (Rule + (= t4 t4) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t6 (Add t85 (Var "y"))) + prf11 + (Sym + (= (Var "z") t85) + (Rule + (= t85 (Var "z")) + (name + "(rewrite (Add x y) (Add y x))") + (premises prf27) + (substitution + t87 + (x (Var "y")) + (@rewrite_var__ + (Var "z"))))) + 0)) + (substitution + (z (Var "y")) + (y (Var "y")) + t88 + t89))) +(let t90 (@rewrite_var__1 t4)) +(let prf29 + (Rule + (= t81 t4) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t4 (Add t64 (Var "y"))) + prf28 + prf15 + 0)) + (substitution + (z (Var "y")) + (y (Var "z")) + t90 + (x (Var "z"))))) +(let prf30 (Sym (= t4 t81) prf29)) +(let t91 (Add (Neg (Var "y")) t6)) +(let t92 + (Add + t6 + (Neg (Var "y")))) +(let t93 (premises prf11)) +(let t94 (z t6)) +(let t95 (x t6)) +(let prf31 + (Sym + (= (Var "z") t91) + (Rule + (= t91 (Var "z")) + (name + "(rewrite (Add x y) (Add y x))") + (premises + (Sym + (= (Var "z") t92) + (Rule + (= t92 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t93 + (substitution + t94 + (x (Var "z")) + (y (Var "y")))))) + (substitution + (y (Neg (Var "y"))) + t95 + (@rewrite_var__ (Var "z")))))) +(let t96 + (premises + (Congr + (= + (Var "y") + (Add t91 (Var "z"))) + prf15 + prf31 + 0))) +(let t97 (y t6)) +(let t98 (x (Neg (Var "y")))) +(let t99 + (substitution + (z (Var "z")) + t97 + (@rewrite_var__1 (Var "y")) + t98)) +(let prf32 + (Rule + (= t7 t7) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t96 + t99)) +(let prf33 + (Rule + (= t81 t7) + (name "(rewrite (Add x y) (Add y x))") + (premises prf32) + (substitution + (y (Var "z")) + t95 + (@rewrite_var__ t7)))) +(let prop1 (= t84 t7)) +(let t100 (Add t6 t82)) +(let t101 (Add t6 (Neg (Var "z")))) +(let t102 + (Add + (Var "y") + (Var "z"))) +(let prf34 + (Rule + (= t102 t6) + (name + "(rewrite (Add x y) (Add y x))") + t93 + (substitution + (y (Var "y")) + (x (Var "z")) + (@rewrite_var__ t6)))) +(let prf35 (Sym (= t6 t102) prf34)) +(let t103 + (premises + (Congr + (= t7 (Add t100 (Var "z"))) + prf32 + (Sym + (= t6 t100) + (Rule + (= t100 t6) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t6 (Add t101 (Var "z"))) + prf35 + (Sym + (= (Var "y") t101) + (Rule + (= t101 (Var "y")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf34) + (substitution + t94 + (x (Var "y")) + (y (Var "z"))))) + 0)) + (substitution + (z (Var "z")) + t87 + t88 + t95))) + 0))) +(let t104 (@rewrite_var__1 t7)) +(let t105 + (substitution + (z (Var "z")) + (y t82) + t104 + t95)) +(let t106 (Add (Var "z") (Neg (Var "z")))) +(let t107 (Add t106 (Var "z"))) +(let t108 (Add (Var "z") t106)) +(let t109 + (premises + (Sym + (= (Var "z") t108) + (Rule + (= t108 (Var "z")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= + (Var "z") + (Add + t64 + (Neg (Var "z")))) + prf27 + prf15 + 0)) + (substitution + (z (Neg (Var "z"))) + (y (Var "z")) + (@rewrite_var__1 (Var "z")) + (x (Var "z"))))))) +(let t110 + (substitution + (y t106) + (x (Var "z")) + (@rewrite_var__ (Var "z")))) +(let t111 (Mul (Num 3) (Var "z"))) +(let t112 (Mul t11 (Var "z"))) +(let t113 (Mul t61 (Var "z"))) +(let t114 (Mul (Num 2) (Var "z"))) +(let t115 + (premises + (Congr + (= t6 (Add t62 t114)) + prf13 + (Congr + (= (Var "y") t114) + prf16 + prf17 + 0) + 1))) +(let t116 + (substitution + (z (Num 2)) + t67 + (y (Num 1)) + (x (Var "z")))) +(let t117 (Add t58 (Num 1))) +(let t118 + (premises + (Congr + (= t117 t54) + (Rule + (= t117 t117) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + (premises + (Congr + (= t6 (Add t63 t62)) + (Congr + (= + t6 + (Add t63 (Var "z"))) + prf35 + prf16 + 0) + prf12 + 1)) + (substitution + (z (Num 1)) + t67 + (y t58) + (x (Var "z")))) + prf17 + 0))) +(let prf36 + (Rule + (= (Var "z") (Num 2)) + (name + "(rule ((= (Mul (Num x) y) (Num z)) + (= (% z x) 0)) + ((union y (Num (/ z x)))) + )") + (premises + (Trans + (= t111 (Num 6)) + (Sym + (= t111 t6) + (Congr + (= t6 t111) + (Trans + (= t6 t112) + (Sym + (= t6 t113) + (Rule + (= t113 t6) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t115 + t116)) + (Congr + (= t113 t112) + (Rule + (= t113 t113) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t115 + t116) + (Trans + (= t61 t11) + (Rule + (= t61 t117) + (name + "(rewrite (Add x y) (Add y x))") + t118 + (substitution + (y (Num 1)) + (x (Num 2)) + (@rewrite_var__ t117))) + (Trans + (= t117 t11) + (Sym + (= t117 (Num 3)) + (Rule + (= (Num 3) t117) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + t118 + (substitution + (@rewrite_var__2 t117) + (x 2) + (y 1)))) + prf22)) + 0)) + (Sym (= t11 (Num 3)) prf22) + 0)) + (Sym (= t6 (Num 6)) prf26)) + (Fiat (= 0 0))) + (substitution (z 6) (x 3) (y (Var "z"))))) +(let t119 (Add (Var "z") t4)) +(let t120 (Add t7 (Var "z"))) +(let t121 (Add (Neg (Var "y")) t7)) +(let prf37 + (Sym + (= (Var "y") t121) + (Rule + (= t121 (Var "y")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t96 + t99))) +(let t122 (y t7)) +(let prf38 (Trans (= t7 t4) (Sym (= t7 t81) prf33) prf29)) +(let t123 + (premises + (Congr (= t6 (Add t91 (Var "y"))) prf11 prf31 0))) +(let t124 (substitution (z (Var "y")) t97 t88 t98)) +(let t125 (Add (Var "z") t9)) +(let t126 (Add t9 (Var "z"))) +(let t127 (Add (Neg (Var "y")) t9)) +(let prf39 + (Congr + (= t8 t5) + (Rule + (= t8 t8) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr (= t4 (Add t121 (Var "y"))) prf28 prf37 0)) + (substitution (z (Var "y")) t122 t90 t98)) + prf38 + 0)) +(let t128 (Mul t58 (Var "y"))) +(let t129 (Mul (Num 1) (Var "y"))) +(let prf40 + (Sym + (= (Var "y") t129) + (Rule + (= t129 (Var "y")) + (name + "(rule ((= x (Var v))) + ((union (Mul (Num 1) x) x)) + )") + (premises (Fiat (= (Var "y") (Var "y")))) + (substitution (v "y") (x (Var "y")))))) +(let t130 + (premises + (Congr + (= t4 (Add t129 t129)) + (Congr (= t4 (Add t129 (Var "y"))) prf28 prf40 0) + prf40 + 1))) +(let t131 + (substitution + (z (Num 1)) + (@rewrite_var__5 t4) + (y (Num 1)) + (x (Var "y")))) +(Trans + (= t1 (Num 12)) + (Sym + (= t1 t3) + (Congr + (= t3 t1) + (Trans + (= t3 t5) + (Trans + (= t3 t8) + (Trans + (= t3 t10) + (Congr + (= t3 t13) + (Sym + (= t3 t15) + (Rule + (= t15 t3) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t3 (Add t16 (Var "x"))) prf4 prf1 0)) + (substitution + (z (Var "x")) + (y (Var "x")) + (@rewrite_var__1 t3) + (x (Num 2))))) + (Trans + (= t14 t12) + (Sym + (= t14 t27) + (Congr + (= t27 t14) + (Rule + (= t27 t27) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t36 + t38) + prf7 + 1)) + (Rule + (= t27 t12) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t36 + t38)) + 1) + (Congr + (= t13 t10) + (Rule + (= t13 t13) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= (Var "x") (Add t40 t12)) + (Sym + (= (Var "x") t41) + (Rule + (= t41 (Var "x")) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t33 + t35)) + (Trans + (= (Neg (Var "x")) t40) + (Sym + (= (Neg (Var "x")) t43) + (Rule + (= t43 (Neg (Var "x"))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t46 + t48)) + (Congr + (= t43 t40) + (Rule + (= t43 t43) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t46 + t48) + (Rule + (= t42 (Num 2)) + (name "(rewrite (Neg (Neg x)) x)") + (premises + (Rule + (= t42 t42) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf5) + (substitution (z (Var "x")) t22 t47))) + (substitution (x (Num 2)) (@rewrite_var__3 t42))) + 1)) + 0)) + (substitution + (z t12) + (y (Num 2)) + (@rewrite_var__1 (Var "x")) + (x t39))) + (Trans + (= t12 t9) + (Congr + (= t12 t49) + (Sym + (= t12 t51) + (Rule + (= t51 t12) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t12 (Add t16 t11)) prf9 prf1 0)) + (substitution t34 (y (Var "x")) t37 (x (Num 2))))) + (Trans + (= t50 t4) + (Trans + (= t50 t53) + (Sym + (= t50 t55) + (Congr + (= t55 t50) + (Rule + (= t55 t55) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t72 + t74) + (Trans + (= t54 t11) + (Rule + (= t54 t59) + (name "(rewrite (Add x y) (Add y x))") + t70 + (substitution + (y (Num 2)) + (x (Num 1)) + (@rewrite_var__ t59))) + prf23) + 1)) + (Rule + (= t55 t53) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t72 + t74)) + (Trans + (= t53 t4) + (Trans + (= t53 t75) + (Sym + (= t53 t77) + (Rule + (= t77 t53) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t78 + t79)) + (Congr + (= t77 t75) + (Rule + (= t77 t77) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t78 + t79) + (Trans + (= t76 t6) + (Trans + (= t76 (Num 6)) + (Rule + (= t76 t80) + (name "(rewrite (Add x y) (Add y x))") + (premises prf25) + (substitution + (y (Var "x")) + (x (Num 1)) + (@rewrite_var__ t80))) + (Rule + (= t80 (Num 6)) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t80 (Add (Num 1) (Num 5))) + prf25 + prf21 + 1)) + (substitution (@rewrite_var__2 t80) (x 1) (y 5)))) + prf26) + 1)) + (Trans + (= t75 t4) + (Sym + (= t75 t81) + (Congr + (= t81 t75) + (Rule + (= t81 t81) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Trans + prop0 + (Trans + (= t4 t84) + (Trans prop0 prf30 prf33) + (Sym + (= t7 t84) + (Rule + prop1 + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t103 + t105))) + (Congr + prop1 + (Rule + (= t84 t84) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t103 + t105) + (Trans + (= t83 (Var "z")) + (Sym + (= t83 t107) + (Congr + (= t107 t83) + (Rule + (= t107 t107) + (name + "(rewrite (Add x y) (Add y x))") + t109 + t110) + (Rule + (= t106 t82) + (name + "(rewrite (Add x y) (Add y x))") + (premises + (Rule + (= t82 t82) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= + (Var "y") + (Add t86 (Var "z"))) + prf15 + prf27 + 0)) + (substitution + (z (Var "z")) + t87 + (@rewrite_var__1 (Var "y")) + (x (Var "y"))))) + (substitution + (y (Var "z")) + t89 + (@rewrite_var__ t82))) + 0)) + (Rule + (= t107 (Var "z")) + (name "(rewrite (Add x y) (Add y x))") + t109 + t110)) + 1))) + (substitution + (y (Var "z")) + t95 + (@rewrite_var__ t4))) + prf36 + 0)) + prf29))) + 1) + (Trans + (= t49 t9) + (Sym + (= t49 t119) + (Congr + (= t119 t49) + (Rule + (= t119 t119) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Congr + (= t120 (Add t4 (Var "z"))) + (Rule + (= t120 t120) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t6 (Add t121 (Var "z"))) + prf35 + prf37 + 0)) + (substitution (z (Var "z")) t122 t88 t98)) + prf38 + 0)) + (substitution + (y (Var "z")) + (x t4) + (@rewrite_var__ t120))) + prf36 + 0)) + (Rule + (= t119 t9) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Rule + (= t9 t9) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t123 + t124)) + (substitution + (z (Var "y")) + (y (Var "y")) + (@rewrite_var__1 t9) + (x (Var "z")))))) + 1)) + (Trans + (= t10 t8) + (Sym + (= t10 t125) + (Congr + (= t125 t10) + (Rule + (= t125 t125) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Rule + (= t126 t126) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t7 (Add t127 (Var "z"))) + prf32 + (Sym + (= t6 t127) + (Rule + (= t127 t6) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t123 + t124)) + 0)) + (substitution (z (Var "z")) (y t9) t104 t98))) + (substitution (y (Var "z")) (x t9) (@rewrite_var__ t126))) + prf36 + 0)) + (Rule + (= t125 t8) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t8 (Add t81 (Var "y"))) prf39 prf30 0)) + (substitution + (z (Var "y")) + t97 + (@rewrite_var__1 t8) + (x (Var "z")))))) + prf39) + (Trans + (= t4 t0) + (Sym + (= t4 t128) + (Rule + (= t128 t4) + (name "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t130 + t131)) + (Congr + (= t128 t0) + (Rule + (= t128 t128) + (name "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t130 + t131) + prf17 + 0)) + 0)) + (Sym + (= t3 (Num 12)) + (Rule + (= (Num 12) t3) + (name "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t3 (Add (Num 7) (Num 5))) + (Congr (= t3 (Add (Num 7) (Var "x"))) prf4 prf20 0) + prf21 + 1)) + (substitution (@rewrite_var__2 t3) (x 7) (y 5))))) +(let t0 (Mul (Num 3) (Var "y"))) +(let t1 (Add (Var "x") (Num 2))) +(let t2 (Add t1 (Var "x"))) +(let t3 (Add (Var "x") (Neg (Num 2)))) +(let t4 (Mul t3 (Var "y"))) +(let t5 (Add (Var "z") (Var "y"))) +(let t6 (Add t5 (Var "z"))) +(let t7 (Add t6 (Var "y"))) +(let t8 (Add t5 (Var "y"))) +(let t9 (Add (Num 2) t8)) +(let t10 (Add t1 t3)) +(let t11 (Add (Num 2) t10)) +(let t12 (Add (Var "x") (Var "x"))) +(let t13 (Add (Num 2) t12)) +(let t14 (Add (Num 2) (Var "x"))) +(let t15 (Add (Neg (Var "x")) t1)) +(let t16 (premises (Fiat (= t1 t1)))) +(let prf0 + (Rule + (= t14 t1) + (name "(rewrite (Add x y) (Add y x))") + t16 + (substitution + (y (Num 2)) + (x (Var "x")) + (@rewrite_var__ t1)))) +(let prf1 (Sym (= t1 t14) prf0)) +(let t17 (Add t1 (Neg (Var "x")))) +(let t18 (z t1)) +(let prf2 + (Sym + (= (Num 2) t17) + (Rule + (= t17 (Num 2)) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf0) + (substitution + t18 + (x (Num 2)) + (y (Var "x")))))) +(let t19 (y (Neg (Var "x")))) +(let t20 (x t1)) +(let prf3 + (Sym + (= (Num 2) t15) + (Rule + (= t15 (Num 2)) + (name "(rewrite (Add x y) (Add y x))") + (premises prf2) + (substitution t19 t20 (@rewrite_var__ (Num 2)))))) +(let t21 (y t1)) +(let t22 (@rewrite_var__1 t1)) +(let t23 (x (Neg (Var "x")))) +(let prf4 + (Rule + (= t2 t2) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr (= t1 (Add t15 (Var "x"))) prf1 prf3 0)) + (substitution (z (Var "x")) t21 t22 t23))) +(let t24 (Add (Num 2) t3)) +(let t25 (Add (Var "x") t24)) +(let t26 (Add t1 (Neg (Num 2)))) +(let t27 + (substitution + t18 + (x (Var "x")) + (y (Num 2)))) +(let prf5 + (Rule + (= t26 (Var "x")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t16 + t27)) +(let prf6 (Sym (= (Var "x") t26) prf5)) +(let t28 + (premises + (Congr + (= (Var "x") (Add t14 (Neg (Num 2)))) + prf6 + prf1 + 0))) +(let t29 (z (Neg (Num 2)))) +(let t30 + (substitution + t29 + (y (Var "x")) + (@rewrite_var__1 (Var "x")) + (x (Num 2)))) +(let prf7 + (Rule + (= t24 (Var "x")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t28 + t30)) +(let prf8 (Sym (= (Var "x") t24) prf7)) +(let t31 + (premises + (Congr (= (Var "x") (Add t15 t3)) prf8 prf3 0))) +(let t32 (z t3)) +(let t33 (substitution t32 t21 (@rewrite_var__1 (Var "x")) t23)) +(let prf9 + (Rule + (= t10 t10) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t31 + t33)) +(let t34 (premises prf9)) +(let t35 (@rewrite_var__1 t10)) +(let t36 (substitution t32 (y (Num 2)) t35 (x (Var "x")))) +(let t37 (Add (Neg (Var "x")) (Neg (Num 2)))) +(let t38 (Add t37 (Num 2))) +(let t39 (Add (Neg (Var "x")) t10)) +(let t40 (Neg (Neg (Num 2)))) +(let t41 (Add t37 t40)) +(let t42 (Add (Num 2) (Neg (Num 2)))) +(let t43 (premises prf6)) +(let t44 + (premises + (Rule + (= t37 t37) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t42 (Add t17 (Neg (Num 2)))) + (Rule + (= t42 t42) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t43 + (substitution + t29 + (y (Num 2)) + (@rewrite_var__1 (Var "x")) + (x (Var "x")))) + prf2 + 0)) + (substitution t29 t19 (@rewrite_var__1 t42) t20)))) +(let t45 (y (Neg (Num 2)))) +(let t46 (substitution (z t37) t23 t45)) +(let t47 (Add (Var "y") (Var "y"))) +(let t48 (Add (Num 2) t47)) +(let t49 (Add (Var "x") t3)) +(let t50 (Add (Num 2) t49)) +(let t51 (Add t3 (Neg (Num 2)))) +(let t52 (Add t1 t51)) +(let t53 (Add (Num 2) (Num 1))) +(let t54 (Add (Var "x") t53)) +(let t55 (Add (Num 2) t51)) +(let prf10 + (Rule + (= t3 t3) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t28 + t30)) +(let t56 (@rewrite_var__1 t3)) +(let t57 (Add (Num 1) (Num 1))) +(let t58 (Add (Num 1) t57)) +(let t59 (Add t58 (Neg (Num 2)))) +(let t60 (Add (Num 1) (Num 2))) +(let t61 (Mul (Num 1) (Var "z"))) +(let t62 (Mul t57 (Var "z"))) +(let prf11 (Fiat (= t5 t5))) +(let prf12 + (Sym + (= (Var "z") t61) + (Rule + (= t61 (Var "z")) + (name + "(rule ((= x (Var v))) + ((union (Mul (Num 1) x) x)) + )") + (premises + (Fiat + (= + (Var "z") + (Var "z")))) + (substitution + (v "z") + (x (Var "z")))))) +(let prf13 + (Congr + (= t5 (Add t61 (Var "y"))) + prf11 + prf12 + 0)) +(let t63 + (Add + (Var "z") + (Var "z"))) +(let prf14 + (Fiat + (= + t63 + (Var "y")))) +(let prf15 + (Sym + (= + (Var "y") + t63) + prf14)) +(let t64 + (premises + (Congr + (= + (Var "y") + (Add t61 t61)) + (Congr + (= + (Var "y") + (Add + t61 + (Var "z"))) + prf15 + prf12 + 0) + prf12 + 1))) +(let t65 + (substitution + (z (Num 1)) + (@rewrite_var__5 + (Var "y")) + (y (Num 1)) + (x (Var "z")))) +(let prf16 + (Sym + (= (Var "y") t62) + (Rule + (= t62 (Var "y")) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t64 + t65))) +(let t66 (@rewrite_var__5 t5)) +(let prf17 + (Rule + (= t57 (Num 2)) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Rule + (= t57 t57) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t64 + t65)) + (substitution + (@rewrite_var__2 t57) + (x 1) + (y 1)))) +(let prf18 + (Congr + (= t58 t60) + (Rule + (= t58 t58) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + (premises + (Congr + (= t5 (Add t61 t62)) + prf13 + prf16 + 1)) + (substitution + (z t57) + t66 + (y (Num 1)) + (x (Var "z")))) + prf17 + 1)) +(let t67 (premises (Sym (= t60 t58) prf18))) +(let t68 + (substitution + (z t58) + (x (Num 1)) + (y (Num 2)))) +(let t69 (premises prf18)) +(let t70 + (Add + (Neg (Num 2)) + t1)) +(let prf19 + (Sym + (= + (Neg (Num 2)) + (Num -2)) + (Rule + (= + (Num -2) + (Neg (Num 2))) + (name + "(rewrite (Neg (Num n)) (Num (- 0 n)))") + (premises + (Rule + (= + (Neg + (Num 2)) + (Neg + (Num 2))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t16 + t27)) + (substitution + (@rewrite_var__4 + (Neg (Num 2))) + (n 2))))) +(let prf20 + (Sym + (= t1 (Num 7)) + (Fiat (= (Num 7) t1)))) +(let prf21 + (Sym + (= (Var "x") (Num 5)) + (Rule + (= (Num 5) (Var "x")) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= + (Var "x") + (Add (Num -2) (Num 7))) + (Congr + (= + (Var "x") + (Add (Num -2) t1)) + (Sym + (= (Var "x") t70) + (Rule + (= t70 (Var "x")) + (name + "(rewrite (Add x y) (Add y x))") + t43 + (substitution + t45 + t20 + (@rewrite_var__ + (Var "x"))))) + prf19 + 0) + prf20 + 1)) + (substitution + (@rewrite_var__2 + (Var "x")) + (x -2) + (y 7))))) +(let prf22 + (Rule + (= (Num 3) t3) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t3 (Add (Num 5) (Num -2))) + (Congr + (= + t3 + (Add (Num 5) (Neg (Num 2)))) + prf10 + prf21 + 0) + prf19 + 1)) + (substitution + (@rewrite_var__2 t3) + (x 5) + (y -2)))) +(let prf23 + (Trans + (= t58 t3) + (Sym + (= t58 (Num 3)) + (Rule + (= (Num 3) t58) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + t69 + (substitution + (@rewrite_var__2 t58) + (x 1) + (y 2)))) + prf22)) +(let prf24 + (Congr + (= t52 (Add t1 (Num 1))) + (Rule + (= t52 t52) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t3 (Add t15 t51)) + (Sym + (= t3 t55) + (Rule + (= t55 t3) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t3 (Add t24 (Neg (Num 2)))) + prf10 + prf8 + 0)) + (substitution + t29 + (y t3) + t56 + (x (Num 2))))) + prf3 + 0)) + (substitution (z t51) t21 t56 t23)) + (Trans + (= t51 (Num 1)) + (Sym + (= t51 t59) + (Congr + (= t59 t51) + (Rule + (= t59 t59) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t67 + t68) + prf23 + 0)) + (Rule + (= t59 (Num 1)) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t67 + t68)) + 1)) +(let t71 (premises prf24)) +(let t72 (@rewrite_var__1 t52)) +(let t73 + (substitution + (z (Num 1)) + (y (Num 2)) + t72 + (x (Var "x")))) +(let prf25 + (Trans + (= t53 t3) + (Rule + (= t53 t58) + (name "(rewrite (Add x y) (Add y x))") + t69 + (substitution + (y (Num 2)) + (x (Num 1)) + (@rewrite_var__ t58))) + prf23)) +(let t74 (Add (Num 2) t5)) +(let t75 (Add (Var "x") (Num 1))) +(let t76 (Add (Num 2) t75)) +(let t77 + (premises + (Congr (= t52 (Add t14 (Num 1))) prf24 prf1 0))) +(let t78 + (substitution + (z (Num 1)) + (y (Var "x")) + t72 + (x (Num 2)))) +(let t79 (Add (Num 1) (Var "x"))) +(let prf26 + (Rule + (= t79 t79) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t1 (Add t57 (Var "x"))) + prf1 + (Sym (= (Num 2) t57) prf17) + 0)) + (substitution + (z (Var "x")) + (y (Num 1)) + t22 + (x (Num 1))))) +(let prf27 (Fiat (= (Num 6) t5))) +(let t80 (Add (Var "z") t5)) +(let prop0 (= t47 t6)) +(let t81 (Add (Neg (Var "z")) (Var "z"))) +(let t82 (Add t81 (Var "z"))) +(let t83 (Add t5 t82)) +(let t84 + (Add + (Neg (Var "z")) + (Var "y"))) +(let t85 + (Add + (Var "y") + (Neg (Var "z")))) +(let prf28 + (Sym + (= (Var "z") t85) + (Rule + (= t85 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf14) + (substitution + (z (Var "y")) + (x (Var "z")) + (y (Var "z")))))) +(let t86 (y (Neg (Var "z")))) +(let t87 (@rewrite_var__1 t5)) +(let t88 (x (Neg (Var "z")))) +(let prf29 + (Rule + (= t47 t47) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t5 (Add t84 (Var "y"))) + prf11 + (Sym + (= (Var "z") t84) + (Rule + (= t84 (Var "z")) + (name + "(rewrite (Add x y) (Add y x))") + (premises prf28) + (substitution + t86 + (x (Var "y")) + (@rewrite_var__ + (Var "z"))))) + 0)) + (substitution + (z (Var "y")) + (y (Var "y")) + t87 + t88))) +(let t89 (@rewrite_var__1 t47)) +(let prf30 + (Rule + (= t80 t47) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t47 (Add t63 (Var "y"))) + prf29 + prf15 + 0)) + (substitution + (z (Var "y")) + (y (Var "z")) + t89 + (x (Var "z"))))) +(let prf31 (Sym (= t47 t80) prf30)) +(let t90 (Add (Neg (Var "y")) t5)) +(let t91 + (Add + t5 + (Neg (Var "y")))) +(let t92 (premises prf11)) +(let t93 (z t5)) +(let t94 (x t5)) +(let prf32 + (Sym + (= (Var "z") t90) + (Rule + (= t90 (Var "z")) + (name + "(rewrite (Add x y) (Add y x))") + (premises + (Sym + (= (Var "z") t91) + (Rule + (= t91 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t92 + (substitution + t93 + (x (Var "z")) + (y (Var "y")))))) + (substitution + (y (Neg (Var "y"))) + t94 + (@rewrite_var__ (Var "z")))))) +(let t95 + (premises + (Congr + (= + (Var "y") + (Add t90 (Var "z"))) + prf15 + prf32 + 0))) +(let t96 (y t5)) +(let t97 (x (Neg (Var "y")))) +(let t98 + (substitution + (z (Var "z")) + t96 + (@rewrite_var__1 (Var "y")) + t97)) +(let prf33 + (Rule + (= t6 t6) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t95 + t98)) +(let prf34 + (Rule + (= t80 t6) + (name "(rewrite (Add x y) (Add y x))") + (premises prf33) + (substitution + (y (Var "z")) + t94 + (@rewrite_var__ t6)))) +(let prop1 (= t83 t6)) +(let t99 (Add t5 t81)) +(let t100 (Add t5 (Neg (Var "z")))) +(let t101 + (Add + (Var "y") + (Var "z"))) +(let prf35 + (Rule + (= t101 t5) + (name + "(rewrite (Add x y) (Add y x))") + t92 + (substitution + (y (Var "y")) + (x (Var "z")) + (@rewrite_var__ t5)))) +(let prf36 (Sym (= t5 t101) prf35)) +(let t102 + (premises + (Congr + (= t6 (Add t99 (Var "z"))) + prf33 + (Sym + (= t5 t99) + (Rule + (= t99 t5) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t5 (Add t100 (Var "z"))) + prf36 + (Sym + (= (Var "y") t100) + (Rule + (= t100 (Var "y")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf35) + (substitution + t93 + (x (Var "y")) + (y (Var "z"))))) + 0)) + (substitution + (z (Var "z")) + t86 + t87 + t94))) + 0))) +(let t103 (@rewrite_var__1 t6)) +(let t104 + (substitution + (z (Var "z")) + (y t81) + t103 + t94)) +(let t105 (Add (Var "z") (Neg (Var "z")))) +(let t106 (Add t105 (Var "z"))) +(let t107 (Add (Var "z") t105)) +(let t108 + (premises + (Sym + (= (Var "z") t107) + (Rule + (= t107 (Var "z")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= + (Var "z") + (Add + t63 + (Neg (Var "z")))) + prf28 + prf15 + 0)) + (substitution + (z (Neg (Var "z"))) + (y (Var "z")) + (@rewrite_var__1 (Var "z")) + (x (Var "z"))))))) +(let t109 + (substitution + (y t105) + (x (Var "z")) + (@rewrite_var__ (Var "z")))) +(let t110 (Mul (Num 3) (Var "z"))) +(let t111 (Mul t3 (Var "z"))) +(let t112 (Mul t60 (Var "z"))) +(let t113 (Mul (Num 2) (Var "z"))) +(let t114 + (premises + (Congr + (= t5 (Add t61 t113)) + prf13 + (Congr + (= (Var "y") t113) + prf16 + prf17 + 0) + 1))) +(let t115 + (substitution + (z (Num 2)) + t66 + (y (Num 1)) + (x (Var "z")))) +(let t116 (Add t57 (Num 1))) +(let t117 + (premises + (Congr + (= t116 t53) + (Rule + (= t116 t116) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + (premises + (Congr + (= t5 (Add t62 t61)) + (Congr + (= + t5 + (Add t62 (Var "z"))) + prf36 + prf16 + 0) + prf12 + 1)) + (substitution + (z (Num 1)) + t66 + (y t57) + (x (Var "z")))) + prf17 + 0))) +(let prf37 (Sym (= t3 (Num 3)) prf22)) +(let prf38 + (Rule + (= (Var "z") (Num 2)) + (name + "(rule ((= (Mul (Num x) y) (Num z)) + (= (% z x) 0)) + ((union y (Num (/ z x)))) + )") + (premises + (Trans + (= t110 (Num 6)) + (Sym + (= t110 t5) + (Congr + (= t5 t110) + (Trans + (= t5 t111) + (Sym + (= t5 t112) + (Rule + (= t112 t5) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t114 + t115)) + (Congr + (= t112 t111) + (Rule + (= t112 t112) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t114 + t115) + (Trans + (= t60 t3) + (Rule + (= t60 t116) + (name + "(rewrite (Add x y) (Add y x))") + t117 + (substitution + (y (Num 1)) + (x (Num 2)) + (@rewrite_var__ t116))) + (Trans + (= t116 t3) + (Sym + (= t116 (Num 3)) + (Rule + (= (Num 3) t116) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + t117 + (substitution + (@rewrite_var__2 t116) + (x 2) + (y 1)))) + prf22)) + 0)) + prf37 + 0)) + (Sym (= t5 (Num 6)) prf27)) + (Fiat (= 0 0))) + (substitution (z 6) (x 3) (y (Var "z"))))) +(let t118 (Add (Var "z") t47)) +(let t119 (Add t6 (Var "z"))) +(let t120 (Add (Neg (Var "y")) t6)) +(let prf39 + (Sym + (= (Var "y") t120) + (Rule + (= t120 (Var "y")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t95 + t98))) +(let t121 (y t6)) +(let prf40 (Trans (= t6 t47) (Sym (= t6 t80) prf34) prf30)) +(let t122 + (premises + (Congr (= t5 (Add t90 (Var "y"))) prf11 prf32 0))) +(let t123 (substitution (z (Var "y")) t96 t87 t97)) +(let t124 (Add (Var "z") t8)) +(let t125 (Add t8 (Var "z"))) +(let t126 (Add (Neg (Var "y")) t8)) +(let prf41 + (Congr + (= t7 (Add t47 (Var "y"))) + (Rule + (= t7 t7) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr (= t47 (Add t120 (Var "y"))) prf29 prf39 0)) + (substitution (z (Var "y")) t121 t89 t97)) + prf40 + 0)) +(let t127 (Mul t53 (Var "y"))) +(let t128 (Mul (Num 2) (Var "y"))) +(let t129 (Mul (Num 1) (Var "y"))) +(let t130 (Mul t57 (Var "y"))) +(let prf42 + (Sym + (= (Var "y") t129) + (Rule + (= t129 (Var "y")) + (name + "(rule ((= x (Var v))) + ((union (Mul (Num 1) x) x)) + )") + (premises (Fiat (= (Var "y") (Var "y")))) + (substitution (v "y") (x (Var "y")))))) +(let t131 + (premises + (Congr + (= t47 (Add t129 t129)) + (Congr (= t47 (Add t129 (Var "y"))) prf29 prf42 0) + prf42 + 1))) +(let t132 + (substitution + (z (Num 1)) + (@rewrite_var__5 t47) + (y (Num 1)) + (x (Var "y")))) +(let t133 + (premises + (Congr + (= t7 (Add t128 t129)) + (Congr + (= t7 (Add t128 (Var "y"))) + prf41 + (Trans + (= t47 t128) + (Sym + (= t47 t130) + (Rule + (= t130 t47) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t131 + t132)) + (Congr + (= t130 t128) + (Rule + (= t130 t130) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t131 + t132) + prf17 + 0)) + 0) + prf42 + 1))) +(let t134 + (substitution + (z (Num 1)) + (@rewrite_var__5 t7) + (y (Num 2)) + (x (Var "y")))) +(Trans + (= t0 (Num 12)) + (Sym + (= t0 t2) + (Congr + (= t2 t0) + (Trans + (= t2 t4) + (Trans + (= t2 t7) + (Trans + (= t2 t9) + (Congr + (= t2 t11) + (Sym + (= t2 t13) + (Rule + (= t13 t2) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t2 (Add t14 (Var "x"))) prf4 prf1 0)) + (substitution + (z (Var "x")) + (y (Var "x")) + (@rewrite_var__1 t2) + (x (Num 2))))) + (Trans + (= t12 t10) + (Sym + (= t12 t25) + (Congr + (= t25 t12) + (Rule + (= t25 t25) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t34 + t36) + prf7 + 1)) + (Rule + (= t25 t10) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t34 + t36)) + 1) + (Congr + (= t11 t9) + (Rule + (= t11 t11) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= (Var "x") (Add t38 t10)) + (Sym + (= (Var "x") t39) + (Rule + (= t39 (Var "x")) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t31 + t33)) + (Trans + (= (Neg (Var "x")) t38) + (Sym + (= (Neg (Var "x")) t41) + (Rule + (= t41 (Neg (Var "x"))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t44 + t46)) + (Congr + (= t41 t38) + (Rule + (= t41 t41) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t44 + t46) + (Rule + (= t40 (Num 2)) + (name "(rewrite (Neg (Neg x)) x)") + (premises + (Rule + (= t40 t40) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf5) + (substitution (z (Var "x")) t20 t45))) + (substitution (x (Num 2)) (@rewrite_var__3 t40))) + 1)) + 0)) + (substitution + (z t10) + (y (Num 2)) + (@rewrite_var__1 (Var "x")) + (x t37))) + (Trans + (= t10 t8) + (Congr + (= t10 t48) + (Sym + (= t10 t50) + (Rule + (= t50 t10) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t10 (Add t14 t3)) prf9 prf1 0)) + (substitution t32 (y (Var "x")) t35 (x (Num 2))))) + (Trans + (= t49 t47) + (Trans + (= t49 t52) + (Sym + (= t49 t54) + (Congr + (= t54 t49) + (Rule + (= t54 t54) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t71 + t73) + prf25 + 1)) + (Rule + (= t54 t52) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t71 + t73)) + (Trans + (= t52 t47) + (Trans + (= t52 t74) + (Sym + (= t52 t76) + (Rule + (= t76 t52) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t77 + t78)) + (Congr + (= t76 t74) + (Rule + (= t76 t76) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t77 + t78) + (Trans + (= t75 t5) + (Trans + (= t75 (Num 6)) + (Rule + (= t75 t79) + (name "(rewrite (Add x y) (Add y x))") + (premises prf26) + (substitution + (y (Var "x")) + (x (Num 1)) + (@rewrite_var__ t79))) + (Rule + (= t79 (Num 6)) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t79 (Add (Num 1) (Num 5))) + prf26 + prf21 + 1)) + (substitution (@rewrite_var__2 t79) (x 1) (y 5)))) + prf27) + 1)) + (Trans + (= t74 t47) + (Sym + (= t74 t80) + (Congr + (= t80 t74) + (Rule + (= t80 t80) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Trans + prop0 + (Trans + (= t47 t83) + (Trans prop0 prf31 prf34) + (Sym + (= t6 t83) + (Rule + prop1 + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t102 + t104))) + (Congr + prop1 + (Rule + (= t83 t83) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t102 + t104) + (Trans + (= t82 (Var "z")) + (Sym + (= t82 t106) + (Congr + (= t106 t82) + (Rule + (= t106 t106) + (name + "(rewrite (Add x y) (Add y x))") + t108 + t109) + (Rule + (= t105 t81) + (name + "(rewrite (Add x y) (Add y x))") + (premises + (Rule + (= t81 t81) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= + (Var "y") + (Add t85 (Var "z"))) + prf15 + prf28 + 0)) + (substitution + (z (Var "z")) + t86 + (@rewrite_var__1 (Var "y")) + (x (Var "y"))))) + (substitution + (y (Var "z")) + t88 + (@rewrite_var__ t81))) + 0)) + (Rule + (= t106 (Var "z")) + (name "(rewrite (Add x y) (Add y x))") + t108 + t109)) + 1))) + (substitution + (y (Var "z")) + t94 + (@rewrite_var__ t47))) + prf38 + 0)) + prf30))) + 1) + (Trans + (= t48 t8) + (Sym + (= t48 t118) + (Congr + (= t118 t48) + (Rule + (= t118 t118) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Congr + (= t119 (Add t47 (Var "z"))) + (Rule + (= t119 t119) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t5 (Add t120 (Var "z"))) + prf36 + prf39 + 0)) + (substitution (z (Var "z")) t121 t87 t97)) + prf40 + 0)) + (substitution + (y (Var "z")) + (x t47) + (@rewrite_var__ t119))) + prf38 + 0)) + (Rule + (= t118 t8) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Rule + (= t8 t8) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t122 + t123)) + (substitution + (z (Var "y")) + (y (Var "y")) + (@rewrite_var__1 t8) + (x (Var "z")))))) + 1)) + (Trans + (= t9 t7) + (Sym + (= t9 t124) + (Congr + (= t124 t9) + (Rule + (= t124 t124) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Rule + (= t125 t125) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t6 (Add t126 (Var "z"))) + prf33 + (Sym + (= t5 t126) + (Rule + (= t126 t5) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t122 + t123)) + 0)) + (substitution (z (Var "z")) (y t8) t103 t97))) + (substitution (y (Var "z")) (x t8) (@rewrite_var__ t125))) + prf38 + 0)) + (Rule + (= t124 t7) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t7 (Add t80 (Var "y"))) prf41 prf31 0)) + (substitution + (z (Var "y")) + t96 + (@rewrite_var__1 t7) + (x (Var "z")))))) + (Trans + (= t7 t4) + (Sym + (= t7 t127) + (Rule + (= t127 t7) + (name "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t133 + t134)) + (Congr + (= t127 t4) + (Rule + (= t127 t127) + (name "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t133 + t134) + prf25 + 0))) + prf37 + 0)) + (Sym + (= t2 (Num 12)) + (Rule + (= (Num 12) t2) + (name "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t2 (Add (Num 7) (Num 5))) + (Congr (= t2 (Add (Num 7) (Var "x"))) prf4 prf20 0) + prf21 + 1)) + (substitution (@rewrite_var__2 t2) (x 7) (y 5))))) diff --git a/egglog/tests/snapshots/files__proof_integration__eqsolve_proof_testing.snap b/egglog/tests/snapshots/files__proof_integration__eqsolve_proof_testing.snap new file mode 100644 index 0000000..7063ce7 --- /dev/null +++ b/egglog/tests/snapshots/files__proof_integration__eqsolve_proof_testing.snap @@ -0,0 +1,6857 @@ +--- +source: egglog/tests/files.rs +expression: proof_snapshot +--- +(let t0 (Add (Num 6) (Neg (Var "y")))) +(let t1 (Mul (Num 3) (Var "z"))) +(let t2 (Add (Var "z") (Var "y"))) +(let t3 (Add (Var "x") (Neg (Num 2)))) +(let t4 (Mul t3 (Var "z"))) +(let t5 (Add (Num 1) (Num 2))) +(let t6 (Mul t5 (Var "z"))) +(let t7 (Mul (Num 1) (Var "z"))) +(let t8 (Mul (Num 2) (Var "z"))) +(let prf0 (Fiat (= t2 t2))) +(let prf1 + (Sym + (= (Var "z") t7) + (Rule + (= t7 (Var "z")) + (name + "(rule ((= x (Var v))) + ((union (Mul (Num 1) x) x)) + )") + (premises (Fiat (= (Var "z") (Var "z")))) + (substitution (v "z") (x (Var "z")))))) +(let t9 (Add (Num 1) (Num 1))) +(let t10 (Mul t9 (Var "z"))) +(let t11 (Add (Var "z") (Var "z"))) +(let t12 + (premises + (Congr + (= (Var "y") (Add t7 t7)) + (Congr + (= (Var "y") (Add t7 (Var "z"))) + (Sym + (= (Var "y") t11) + (Fiat (= t11 (Var "y")))) + prf1 + 0) + prf1 + 1))) +(let t13 + (substitution + (z (Num 1)) + (@rewrite_var__5 (Var "y")) + (y (Num 1)) + (x (Var "z")))) +(let prf2 + (Sym + (= (Var "y") t10) + (Rule + (= t10 (Var "y")) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t12 + t13))) +(let prf3 + (Rule + (= t9 (Num 2)) + (name "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Rule + (= t9 t9) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t12 + t13)) + (substitution (@rewrite_var__2 t9) (x 1) (y 1)))) +(let t14 + (premises + (Congr + (= t2 (Add t7 t8)) + (Congr (= t2 (Add t7 (Var "y"))) prf0 prf1 0) + (Congr (= (Var "y") t8) prf2 prf3 0) + 1))) +(let t15 (@rewrite_var__5 t2)) +(let t16 (substitution (z (Num 2)) t15 (y (Num 1)) (x (Var "z")))) +(let t17 (Add t9 (Num 1))) +(let t18 (Add (Var "y") (Var "z"))) +(let t19 (premises prf0)) +(let t20 + (premises + (Congr + (= t17 (Add (Num 2) (Num 1))) + (Rule + (= t17 t17) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + (premises + (Congr + (= t2 (Add t10 t7)) + (Congr + (= t2 (Add t10 (Var "z"))) + (Sym + (= t2 t18) + (Rule + (= t18 t2) + (name "(rewrite (Add x y) (Add y x))") + t19 + (substitution + (y (Var "y")) + (x (Var "z")) + (@rewrite_var__ t2)))) + prf2 + 0) + prf1 + 1)) + (substitution (z (Num 1)) t15 (y t9) (x (Var "z")))) + prf3 + 0))) +(let t21 (Add (Num 2) (Var "x"))) +(let t22 (Add (Var "x") (Num 2))) +(let t23 (Add t22 (Neg (Num 2)))) +(let t24 (premises (Fiat (= t22 t22)))) +(let t25 + (substitution + (z t22) + (x (Var "x")) + (y (Num 2)))) +(let prf4 + (Sym + (= (Var "x") t23) + (Rule + (= t23 (Var "x")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t24 + t25))) +(let t26 (Add (Neg (Num 2)) t22)) +(let prf5 + (Sym + (= (Neg (Num 2)) (Num -2)) + (Rule + (= (Num -2) (Neg (Num 2))) + (name + "(rewrite (Neg (Num n)) (Num (- 0 n)))") + (premises + (Rule + (= (Neg (Num 2)) (Neg (Num 2))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t24 + t25)) + (substitution + (@rewrite_var__4 (Neg (Num 2))) + (n 2))))) +(let prf6 + (Rule + (= (Num 3) t3) + (name "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t3 (Add (Num 5) (Num -2))) + (Congr + (= t3 (Add (Num 5) (Neg (Num 2)))) + (Rule + (= t3 t3) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= (Var "x") (Add t21 (Neg (Num 2)))) + prf4 + (Sym + (= t22 t21) + (Rule + (= t21 t22) + (name "(rewrite (Add x y) (Add y x))") + t24 + (substitution + (y (Num 2)) + (x (Var "x")) + (@rewrite_var__ t22)))) + 0)) + (substitution + (z (Neg (Num 2))) + (y (Var "x")) + (@rewrite_var__1 (Var "x")) + (x (Num 2)))) + (Sym + (= (Var "x") (Num 5)) + (Rule + (= (Num 5) (Var "x")) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= (Var "x") (Add (Num -2) (Num 7))) + (Congr + (= (Var "x") (Add (Num -2) t22)) + (Sym + (= (Var "x") t26) + (Rule + (= t26 (Var "x")) + (name "(rewrite (Add x y) (Add y x))") + (premises prf4) + (substitution + (y (Neg (Num 2))) + (x t22) + (@rewrite_var__ (Var "x"))))) + prf5 + 0) + (Sym (= t22 (Num 7)) (Fiat (= (Num 7) t22))) + 1)) + (substitution + (@rewrite_var__2 (Var "x")) + (x -2) + (y 7)))) + 0) + prf5 + 1)) + (substitution (@rewrite_var__2 t3) (x 5) (y -2)))) +(let prf7 (Sym (= t2 (Num 6)) (Fiat (= (Num 6) t2)))) +(let prf8 + (Rule + (= (Var "z") (Num 2)) + (name + "(rule ((= (Mul (Num x) y) (Num z)) + (= (% z x) 0)) + ((union y (Num (/ z x)))) + )") + (premises + (Trans + (= t1 (Num 6)) + (Sym + (= t1 t2) + (Congr + (= t2 t1) + (Trans + (= t2 t4) + (Sym + (= t2 t6) + (Rule + (= t6 t2) + (name "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t14 + t16)) + (Congr + (= t6 t4) + (Rule + (= t6 t6) + (name "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t14 + t16) + (Trans + (= t5 t3) + (Rule + (= t5 t17) + (name "(rewrite (Add x y) (Add y x))") + t20 + (substitution (y (Num 1)) (x (Num 2)) (@rewrite_var__ t17))) + (Trans + (= t17 t3) + (Sym + (= t17 (Num 3)) + (Rule + (= (Num 3) t17) + (name "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + t20 + (substitution (@rewrite_var__2 t17) (x 2) (y 1)))) + prf6)) + 0)) + (Sym (= t3 (Num 3)) prf6) + 0)) + prf7) + (Fiat (= 0 0))) + (substitution (z 6) (x 3) (y (Var "z"))))) +(let t27 (Add t2 (Neg (Var "y")))) +(Trans + (= (Var "z") t0) + prf8 + (Congr + (= (Num 2) t0) + (Trans + (= (Num 2) t27) + (Sym (= (Num 2) (Var "z")) prf8) + (Sym + (= (Var "z") t27) + (Rule + (= t27 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t19 + (substitution (z t2) (x (Var "z")) (y (Var "y")))))) + prf7 + 0)) +(let t0 (Add (Num 6) (Neg (Var "y")))) +(let t1 (Add (Num 2) (Num 2))) +(let t2 (Add (Var "z") (Var "z"))) +(let prf0 (Fiat (= t2 (Var "y")))) +(let prf1 (Sym (= (Var "y") t2) prf0)) +(let t3 (Add (Var "z") (Neg (Var "z")))) +(let t4 (Neg t3)) +(let t5 (Add t4 (Var "z"))) +(let t6 (Add (Var "z") t4)) +(let t7 (Add (Var "y") (Neg (Var "z")))) +(let t8 (Mul (Num 3) (Var "z"))) +(let t9 (Add (Var "z") (Var "y"))) +(let t10 (Add (Var "x") (Neg (Num 2)))) +(let t11 (Mul t10 (Var "z"))) +(let t12 (Add (Num 1) (Num 2))) +(let t13 (Mul t12 (Var "z"))) +(let t14 (Mul (Num 1) (Var "z"))) +(let t15 (Mul (Num 2) (Var "z"))) +(let prf2 (Fiat (= t9 t9))) +(let prf3 + (Sym + (= (Var "z") t14) + (Rule + (= t14 (Var "z")) + (name + "(rule ((= x (Var v))) + ((union (Mul (Num 1) x) x)) + )") + (premises (Fiat (= (Var "z") (Var "z")))) + (substitution (v "z") (x (Var "z")))))) +(let t16 (Add (Num 1) (Num 1))) +(let t17 (Mul t16 (Var "z"))) +(let t18 + (premises + (Congr + (= (Var "y") (Add t14 t14)) + (Congr + (= (Var "y") (Add t14 (Var "z"))) + prf1 + prf3 + 0) + prf3 + 1))) +(let t19 + (substitution + (z (Num 1)) + (@rewrite_var__5 (Var "y")) + (y (Num 1)) + (x (Var "z")))) +(let prf4 + (Sym + (= (Var "y") t17) + (Rule + (= t17 (Var "y")) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t18 + t19))) +(let prf5 + (Rule + (= t16 (Num 2)) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Rule + (= t16 t16) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t18 + t19)) + (substitution + (@rewrite_var__2 t16) + (x 1) + (y 1)))) +(let t20 + (premises + (Congr + (= t9 (Add t14 t15)) + (Congr (= t9 (Add t14 (Var "y"))) prf2 prf3 0) + (Congr (= (Var "y") t15) prf4 prf5 0) + 1))) +(let t21 (@rewrite_var__5 t9)) +(let t22 + (substitution + (z (Num 2)) + t21 + (y (Num 1)) + (x (Var "z")))) +(let t23 (Add t16 (Num 1))) +(let t24 (Add (Var "y") (Var "z"))) +(let t25 (premises prf2)) +(let t26 + (premises + (Congr + (= t23 (Add (Num 2) (Num 1))) + (Rule + (= t23 t23) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + (premises + (Congr + (= t9 (Add t17 t14)) + (Congr + (= t9 (Add t17 (Var "z"))) + (Sym + (= t9 t24) + (Rule + (= t24 t9) + (name + "(rewrite (Add x y) (Add y x))") + t25 + (substitution + (y (Var "y")) + (x (Var "z")) + (@rewrite_var__ t9)))) + prf4 + 0) + prf3 + 1)) + (substitution + (z (Num 1)) + t21 + (y t16) + (x (Var "z")))) + prf5 + 0))) +(let t27 (Add (Num 2) (Var "x"))) +(let t28 (Add (Var "x") (Num 2))) +(let t29 (Add t28 (Neg (Num 2)))) +(let t30 (premises (Fiat (= t28 t28)))) +(let t31 + (substitution + (z t28) + (x (Var "x")) + (y (Num 2)))) +(let prf6 + (Sym + (= (Var "x") t29) + (Rule + (= t29 (Var "x")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t30 + t31))) +(let t32 (Add (Neg (Num 2)) t28)) +(let prf7 + (Sym + (= (Neg (Num 2)) (Num -2)) + (Rule + (= (Num -2) (Neg (Num 2))) + (name + "(rewrite (Neg (Num n)) (Num (- 0 n)))") + (premises + (Rule + (= + (Neg (Num 2)) + (Neg (Num 2))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t30 + t31)) + (substitution + (@rewrite_var__4 + (Neg (Num 2))) + (n 2))))) +(let prf8 + (Rule + (= (Num 3) t10) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t10 (Add (Num 5) (Num -2))) + (Congr + (= t10 (Add (Num 5) (Neg (Num 2)))) + (Rule + (= t10 t10) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= (Var "x") (Add t27 (Neg (Num 2)))) + prf6 + (Sym + (= t28 t27) + (Rule + (= t27 t28) + (name + "(rewrite (Add x y) (Add y x))") + t30 + (substitution + (y (Num 2)) + (x (Var "x")) + (@rewrite_var__ t28)))) + 0)) + (substitution + (z (Neg (Num 2))) + (y (Var "x")) + (@rewrite_var__1 (Var "x")) + (x (Num 2)))) + (Sym + (= (Var "x") (Num 5)) + (Rule + (= (Num 5) (Var "x")) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= (Var "x") (Add (Num -2) (Num 7))) + (Congr + (= (Var "x") (Add (Num -2) t28)) + (Sym + (= (Var "x") t32) + (Rule + (= t32 (Var "x")) + (name + "(rewrite (Add x y) (Add y x))") + (premises prf6) + (substitution + (y (Neg (Num 2))) + (x t28) + (@rewrite_var__ (Var "x"))))) + prf7 + 0) + (Sym + (= t28 (Num 7)) + (Fiat (= (Num 7) t28))) + 1)) + (substitution + (@rewrite_var__2 (Var "x")) + (x -2) + (y 7)))) + 0) + prf7 + 1)) + (substitution (@rewrite_var__2 t10) (x 5) (y -2)))) +(let prf9 (Sym (= t9 (Num 6)) (Fiat (= (Num 6) t9)))) +(let prf10 + (Rule + (= (Var "z") (Num 2)) + (name + "(rule ((= (Mul (Num x) y) (Num z)) + (= (% z x) 0)) + ((union y (Num (/ z x)))) + )") + (premises + (Trans + (= t8 (Num 6)) + (Sym + (= t8 t9) + (Congr + (= t9 t8) + (Trans + (= t9 t11) + (Sym + (= t9 t13) + (Rule + (= t13 t9) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t20 + t22)) + (Congr + (= t13 t11) + (Rule + (= t13 t13) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t20 + t22) + (Trans + (= t12 t10) + (Rule + (= t12 t23) + (name "(rewrite (Add x y) (Add y x))") + t26 + (substitution + (y (Num 1)) + (x (Num 2)) + (@rewrite_var__ t23))) + (Trans + (= t23 t10) + (Sym + (= t23 (Num 3)) + (Rule + (= (Num 3) t23) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + t26 + (substitution (@rewrite_var__2 t23) (x 2) (y 1)))) + prf8)) + 0)) + (Sym (= t10 (Num 3)) prf8) + 0)) + prf9) + (Fiat (= 0 0))) + (substitution (z 6) (x 3) (y (Var "z"))))) +(let t33 (Add t9 (Neg (Var "y")))) +(let prf11 + (Congr + (= (Num 2) t0) + (Trans + (= (Num 2) t33) + (Sym (= (Num 2) (Var "z")) prf10) + (Sym + (= (Var "z") t33) + (Rule + (= t33 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t25 + (substitution (z t9) (x (Var "z")) (y (Var "y")))))) + prf9 + 0)) +(Congr + (= (Var "y") (Add t0 t0)) + (Congr + (= (Var "y") (Add t0 (Num 2))) + (Trans + (= (Var "y") t1) + prf1 + (Congr + (= t2 t1) + (Congr + (= t2 (Add (Num 2) (Var "z"))) + (Rule + (= t2 t2) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= (Var "y") (Add t5 (Var "z"))) + prf1 + (Sym + (= (Var "z") t5) + (Rule + (= t5 (Var "z")) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Sym + (= (Var "z") t6) + (Rule + (= t6 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises + (Rule + (= (Add (Var "z") t3) (Var "z")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= (Var "z") (Add t2 (Neg (Var "z")))) + (Sym + (= (Var "z") t7) + (Rule + (= t7 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf0) + (substitution + (z (Var "y")) + (x (Var "z")) + (y (Var "z"))))) + prf1 + 0)) + (substitution + (z (Neg (Var "z"))) + (y (Var "z")) + (@rewrite_var__1 (Var "z")) + (x (Var "z"))))) + (substitution (z (Var "z")) (x (Var "z")) (y t3))))) + (substitution + (y t4) + (x (Var "z")) + (@rewrite_var__ (Var "z"))))) + 0)) + (substitution + (z (Var "z")) + (y (Var "z")) + (@rewrite_var__1 (Var "y")) + (x t4))) + prf10 + 0) + prf10 + 1)) + prf11 + 0) + prf11 + 1) +(let t0 (Add (Num 12) (Neg (Var "y")))) +(let t1 (Add (Var "y") (Var "y"))) +(let t2 (Add t1 (Neg (Var "y")))) +(let t3 (Add (Var "z") (Var "y"))) +(let t4 (Add t3 (Var "z"))) +(let t5 (Add t4 (Neg (Var "y")))) +(let t6 (Add (Neg (Var "y")) t4)) +(let t7 (Add (Neg (Var "y")) t3)) +(let t8 (Add (Var "z") (Var "z"))) +(let prf0 (Fiat (= t8 (Var "y")))) +(let prf1 (Sym (= (Var "y") t8) prf0)) +(let t9 (Add t3 (Neg (Var "y")))) +(let prf2 (Fiat (= t3 t3))) +(let t10 (premises prf2)) +(let t11 (z t3)) +(let prf3 + (Sym + (= (Var "z") t9) + (Rule + (= t9 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t10 + (substitution t11 (x (Var "z")) (y (Var "y")))))) +(let t12 (y (Neg (Var "y")))) +(let t13 (x t3)) +(let prf4 + (Sym + (= (Var "z") t7) + (Rule + (= t7 (Var "z")) + (name "(rewrite (Add x y) (Add y x))") + (premises prf3) + (substitution t12 t13 (@rewrite_var__ (Var "z")))))) +(let t14 (premises (Congr (= (Var "y") (Add t7 (Var "z"))) prf1 prf4 0))) +(let t15 (y t3)) +(let t16 (x (Neg (Var "y")))) +(let t17 (substitution (z (Var "z")) t15 (@rewrite_var__1 (Var "y")) t16)) +(let prf5 + (Sym + (= (Var "y") t6) + (Rule + (= t6 (Var "y")) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t14 + t17))) +(let t18 (y t4)) +(let t19 (Add (Neg (Var "z")) (Var "z"))) +(let t20 (Add (Var "z") (Neg (Var "y")))) +(let t21 (Add t20 (Neg (Var "z")))) +(let t22 (Add (Var "y") t21)) +(let t23 (Add (Var "z") (Neg (Var "z")))) +(let t24 (Add (Var "y") (Neg (Var "z")))) +(let prf6 + (Sym + (= (Var "z") t24) + (Rule + (= t24 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf0) + (substitution + (z (Var "y")) + (x (Var "z")) + (y (Var "z")))))) +(let t25 (y (Neg (Var "z")))) +(let t26 (x (Neg (Var "z")))) +(let prf7 + (Rule + (= t23 t19) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Rule + (= t19 t19) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr (= (Var "y") (Add t24 (Var "z"))) prf1 prf6 0)) + (substitution + (z (Var "z")) + t25 + (@rewrite_var__1 (Var "y")) + (x (Var "y"))))) + (substitution (y (Var "z")) t26 (@rewrite_var__ t19)))) +(let t27 (Add (Var "y") t20)) +(let t28 + (premises + (Congr + (= (Var "z") (Add t8 (Neg (Var "z")))) + prf6 + prf1 + 0))) +(let t29 (z (Neg (Var "z")))) +(let t30 + (substitution + t29 + (y (Var "z")) + (@rewrite_var__1 (Var "z")) + (x (Var "z")))) +(let t31 (Add (Var "y") (Var "z"))) +(let prf8 + (Rule + (= t31 t3) + (name "(rewrite (Add x y) (Add y x))") + t10 + (substitution + (y (Var "y")) + (x (Var "z")) + (@rewrite_var__ t3)))) +(let prf9 (Sym (= t3 t31) prf8)) +(let t32 (z (Neg (Var "y")))) +(let t33 + (premises + (Congr + (= t23 (Add t27 (Neg (Var "z")))) + (Rule + (= t23 t23) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t28 + t30) + (Sym + (= (Var "z") t27) + (Rule + (= t27 (Var "z")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= (Var "z") (Add t31 (Neg (Var "y")))) + prf3 + prf9 + 0)) + (substitution + t32 + (y (Var "z")) + (@rewrite_var__1 (Var "z")) + (x (Var "y"))))) + 0))) +(let t34 + (substitution + t29 + (y t20) + (@rewrite_var__1 t23) + (x (Var "y")))) +(let t35 (Add (Neg (Var "z")) (Neg (Var "z")))) +(let t36 (Add (Neg (Var "z")) (Var "y"))) +(let prf10 + (Rule + (= t36 (Var "z")) + (name "(rewrite (Add x y) (Add y x))") + (premises prf6) + (substitution + t25 + (x (Var "y")) + (@rewrite_var__ (Var "z"))))) +(let prf11 + (Rule + (= t20 (Neg (Var "z"))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf10) + (substitution (z (Var "z")) t26 (y (Var "y"))))) +(let t37 (Add (Neg (Var "y")) (Var "z"))) +(let t38 (Add t37 (Neg (Var "z")))) +(let t39 (Add t3 t37)) +(let t40 + (premises + (Congr + (= (Var "y") (Add t9 (Var "z"))) + prf1 + prf3 + 0))) +(let t41 + (substitution + (z (Var "z")) + t12 + (@rewrite_var__1 (Var "y")) + t13)) +(let t42 + (premises + (Rule + (= t37 t37) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t40 + t41))) +(let t43 (Add (Var "z") t3)) +(let prf12 + (Rule + (= t4 t4) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t14 + t17)) +(let prf13 + (Rule + (= t43 t4) + (name "(rewrite (Add x y) (Add y x))") + (premises prf12) + (substitution (y (Var "z")) t13 (@rewrite_var__ t4)))) +(let t44 (@rewrite_var__1 t3)) +(let prf14 + (Rule + (= t1 t1) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t3 (Add t36 (Var "y"))) + prf2 + (Sym (= (Var "z") t36) prf10) + 0)) + (substitution (z (Var "y")) (y (Var "y")) t44 t26))) +(let t45 (@rewrite_var__1 t1)) +(let prf15 + (Rule + (= t43 t1) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t1 (Add t8 (Var "y"))) prf14 prf1 0)) + (substitution (z (Var "y")) (y (Var "z")) t45 (x (Var "z"))))) +(let prf16 (Trans (= t4 t1) (Sym (= t4 t43) prf13) prf15)) +(let t46 (Add (Var "x") (Num 2))) +(let t47 (Add t46 (Var "x"))) +(let t48 (Add t4 (Var "y"))) +(let t49 (Add t48 (Neg (Var "y")))) +(let t50 (Add (Neg (Var "y")) t48)) +(let t51 (premises (Congr (= t1 (Add t6 (Var "y"))) prf14 prf5 0))) +(let t52 (substitution (z (Var "y")) t18 t45 t16)) +(let t53 (@rewrite_var__ t1)) +(let t54 (Add t3 (Var "y"))) +(let t55 (Add (Num 2) t54)) +(let t56 (Add (Var "z") t54)) +(let prf17 (Sym (= t1 t43) prf15)) +(let t57 (Add t54 (Var "z"))) +(let t58 (Add (Neg (Var "y")) t54)) +(let t59 + (premises + (Congr (= t3 (Add t7 (Var "y"))) prf2 prf4 0))) +(let t60 (substitution (z (Var "y")) t15 t44 t16)) +(let t61 (@rewrite_var__1 t4)) +(let t62 (Mul (Num 3) (Var "z"))) +(let t63 (Add (Var "x") (Neg (Num 2)))) +(let t64 (Mul t63 (Var "z"))) +(let t65 (Add (Num 1) (Num 2))) +(let t66 (Mul t65 (Var "z"))) +(let t67 (Mul (Num 1) (Var "z"))) +(let t68 (Mul (Num 2) (Var "z"))) +(let prf18 + (Sym + (= (Var "z") t67) + (Rule + (= t67 (Var "z")) + (name + "(rule ((= x (Var v))) + ((union (Mul (Num 1) x) x)) + )") + (premises (Fiat (= (Var "z") (Var "z")))) + (substitution (v "z") (x (Var "z")))))) +(let prf19 (Congr (= t3 (Add t67 (Var "y"))) prf2 prf18 0)) +(let t69 (Add (Num 1) (Num 1))) +(let t70 (Mul t69 (Var "z"))) +(let t71 + (premises + (Congr + (= (Var "y") (Add t67 t67)) + (Congr + (= (Var "y") (Add t67 (Var "z"))) + prf1 + prf18 + 0) + prf18 + 1))) +(let t72 + (substitution + (z (Num 1)) + (@rewrite_var__5 (Var "y")) + (y (Num 1)) + (x (Var "z")))) +(let prf20 + (Sym + (= (Var "y") t70) + (Rule + (= t70 (Var "y")) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t71 + t72))) +(let prf21 + (Rule + (= t69 (Num 2)) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Rule + (= t69 t69) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t71 + t72)) + (substitution + (@rewrite_var__2 t69) + (x 1) + (y 1)))) +(let t73 + (premises + (Congr + (= t3 (Add t67 t68)) + prf19 + (Congr (= (Var "y") t68) prf20 prf21 0) + 1))) +(let t74 (@rewrite_var__5 t3)) +(let t75 + (substitution + (z (Num 2)) + t74 + (y (Num 1)) + (x (Var "z")))) +(let t76 (Add t69 (Num 1))) +(let t77 (Add (Num 2) (Num 1))) +(let t78 + (premises + (Congr + (= t76 t77) + (Rule + (= t76 t76) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + (premises + (Congr + (= t3 (Add t70 t67)) + (Congr + (= t3 (Add t70 (Var "z"))) + prf9 + prf20 + 0) + prf18 + 1)) + (substitution + (z (Num 1)) + t74 + (y t69) + (x (Var "z")))) + prf21 + 0))) +(let t79 (Add (Num 2) (Var "x"))) +(let t80 (Add t46 (Neg (Num 2)))) +(let t81 (premises (Fiat (= t46 t46)))) +(let t82 (z t46)) +(let t83 + (substitution + t82 + (x (Var "x")) + (y (Num 2)))) +(let prf22 + (Rule + (= t80 (Var "x")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t81 + t83)) +(let prf23 (Sym (= (Var "x") t80) prf22)) +(let prf24 + (Rule + (= t79 t46) + (name + "(rewrite (Add x y) (Add y x))") + t81 + (substitution + (y (Num 2)) + (x (Var "x")) + (@rewrite_var__ t46)))) +(let prf25 (Sym (= t46 t79) prf24)) +(let t84 + (premises + (Congr + (= + (Var "x") + (Add t79 (Neg (Num 2)))) + prf23 + prf25 + 0))) +(let t85 (z (Neg (Num 2)))) +(let t86 + (substitution + t85 + (y (Var "x")) + (@rewrite_var__1 (Var "x")) + (x (Num 2)))) +(let prf26 + (Rule + (= t63 t63) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t84 + t86)) +(let t87 (Add (Neg (Num 2)) t46)) +(let t88 (premises prf23)) +(let t89 (y (Neg (Num 2)))) +(let t90 (x t46)) +(let prf27 + (Sym + (= (Neg (Num 2)) (Num -2)) + (Rule + (= (Num -2) (Neg (Num 2))) + (name + "(rewrite (Neg (Num n)) (Num (- 0 n)))") + (premises + (Rule + (= + (Neg (Num 2)) + (Neg (Num 2))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t81 + t83)) + (substitution + (@rewrite_var__4 + (Neg (Num 2))) + (n 2))))) +(let prf28 + (Sym + (= t46 (Num 7)) + (Fiat (= (Num 7) t46)))) +(let prf29 + (Sym + (= (Var "x") (Num 5)) + (Rule + (= (Num 5) (Var "x")) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= + (Var "x") + (Add (Num -2) (Num 7))) + (Congr + (= (Var "x") (Add (Num -2) t46)) + (Sym + (= (Var "x") t87) + (Rule + (= t87 (Var "x")) + (name + "(rewrite (Add x y) (Add y x))") + t88 + (substitution + t89 + t90 + (@rewrite_var__ (Var "x"))))) + prf27 + 0) + prf28 + 1)) + (substitution + (@rewrite_var__2 (Var "x")) + (x -2) + (y 7))))) +(let prf30 + (Rule + (= (Num 3) t63) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t63 (Add (Num 5) (Num -2))) + (Congr + (= t63 (Add (Num 5) (Neg (Num 2)))) + prf26 + prf29 + 0) + prf27 + 1)) + (substitution + (@rewrite_var__2 t63) + (x 5) + (y -2)))) +(let prf31 (Fiat (= (Num 6) t3))) +(let prf32 + (Rule + (= (Var "z") (Num 2)) + (name + "(rule ((= (Mul (Num x) y) (Num z)) + (= (% z x) 0)) + ((union y (Num (/ z x)))) + )") + (premises + (Trans + (= t62 (Num 6)) + (Sym + (= t62 t3) + (Congr + (= t3 t62) + (Trans + (= t3 t64) + (Sym + (= t3 t66) + (Rule + (= t66 t3) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t73 + t75)) + (Congr + (= t66 t64) + (Rule + (= t66 t66) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t73 + t75) + (Trans + (= t65 t63) + (Rule + (= t65 t76) + (name "(rewrite (Add x y) (Add y x))") + t78 + (substitution + (y (Num 1)) + (x (Num 2)) + (@rewrite_var__ t76))) + (Trans + (= t76 t63) + (Sym + (= t76 (Num 3)) + (Rule + (= (Num 3) t76) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + t78 + (substitution + (@rewrite_var__2 t76) + (x 2) + (y 1)))) + prf30)) + 0)) + (Sym (= t63 (Num 3)) prf30) + 0)) + (Sym (= t3 (Num 6)) prf31)) + (Fiat (= 0 0))) + (substitution (z 6) (x 3) (y (Var "z"))))) +(let t91 (Add t46 t63)) +(let t92 (Add (Num 2) t91)) +(let t93 (Add (Neg (Var "x")) (Neg (Num 2)))) +(let t94 (Add t93 (Num 2))) +(let t95 (Add (Neg (Var "x")) t91)) +(let t96 (Add (Neg (Var "x")) t46)) +(let t97 (Add (Num 2) t63)) +(let prf33 + (Rule + (= t97 (Var "x")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t84 + t86)) +(let prf34 (Sym (= (Var "x") t97) prf33)) +(let t98 (Add t46 (Neg (Var "x")))) +(let prf35 + (Sym + (= (Num 2) t98) + (Rule + (= t98 (Num 2)) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf24) + (substitution + t82 + (x (Num 2)) + (y (Var "x")))))) +(let t99 (y (Neg (Var "x")))) +(let prf36 + (Sym + (= (Num 2) t96) + (Rule + (= t96 (Num 2)) + (name "(rewrite (Add x y) (Add y x))") + (premises prf35) + (substitution t99 t90 (@rewrite_var__ (Num 2)))))) +(let t100 + (premises + (Congr (= (Var "x") (Add t96 t63)) prf34 prf36 0))) +(let t101 (z t63)) +(let t102 (y t46)) +(let t103 (x (Neg (Var "x")))) +(let t104 + (substitution + t101 + t102 + (@rewrite_var__1 (Var "x")) + t103)) +(let t105 (Neg (Neg (Num 2)))) +(let t106 (Add t93 t105)) +(let t107 (Add (Num 2) (Neg (Num 2)))) +(let t108 + (premises + (Rule + (= t93 t93) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t107 (Add t98 (Neg (Num 2)))) + (Rule + (= t107 t107) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t88 + (substitution + t85 + (y (Num 2)) + (@rewrite_var__1 (Var "x")) + (x (Var "x")))) + prf35 + 0)) + (substitution t85 t99 (@rewrite_var__1 t107) t90)))) +(let t109 (substitution (z t93) t103 t89)) +(let t110 (Add (Num 2) t1)) +(let t111 (Add (Var "x") t63)) +(let t112 (Add (Num 2) t111)) +(let prf37 + (Rule + (= t91 t91) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t100 + t104)) +(let t113 (@rewrite_var__1 t91)) +(let t114 (Add t63 (Neg (Num 2)))) +(let t115 (Add t46 t114)) +(let t116 (Add (Var "x") t77)) +(let t117 (Add (Num 2) t114)) +(let t118 (@rewrite_var__1 t63)) +(let t119 (Add (Num 1) t69)) +(let t120 (Add t119 (Neg (Num 2)))) +(let prf38 + (Congr + (= t119 t65) + (Rule + (= t119 t119) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + (premises + (Congr + (= t3 (Add t67 t70)) + prf19 + prf20 + 1)) + (substitution + (z t69) + t74 + (y (Num 1)) + (x (Var "z")))) + prf21 + 1)) +(let t121 (premises (Sym (= t65 t119) prf38))) +(let t122 + (substitution + (z t119) + (x (Num 1)) + (y (Num 2)))) +(let t123 (premises prf38)) +(let prf39 + (Trans + (= t119 t63) + (Sym + (= t119 (Num 3)) + (Rule + (= (Num 3) t119) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + t123 + (substitution + (@rewrite_var__2 t119) + (x 1) + (y 2)))) + prf30)) +(let prf40 + (Congr + (= t115 (Add t46 (Num 1))) + (Rule + (= t115 t115) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t63 (Add t96 t114)) + (Sym + (= t63 t117) + (Rule + (= t117 t63) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t63 (Add t97 (Neg (Num 2)))) + prf26 + prf34 + 0)) + (substitution + t85 + (y t63) + t118 + (x (Num 2))))) + prf36 + 0)) + (substitution (z t114) t102 t118 t103)) + (Trans + (= t114 (Num 1)) + (Sym + (= t114 t120) + (Congr + (= t120 t114) + (Rule + (= t120 t120) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t121 + t122) + prf39 + 0)) + (Rule + (= t120 (Num 1)) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t121 + t122)) + 1)) +(let t124 (premises prf40)) +(let t125 (@rewrite_var__1 t115)) +(let t126 + (substitution + (z (Num 1)) + (y (Num 2)) + t125 + (x (Var "x")))) +(let t127 (Add (Num 2) t3)) +(let t128 (Add (Var "x") (Num 1))) +(let t129 (Add (Num 2) t128)) +(let t130 + (premises + (Congr (= t115 (Add t79 (Num 1))) prf40 prf25 0))) +(let t131 + (substitution + (z (Num 1)) + (y (Var "x")) + t125 + (x (Num 2)))) +(let t132 (Add (Num 1) (Var "x"))) +(let t133 (@rewrite_var__1 t46)) +(let prf41 + (Rule + (= t132 t132) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t46 (Add t69 (Var "x"))) + prf25 + (Sym (= (Num 2) t69) prf21) + 0)) + (substitution + (z (Var "x")) + (y (Num 1)) + t133 + (x (Num 1))))) +(let prop0 (= t1 t4)) +(let t134 (Add t19 (Var "z"))) +(let t135 (Add t3 t134)) +(let prop1 (= t135 t4)) +(let t136 (Add t3 t19)) +(let t137 (Add t3 (Neg (Var "z")))) +(let t138 + (premises + (Congr + (= t4 (Add t136 (Var "z"))) + prf12 + (Sym + (= t3 t136) + (Rule + (= t136 t3) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t3 (Add t137 (Var "z"))) + prf9 + (Sym + (= (Var "y") t137) + (Rule + (= t137 (Var "y")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf8) + (substitution + t11 + (x (Var "y")) + (y (Var "z"))))) + 0)) + (substitution + (z (Var "z")) + t25 + t44 + t13))) + 0))) +(let t139 + (substitution + (z (Var "z")) + (y t19) + t61 + t13)) +(let t140 (Add t23 (Var "z"))) +(let t141 (Add (Var "z") t23)) +(let t142 + (premises + (Sym + (= (Var "z") t141) + (Rule + (= t141 (Var "z")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t28 + t30)))) +(let t143 + (substitution + (y t23) + (x (Var "z")) + (@rewrite_var__ (Var "z")))) +(let t144 (Add (Var "z") t1)) +(let t145 (Add t4 (Var "z"))) +(let t146 (Add (Var "x") (Var "x"))) +(let t147 (Add (Num 2) t146)) +(let prf42 + (Rule + (= t47 t47) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr (= t46 (Add t96 (Var "x"))) prf25 prf36 0)) + (substitution (z (Var "x")) t102 t133 t103))) +(let t148 (Add (Var "x") t97)) +(let t149 (premises prf37)) +(let t150 (substitution t101 (y (Num 2)) t113 (x (Var "x")))) +(Congr + (= (Var "y") (Add t0 (Neg (Var "y")))) + (Trans + (= (Var "y") t2) + (Sym + (= (Var "y") t5) + (Rule + (= t5 (Var "y")) + (name "(rewrite (Add x y) (Add y x))") + (premises prf5) + (substitution t18 t16 (@rewrite_var__ (Var "y"))))) + (Congr + (= t5 t2) + (Rule + (= t5 t5) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t19 (Add t6 (Neg (Var "y")))) + (Congr + (= t19 (Add (Var "y") (Neg (Var "y")))) + (Trans + (= t19 t22) + (Sym (= t19 t23) prf7) + (Sym + (= t23 t22) + (Rule + (= t22 t23) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t33 + t34))) + (Trans + (= t21 (Neg (Var "y"))) + (Congr + (= t21 t35) + (Rule + (= t21 t21) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t33 + t34) + prf11 + 0) + (Trans + (= t35 (Neg (Var "y"))) + (Sym + (= t35 t38) + (Congr + (= t38 t35) + (Rule + (= t38 t38) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= (Var "z") (Add t39 (Neg (Var "z")))) + prf6 + (Sym + (= (Var "y") t39) + (Rule + (= t39 (Var "y")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t40 + t41)) + 0)) + (substitution + t29 + (y t37) + (@rewrite_var__1 (Var "z")) + t13)) + (Trans + (= t37 (Neg (Var "z"))) + (Sym + (= t37 t20) + (Rule + (= t20 t37) + (name "(rewrite (Add x y) (Add y x))") + t42 + (substitution + (y (Var "z")) + t16 + (@rewrite_var__ t37)))) + prf11) + 0)) + (Rule + (= t38 (Neg (Var "y"))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t42 + (substitution (z t37) t16 (y (Var "z")))))) + 1) + prf5 + 0)) + (substitution t32 t18 (@rewrite_var__1 t19) t16)) + prf16 + 0)) + (Congr + (= t1 t0) + (Congr + (= t1 (Add t47 (Neg (Var "y")))) + (Sym + (= t1 t49) + (Rule + (= t49 t1) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Sym + (= t1 t50) + (Rule + (= t50 t1) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t51 + t52))) + (substitution (y t48) t16 t53))) + (Trans + (= t48 t47) + (Trans + (= t48 t55) + (Sym + (= t48 t56) + (Rule + (= t56 t48) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t48 (Add t43 (Var "y"))) + (Congr + (= t48 (Add t1 (Var "y"))) + (Rule + (= t48 t48) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t51 + t52) + prf16 + 0) + prf17 + 0)) + (substitution + (z (Var "y")) + t15 + (@rewrite_var__1 t48) + (x (Var "z"))))) + (Congr + (= t56 t55) + (Rule + (= t56 t56) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Rule + (= t57 t57) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t4 (Add t58 (Var "z"))) + prf12 + (Sym + (= t3 t58) + (Rule + (= t58 t3) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t59 + t60)) + 0)) + (substitution (z (Var "z")) (y t54) t61 t16))) + (substitution (y (Var "z")) (x t54) (@rewrite_var__ t57))) + prf32 + 0)) + (Trans + (= t55 t47) + (Sym + (= t55 t92) + (Congr + (= t92 t55) + (Rule + (= t92 t92) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= (Var "x") (Add t94 t91)) + (Sym + (= (Var "x") t95) + (Rule + (= t95 (Var "x")) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t100 + t104)) + (Trans + (= (Neg (Var "x")) t94) + (Sym + (= (Neg (Var "x")) t106) + (Rule + (= t106 (Neg (Var "x"))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t108 + t109)) + (Congr + (= t106 t94) + (Rule + (= t106 t106) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t108 + t109) + (Rule + (= t105 (Num 2)) + (name "(rewrite (Neg (Neg x)) x)") + (premises + (Rule + (= t105 t105) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf22) + (substitution (z (Var "x")) t90 t89))) + (substitution (x (Num 2)) (@rewrite_var__3 t105))) + 1)) + 0)) + (substitution + (z t91) + (y (Num 2)) + (@rewrite_var__1 (Var "x")) + (x t93))) + (Trans + (= t91 t54) + (Congr + (= t91 t110) + (Sym + (= t91 t112) + (Rule + (= t112 t91) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t91 (Add t79 t63)) prf37 prf25 0)) + (substitution t101 (y (Var "x")) t113 (x (Num 2))))) + (Trans + (= t111 t1) + (Trans + (= t111 t115) + (Sym + (= t111 t116) + (Congr + (= t116 t111) + (Rule + (= t116 t116) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t124 + t126) + (Trans + (= t77 t63) + (Rule + (= t77 t119) + (name "(rewrite (Add x y) (Add y x))") + t123 + (substitution + (y (Num 2)) + (x (Num 1)) + (@rewrite_var__ t119))) + prf39) + 1)) + (Rule + (= t116 t115) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t124 + t126)) + (Trans + (= t115 t1) + (Trans + (= t115 t127) + (Sym + (= t115 t129) + (Rule + (= t129 t115) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t130 + t131)) + (Congr + (= t129 t127) + (Rule + (= t129 t129) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t130 + t131) + (Trans + (= t128 t3) + (Trans + (= t128 (Num 6)) + (Rule + (= t128 t132) + (name "(rewrite (Add x y) (Add y x))") + (premises prf41) + (substitution + (y (Var "x")) + (x (Num 1)) + (@rewrite_var__ t132))) + (Rule + (= t132 (Num 6)) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t132 (Add (Num 1) (Num 5))) + prf41 + prf29 + 1)) + (substitution + (@rewrite_var__2 t132) + (x 1) + (y 5)))) + prf31) + 1)) + (Trans + (= t127 t1) + (Sym + (= t127 t43) + (Congr + (= t43 t127) + (Rule + (= t43 t43) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Trans + prop0 + (Trans + (= t1 t135) + (Trans prop0 prf17 prf13) + (Sym + (= t4 t135) + (Rule + prop1 + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t138 + t139))) + (Congr + prop1 + (Rule + (= t135 t135) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t138 + t139) + (Trans + (= t134 (Var "z")) + (Sym + (= t134 t140) + (Congr + (= t140 t134) + (Rule + (= t140 t140) + (name + "(rewrite (Add x y) (Add y x))") + t142 + t143) + prf7 + 0)) + (Rule + (= t140 (Var "z")) + (name "(rewrite (Add x y) (Add y x))") + t142 + t143)) + 1))) + (substitution (y (Var "z")) t13 t53)) + prf32 + 0)) + prf15))) + 1) + (Trans + (= t110 t54) + (Sym + (= t110 t144) + (Congr + (= t144 t110) + (Rule + (= t144 t144) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Congr + (= t145 (Add t1 (Var "z"))) + (Rule + (= t145 t145) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr (= t3 (Add t6 (Var "z"))) prf9 prf5 0)) + (substitution (z (Var "z")) t18 t44 t16)) + prf16 + 0)) + (substitution + (y (Var "z")) + (x t1) + (@rewrite_var__ t145))) + prf32 + 0)) + (Rule + (= t144 t54) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Rule + (= t54 t54) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t59 + t60)) + (substitution + (z (Var "y")) + (y (Var "y")) + (@rewrite_var__1 t54) + (x (Var "z")))))) + 1)) + (Sym + (= t92 t47) + (Congr + (= t47 t92) + (Sym + (= t47 t147) + (Rule + (= t147 t47) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t47 (Add t79 (Var "x"))) prf42 prf25 0)) + (substitution + (z (Var "x")) + (y (Var "x")) + (@rewrite_var__1 t47) + (x (Num 2))))) + (Trans + (= t146 t91) + (Sym + (= t146 t148) + (Congr + (= t148 t146) + (Rule + (= t148 t148) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t149 + t150) + prf33 + 1)) + (Rule + (= t148 t91) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t149 + t150)) + 1)))) + 0) + (Sym + (= t47 (Num 12)) + (Rule + (= (Num 12) t47) + (name "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t47 (Add (Num 7) (Num 5))) + (Congr (= t47 (Add (Num 7) (Var "x"))) prf42 prf28 0) + prf29 + 1)) + (substitution (@rewrite_var__2 t47) (x 7) (y 5)))) + 0) + 0) +(let t0 (Add (Var "y") (Var "y"))) +(let t1 (Add (Var "x") (Num 2))) +(let t2 (Add t1 (Var "x"))) +(let t3 (Add (Var "z") (Var "y"))) +(let t4 (Add t3 (Var "z"))) +(let t5 (Add t4 (Var "y"))) +(let t6 (Add t5 (Neg (Var "y")))) +(let t7 (Add (Neg (Var "y")) t5)) +(let t8 (Add (Neg (Var "y")) t4)) +(let t9 (Add (Neg (Var "z")) (Var "y"))) +(let prf0 (Fiat (= t3 t3))) +(let t10 (Add (Var "y") (Neg (Var "z")))) +(let t11 (Add (Var "z") (Var "z"))) +(let prf1 (Fiat (= t11 (Var "y")))) +(let prf2 + (Sym + (= (Var "z") t10) + (Rule + (= t10 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf1) + (substitution + (z (Var "y")) + (x (Var "z")) + (y (Var "z")))))) +(let t12 (y (Neg (Var "z")))) +(let t13 (@rewrite_var__1 t3)) +(let t14 (x (Neg (Var "z")))) +(let prf3 + (Rule + (= t0 t0) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t3 (Add t9 (Var "y"))) + prf0 + (Sym + (= (Var "z") t9) + (Rule + (= t9 (Var "z")) + (name "(rewrite (Add x y) (Add y x))") + (premises prf2) + (substitution + t12 + (x (Var "y")) + (@rewrite_var__ (Var "z"))))) + 0)) + (substitution (z (Var "y")) (y (Var "y")) t13 t14))) +(let t15 (Add (Neg (Var "y")) t3)) +(let prf4 (Sym (= (Var "y") t11) prf1)) +(let t16 (Add t3 (Neg (Var "y")))) +(let t17 (premises prf0)) +(let t18 (z t3)) +(let t19 (x t3)) +(let prf5 + (Sym + (= (Var "z") t15) + (Rule + (= t15 (Var "z")) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Sym + (= (Var "z") t16) + (Rule + (= t16 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t17 + (substitution + t18 + (x (Var "z")) + (y (Var "y")))))) + (substitution + (y (Neg (Var "y"))) + t19 + (@rewrite_var__ (Var "z")))))) +(let t20 + (premises + (Congr (= (Var "y") (Add t15 (Var "z"))) prf4 prf5 0))) +(let t21 (y t3)) +(let t22 (x (Neg (Var "y")))) +(let t23 + (substitution + (z (Var "z")) + t21 + (@rewrite_var__1 (Var "y")) + t22)) +(let prf6 + (Sym + (= (Var "y") t8) + (Rule + (= t8 (Var "y")) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t20 + t23))) +(let t24 (premises (Congr (= t0 (Add t8 (Var "y"))) prf3 prf6 0))) +(let t25 (y t4)) +(let t26 (@rewrite_var__1 t0)) +(let t27 (substitution (z (Var "y")) t25 t26 t22)) +(let t28 (@rewrite_var__ t0)) +(let t29 (Add t3 (Var "y"))) +(let t30 (Add (Num 2) t29)) +(let t31 (Add (Var "z") t29)) +(let t32 (Add (Var "z") t3)) +(let prf7 + (Rule + (= t4 t4) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t20 + t23)) +(let prf8 + (Rule + (= t32 t4) + (name "(rewrite (Add x y) (Add y x))") + (premises prf7) + (substitution (y (Var "z")) t19 (@rewrite_var__ t4)))) +(let prf9 + (Rule + (= t32 t0) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t0 (Add t11 (Var "y"))) prf3 prf4 0)) + (substitution + (z (Var "y")) + (y (Var "z")) + t26 + (x (Var "z"))))) +(let prf10 (Trans (= t4 t0) (Sym (= t4 t32) prf8) prf9)) +(let prf11 (Sym (= t0 t32) prf9)) +(let t33 (Add t29 (Var "z"))) +(let t34 (Add (Neg (Var "y")) t29)) +(let t35 + (premises + (Congr (= t3 (Add t15 (Var "y"))) prf0 prf5 0))) +(let t36 (substitution (z (Var "y")) t21 t13 t22)) +(let t37 (@rewrite_var__1 t4)) +(let t38 (Mul (Num 3) (Var "z"))) +(let t39 (Add (Var "x") (Neg (Num 2)))) +(let t40 (Mul t39 (Var "z"))) +(let t41 (Add (Num 1) (Num 2))) +(let t42 (Mul t41 (Var "z"))) +(let t43 (Mul (Num 1) (Var "z"))) +(let t44 (Mul (Num 2) (Var "z"))) +(let prf12 + (Sym + (= (Var "z") t43) + (Rule + (= t43 (Var "z")) + (name + "(rule ((= x (Var v))) + ((union (Mul (Num 1) x) x)) + )") + (premises (Fiat (= (Var "z") (Var "z")))) + (substitution (v "z") (x (Var "z")))))) +(let prf13 (Congr (= t3 (Add t43 (Var "y"))) prf0 prf12 0)) +(let t45 (Add (Num 1) (Num 1))) +(let t46 (Mul t45 (Var "z"))) +(let t47 + (premises + (Congr + (= (Var "y") (Add t43 t43)) + (Congr + (= (Var "y") (Add t43 (Var "z"))) + prf4 + prf12 + 0) + prf12 + 1))) +(let t48 + (substitution + (z (Num 1)) + (@rewrite_var__5 (Var "y")) + (y (Num 1)) + (x (Var "z")))) +(let prf14 + (Sym + (= (Var "y") t46) + (Rule + (= t46 (Var "y")) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t47 + t48))) +(let prf15 + (Rule + (= t45 (Num 2)) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Rule + (= t45 t45) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t47 + t48)) + (substitution + (@rewrite_var__2 t45) + (x 1) + (y 1)))) +(let t49 + (premises + (Congr + (= t3 (Add t43 t44)) + prf13 + (Congr (= (Var "y") t44) prf14 prf15 0) + 1))) +(let t50 (@rewrite_var__5 t3)) +(let t51 + (substitution + (z (Num 2)) + t50 + (y (Num 1)) + (x (Var "z")))) +(let t52 (Add t45 (Num 1))) +(let t53 (Add (Num 2) (Num 1))) +(let t54 (Add (Var "y") (Var "z"))) +(let prf16 + (Rule + (= t54 t3) + (name + "(rewrite (Add x y) (Add y x))") + t17 + (substitution + (y (Var "y")) + (x (Var "z")) + (@rewrite_var__ t3)))) +(let prf17 (Sym (= t3 t54) prf16)) +(let t55 + (premises + (Congr + (= t52 t53) + (Rule + (= t52 t52) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + (premises + (Congr + (= t3 (Add t46 t43)) + (Congr + (= t3 (Add t46 (Var "z"))) + prf17 + prf14 + 0) + prf12 + 1)) + (substitution + (z (Num 1)) + t50 + (y t45) + (x (Var "z")))) + prf15 + 0))) +(let t56 (Add (Num 2) (Var "x"))) +(let t57 (Add t1 (Neg (Num 2)))) +(let t58 (premises (Fiat (= t1 t1)))) +(let t59 (z t1)) +(let t60 + (substitution + t59 + (x (Var "x")) + (y (Num 2)))) +(let prf18 + (Rule + (= t57 (Var "x")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t58 + t60)) +(let prf19 (Sym (= (Var "x") t57) prf18)) +(let prf20 + (Rule + (= t56 t1) + (name + "(rewrite (Add x y) (Add y x))") + t58 + (substitution + (y (Num 2)) + (x (Var "x")) + (@rewrite_var__ t1)))) +(let prf21 (Sym (= t1 t56) prf20)) +(let t61 + (premises + (Congr + (= (Var "x") (Add t56 (Neg (Num 2)))) + prf19 + prf21 + 0))) +(let t62 (z (Neg (Num 2)))) +(let t63 + (substitution + t62 + (y (Var "x")) + (@rewrite_var__1 (Var "x")) + (x (Num 2)))) +(let prf22 + (Rule + (= t39 t39) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t61 + t63)) +(let t64 (Add (Neg (Num 2)) t1)) +(let t65 (premises prf19)) +(let t66 (y (Neg (Num 2)))) +(let t67 (x t1)) +(let prf23 + (Sym + (= (Neg (Num 2)) (Num -2)) + (Rule + (= (Num -2) (Neg (Num 2))) + (name + "(rewrite (Neg (Num n)) (Num (- 0 n)))") + (premises + (Rule + (= + (Neg (Num 2)) + (Neg (Num 2))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t58 + t60)) + (substitution + (@rewrite_var__4 + (Neg (Num 2))) + (n 2))))) +(let prf24 + (Sym + (= t1 (Num 7)) + (Fiat (= (Num 7) t1)))) +(let prf25 + (Sym + (= (Var "x") (Num 5)) + (Rule + (= (Num 5) (Var "x")) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= (Var "x") (Add (Num -2) (Num 7))) + (Congr + (= (Var "x") (Add (Num -2) t1)) + (Sym + (= (Var "x") t64) + (Rule + (= t64 (Var "x")) + (name + "(rewrite (Add x y) (Add y x))") + t65 + (substitution + t66 + t67 + (@rewrite_var__ (Var "x"))))) + prf23 + 0) + prf24 + 1)) + (substitution + (@rewrite_var__2 (Var "x")) + (x -2) + (y 7))))) +(let prf26 + (Rule + (= (Num 3) t39) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t39 (Add (Num 5) (Num -2))) + (Congr + (= t39 (Add (Num 5) (Neg (Num 2)))) + prf22 + prf25 + 0) + prf23 + 1)) + (substitution (@rewrite_var__2 t39) (x 5) (y -2)))) +(let prf27 (Fiat (= (Num 6) t3))) +(let prf28 + (Rule + (= (Var "z") (Num 2)) + (name + "(rule ((= (Mul (Num x) y) (Num z)) + (= (% z x) 0)) + ((union y (Num (/ z x)))) + )") + (premises + (Trans + (= t38 (Num 6)) + (Sym + (= t38 t3) + (Congr + (= t3 t38) + (Trans + (= t3 t40) + (Sym + (= t3 t42) + (Rule + (= t42 t3) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t49 + t51)) + (Congr + (= t42 t40) + (Rule + (= t42 t42) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t49 + t51) + (Trans + (= t41 t39) + (Rule + (= t41 t52) + (name "(rewrite (Add x y) (Add y x))") + t55 + (substitution + (y (Num 1)) + (x (Num 2)) + (@rewrite_var__ t52))) + (Trans + (= t52 t39) + (Sym + (= t52 (Num 3)) + (Rule + (= (Num 3) t52) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + t55 + (substitution (@rewrite_var__2 t52) (x 2) (y 1)))) + prf26)) + 0)) + (Sym (= t39 (Num 3)) prf26) + 0)) + (Sym (= t3 (Num 6)) prf27)) + (Fiat (= 0 0))) + (substitution (z 6) (x 3) (y (Var "z"))))) +(let t68 (Add t1 t39)) +(let t69 (Add (Num 2) t68)) +(let t70 (Add (Neg (Var "x")) (Neg (Num 2)))) +(let t71 (Add t70 (Num 2))) +(let t72 (Add (Neg (Var "x")) t68)) +(let t73 (Add (Neg (Var "x")) t1)) +(let t74 (Add (Num 2) t39)) +(let prf29 + (Rule + (= t74 (Var "x")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t61 + t63)) +(let prf30 (Sym (= (Var "x") t74) prf29)) +(let t75 (Add t1 (Neg (Var "x")))) +(let prf31 + (Sym + (= (Num 2) t75) + (Rule + (= t75 (Num 2)) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf20) + (substitution t59 (x (Num 2)) (y (Var "x")))))) +(let t76 (y (Neg (Var "x")))) +(let prf32 + (Sym + (= (Num 2) t73) + (Rule + (= t73 (Num 2)) + (name "(rewrite (Add x y) (Add y x))") + (premises prf31) + (substitution t76 t67 (@rewrite_var__ (Num 2)))))) +(let t77 + (premises + (Congr (= (Var "x") (Add t73 t39)) prf30 prf32 0))) +(let t78 (z t39)) +(let t79 (y t1)) +(let t80 (x (Neg (Var "x")))) +(let t81 (substitution t78 t79 (@rewrite_var__1 (Var "x")) t80)) +(let t82 (Neg (Neg (Num 2)))) +(let t83 (Add t70 t82)) +(let t84 (Add (Num 2) (Neg (Num 2)))) +(let t85 + (premises + (Rule + (= t70 t70) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t84 (Add t75 (Neg (Num 2)))) + (Rule + (= t84 t84) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t65 + (substitution + t62 + (y (Num 2)) + (@rewrite_var__1 (Var "x")) + (x (Var "x")))) + prf31 + 0)) + (substitution t62 t76 (@rewrite_var__1 t84) t67)))) +(let t86 (substitution (z t70) t80 t66)) +(let t87 (Add (Num 2) t0)) +(let t88 (Add (Var "x") t39)) +(let t89 (Add (Num 2) t88)) +(let prf33 + (Rule + (= t68 t68) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t77 + t81)) +(let t90 (@rewrite_var__1 t68)) +(let t91 (Add t39 (Neg (Num 2)))) +(let t92 (Add t1 t91)) +(let t93 (Add (Var "x") t53)) +(let t94 (Add (Num 2) t91)) +(let t95 (@rewrite_var__1 t39)) +(let t96 (Add (Num 1) t45)) +(let t97 (Add t96 (Neg (Num 2)))) +(let prf34 + (Congr + (= t96 t41) + (Rule + (= t96 t96) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + (premises + (Congr + (= t3 (Add t43 t46)) + prf13 + prf14 + 1)) + (substitution + (z t45) + t50 + (y (Num 1)) + (x (Var "z")))) + prf15 + 1)) +(let t98 (premises (Sym (= t41 t96) prf34))) +(let t99 + (substitution + (z t96) + (x (Num 1)) + (y (Num 2)))) +(let t100 (premises prf34)) +(let prf35 + (Trans + (= t96 t39) + (Sym + (= t96 (Num 3)) + (Rule + (= (Num 3) t96) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + t100 + (substitution + (@rewrite_var__2 t96) + (x 1) + (y 2)))) + prf26)) +(let prf36 + (Congr + (= t92 (Add t1 (Num 1))) + (Rule + (= t92 t92) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t39 (Add t73 t91)) + (Sym + (= t39 t94) + (Rule + (= t94 t39) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t39 (Add t74 (Neg (Num 2)))) + prf22 + prf30 + 0)) + (substitution + t62 + (y t39) + t95 + (x (Num 2))))) + prf32 + 0)) + (substitution (z t91) t79 t95 t80)) + (Trans + (= t91 (Num 1)) + (Sym + (= t91 t97) + (Congr + (= t97 t91) + (Rule + (= t97 t97) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t98 + t99) + prf35 + 0)) + (Rule + (= t97 (Num 1)) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t98 + t99)) + 1)) +(let t101 (premises prf36)) +(let t102 (@rewrite_var__1 t92)) +(let t103 + (substitution + (z (Num 1)) + (y (Num 2)) + t102 + (x (Var "x")))) +(let t104 (Add (Num 2) t3)) +(let t105 (Add (Var "x") (Num 1))) +(let t106 (Add (Num 2) t105)) +(let t107 + (premises + (Congr (= t92 (Add t56 (Num 1))) prf36 prf21 0))) +(let t108 + (substitution + (z (Num 1)) + (y (Var "x")) + t102 + (x (Num 2)))) +(let t109 (Add (Num 1) (Var "x"))) +(let t110 (@rewrite_var__1 t1)) +(let prf37 + (Rule + (= t109 t109) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t1 (Add t45 (Var "x"))) + prf21 + (Sym (= (Num 2) t45) prf15) + 0)) + (substitution + (z (Var "x")) + (y (Num 1)) + t110 + (x (Num 1))))) +(let prop0 (= t0 t4)) +(let t111 (Add (Neg (Var "z")) (Var "z"))) +(let t112 (Add t111 (Var "z"))) +(let t113 (Add t3 t112)) +(let prop1 (= t113 t4)) +(let t114 (Add t3 t111)) +(let t115 (Add t3 (Neg (Var "z")))) +(let t116 + (premises + (Congr + (= t4 (Add t114 (Var "z"))) + prf7 + (Sym + (= t3 t114) + (Rule + (= t114 t3) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t3 (Add t115 (Var "z"))) + prf17 + (Sym + (= (Var "y") t115) + (Rule + (= t115 (Var "y")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf16) + (substitution + t18 + (x (Var "y")) + (y (Var "z"))))) + 0)) + (substitution + (z (Var "z")) + t12 + t13 + t19))) + 0))) +(let t117 + (substitution + (z (Var "z")) + (y t111) + t37 + t19)) +(let t118 (Add (Var "z") (Neg (Var "z")))) +(let t119 (Add t118 (Var "z"))) +(let t120 (Add (Var "z") t118)) +(let t121 + (premises + (Sym + (= (Var "z") t120) + (Rule + (= t120 (Var "z")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= + (Var "z") + (Add t11 (Neg (Var "z")))) + prf2 + prf4 + 0)) + (substitution + (z (Neg (Var "z"))) + (y (Var "z")) + (@rewrite_var__1 (Var "z")) + (x (Var "z"))))))) +(let t122 + (substitution + (y t118) + (x (Var "z")) + (@rewrite_var__ (Var "z")))) +(let t123 (Add (Var "z") t0)) +(let t124 (Add t4 (Var "z"))) +(let t125 (Add (Var "x") (Var "x"))) +(let t126 (Add (Num 2) t125)) +(let prf38 + (Rule + (= t2 t2) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr (= t1 (Add t73 (Var "x"))) prf21 prf32 0)) + (substitution (z (Var "x")) t79 t110 t80))) +(let t127 (Add (Var "x") t74)) +(let t128 (premises prf33)) +(let t129 (substitution t78 (y (Num 2)) t90 (x (Var "x")))) +(Congr + (= t0 (Add (Num 12) (Neg (Var "y")))) + (Congr + (= t0 (Add t2 (Neg (Var "y")))) + (Sym + (= t0 t6) + (Rule + (= t6 t0) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Sym + (= t0 t7) + (Rule + (= t7 t0) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t24 + t27))) + (substitution (y t5) t22 t28))) + (Trans + (= t5 t2) + (Trans + (= t5 t30) + (Sym + (= t5 t31) + (Rule + (= t31 t5) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t5 (Add t32 (Var "y"))) + (Congr + (= t5 (Add t0 (Var "y"))) + (Rule + (= t5 t5) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t24 + t27) + prf10 + 0) + prf11 + 0)) + (substitution (z (Var "y")) t21 (@rewrite_var__1 t5) (x (Var "z"))))) + (Congr + (= t31 t30) + (Rule + (= t31 t31) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Rule + (= t33 t33) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t4 (Add t34 (Var "z"))) + prf7 + (Sym + (= t3 t34) + (Rule + (= t34 t3) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t35 + t36)) + 0)) + (substitution (z (Var "z")) (y t29) t37 t22))) + (substitution (y (Var "z")) (x t29) (@rewrite_var__ t33))) + prf28 + 0)) + (Trans + (= t30 t2) + (Sym + (= t30 t69) + (Congr + (= t69 t30) + (Rule + (= t69 t69) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= (Var "x") (Add t71 t68)) + (Sym + (= (Var "x") t72) + (Rule + (= t72 (Var "x")) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t77 + t81)) + (Trans + (= (Neg (Var "x")) t71) + (Sym + (= (Neg (Var "x")) t83) + (Rule + (= t83 (Neg (Var "x"))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t85 + t86)) + (Congr + (= t83 t71) + (Rule + (= t83 t83) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t85 + t86) + (Rule + (= t82 (Num 2)) + (name "(rewrite (Neg (Neg x)) x)") + (premises + (Rule + (= t82 t82) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf18) + (substitution (z (Var "x")) t67 t66))) + (substitution (x (Num 2)) (@rewrite_var__3 t82))) + 1)) + 0)) + (substitution + (z t68) + (y (Num 2)) + (@rewrite_var__1 (Var "x")) + (x t70))) + (Trans + (= t68 t29) + (Congr + (= t68 t87) + (Sym + (= t68 t89) + (Rule + (= t89 t68) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t68 (Add t56 t39)) prf33 prf21 0)) + (substitution t78 (y (Var "x")) t90 (x (Num 2))))) + (Trans + (= t88 t0) + (Trans + (= t88 t92) + (Sym + (= t88 t93) + (Congr + (= t93 t88) + (Rule + (= t93 t93) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t101 + t103) + (Trans + (= t53 t39) + (Rule + (= t53 t96) + (name "(rewrite (Add x y) (Add y x))") + t100 + (substitution + (y (Num 2)) + (x (Num 1)) + (@rewrite_var__ t96))) + prf35) + 1)) + (Rule + (= t93 t92) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t101 + t103)) + (Trans + (= t92 t0) + (Trans + (= t92 t104) + (Sym + (= t92 t106) + (Rule + (= t106 t92) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t107 + t108)) + (Congr + (= t106 t104) + (Rule + (= t106 t106) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t107 + t108) + (Trans + (= t105 t3) + (Trans + (= t105 (Num 6)) + (Rule + (= t105 t109) + (name "(rewrite (Add x y) (Add y x))") + (premises prf37) + (substitution + (y (Var "x")) + (x (Num 1)) + (@rewrite_var__ t109))) + (Rule + (= t109 (Num 6)) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t109 (Add (Num 1) (Num 5))) + prf37 + prf25 + 1)) + (substitution (@rewrite_var__2 t109) (x 1) (y 5)))) + prf27) + 1)) + (Trans + (= t104 t0) + (Sym + (= t104 t32) + (Congr + (= t32 t104) + (Rule + (= t32 t32) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Trans + prop0 + (Trans + (= t0 t113) + (Trans prop0 prf11 prf8) + (Sym + (= t4 t113) + (Rule + prop1 + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t116 + t117))) + (Congr + prop1 + (Rule + (= t113 t113) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t116 + t117) + (Trans + (= t112 (Var "z")) + (Sym + (= t112 t119) + (Congr + (= t119 t112) + (Rule + (= t119 t119) + (name "(rewrite (Add x y) (Add y x))") + t121 + t122) + (Rule + (= t118 t111) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Rule + (= t111 t111) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= + (Var "y") + (Add t10 (Var "z"))) + prf4 + prf2 + 0)) + (substitution + (z (Var "z")) + t12 + (@rewrite_var__1 (Var "y")) + (x (Var "y"))))) + (substitution + (y (Var "z")) + t14 + (@rewrite_var__ t111))) + 0)) + (Rule + (= t119 (Var "z")) + (name "(rewrite (Add x y) (Add y x))") + t121 + t122)) + 1))) + (substitution (y (Var "z")) t19 t28)) + prf28 + 0)) + prf9))) + 1) + (Trans + (= t87 t29) + (Sym + (= t87 t123) + (Congr + (= t123 t87) + (Rule + (= t123 t123) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Congr + (= t124 (Add t0 (Var "z"))) + (Rule + (= t124 t124) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr (= t3 (Add t8 (Var "z"))) prf17 prf6 0)) + (substitution (z (Var "z")) t25 t13 t22)) + prf10 + 0)) + (substitution (y (Var "z")) (x t0) (@rewrite_var__ t124))) + prf28 + 0)) + (Rule + (= t123 t29) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Rule + (= t29 t29) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t35 + t36)) + (substitution + (z (Var "y")) + (y (Var "y")) + (@rewrite_var__1 t29) + (x (Var "z")))))) + 1)) + (Sym + (= t69 t2) + (Congr + (= t2 t69) + (Sym + (= t2 t126) + (Rule + (= t126 t2) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t2 (Add t56 (Var "x"))) prf38 prf21 0)) + (substitution + (z (Var "x")) + (y (Var "x")) + (@rewrite_var__1 t2) + (x (Num 2))))) + (Trans + (= t125 t68) + (Sym + (= t125 t127) + (Congr + (= t127 t125) + (Rule + (= t127 t127) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t128 + t129) + prf29 + 1)) + (Rule + (= t127 t68) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t128 + t129)) + 1)))) + 0) + (Sym + (= t2 (Num 12)) + (Rule + (= (Num 12) t2) + (name "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t2 (Add (Num 7) (Num 5))) + (Congr (= t2 (Add (Num 7) (Var "x"))) prf38 prf24 0) + prf25 + 1)) + (substitution (@rewrite_var__2 t2) (x 7) (y 5)))) + 0) +(let t0 (Add (Var "y") (Var "y"))) +(let t1 (Add t0 (Var "y"))) +(let t2 (Add (Var "x") (Num 2))) +(let t3 (Add t2 (Var "x"))) +(let t4 (Add (Var "z") (Var "y"))) +(let t5 (Add t4 (Var "z"))) +(let t6 (Add t5 (Var "y"))) +(let t7 (Add (Neg (Var "y")) t5)) +(let t8 (Add (Neg (Var "z")) (Var "y"))) +(let prf0 (Fiat (= t4 t4))) +(let t9 (Add (Var "y") (Neg (Var "z")))) +(let t10 (Add (Var "z") (Var "z"))) +(let prf1 (Fiat (= t10 (Var "y")))) +(let prf2 + (Sym + (= (Var "z") t9) + (Rule + (= t9 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf1) + (substitution + (z (Var "y")) + (x (Var "z")) + (y (Var "z")))))) +(let t11 (y (Neg (Var "z")))) +(let t12 (@rewrite_var__1 t4)) +(let t13 (x (Neg (Var "z")))) +(let prf3 + (Rule + (= t0 t0) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t4 (Add t8 (Var "y"))) + prf0 + (Sym + (= (Var "z") t8) + (Rule + (= t8 (Var "z")) + (name "(rewrite (Add x y) (Add y x))") + (premises prf2) + (substitution + t11 + (x (Var "y")) + (@rewrite_var__ (Var "z"))))) + 0)) + (substitution (z (Var "y")) (y (Var "y")) t12 t13))) +(let t14 (Add (Neg (Var "y")) t4)) +(let prf4 (Sym (= (Var "y") t10) prf1)) +(let t15 (Add t4 (Neg (Var "y")))) +(let t16 (premises prf0)) +(let t17 (z t4)) +(let t18 (x t4)) +(let prf5 + (Sym + (= (Var "z") t14) + (Rule + (= t14 (Var "z")) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Sym + (= (Var "z") t15) + (Rule + (= t15 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t16 + (substitution t17 (x (Var "z")) (y (Var "y")))))) + (substitution + (y (Neg (Var "y"))) + t18 + (@rewrite_var__ (Var "z")))))) +(let t19 + (premises + (Congr (= (Var "y") (Add t14 (Var "z"))) prf4 prf5 0))) +(let t20 (y t4)) +(let t21 (x (Neg (Var "y")))) +(let t22 + (substitution + (z (Var "z")) + t20 + (@rewrite_var__1 (Var "y")) + t21)) +(let prf6 + (Sym + (= (Var "y") t7) + (Rule + (= t7 (Var "y")) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t19 + t22))) +(let t23 (y t5)) +(let t24 (@rewrite_var__1 t0)) +(let t25 (Add (Var "z") t4)) +(let prf7 + (Rule + (= t5 t5) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t19 + t22)) +(let prf8 + (Rule + (= t25 t5) + (name "(rewrite (Add x y) (Add y x))") + (premises prf7) + (substitution (y (Var "z")) t18 (@rewrite_var__ t5)))) +(let prf9 + (Rule + (= t25 t0) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t0 (Add t10 (Var "y"))) prf3 prf4 0)) + (substitution (z (Var "y")) (y (Var "z")) t24 (x (Var "z"))))) +(let prf10 (Trans (= t5 t0) (Sym (= t5 t25) prf8) prf9)) +(let prf11 + (Congr + (= t6 t1) + (Rule + (= t6 t6) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t0 (Add t7 (Var "y"))) prf3 prf6 0)) + (substitution (z (Var "y")) t23 t24 t21)) + prf10 + 0)) +(let t26 (Add t4 (Var "y"))) +(let t27 (Add (Num 2) t26)) +(let t28 (Add (Var "z") t26)) +(let prf12 (Sym (= t0 t25) prf9)) +(let t29 (Add t26 (Var "z"))) +(let t30 (Add (Neg (Var "y")) t26)) +(let t31 + (premises + (Congr (= t4 (Add t14 (Var "y"))) prf0 prf5 0))) +(let t32 (substitution (z (Var "y")) t20 t12 t21)) +(let t33 (@rewrite_var__1 t5)) +(let t34 (Mul (Num 3) (Var "z"))) +(let t35 (Add (Var "x") (Neg (Num 2)))) +(let t36 (Mul t35 (Var "z"))) +(let t37 (Add (Num 1) (Num 2))) +(let t38 (Mul t37 (Var "z"))) +(let t39 (Mul (Num 1) (Var "z"))) +(let t40 (Mul (Num 2) (Var "z"))) +(let prf13 + (Sym + (= (Var "z") t39) + (Rule + (= t39 (Var "z")) + (name + "(rule ((= x (Var v))) + ((union (Mul (Num 1) x) x)) + )") + (premises (Fiat (= (Var "z") (Var "z")))) + (substitution (v "z") (x (Var "z")))))) +(let prf14 (Congr (= t4 (Add t39 (Var "y"))) prf0 prf13 0)) +(let t41 (Add (Num 1) (Num 1))) +(let t42 (Mul t41 (Var "z"))) +(let t43 + (premises + (Congr + (= (Var "y") (Add t39 t39)) + (Congr + (= (Var "y") (Add t39 (Var "z"))) + prf4 + prf13 + 0) + prf13 + 1))) +(let t44 + (substitution + (z (Num 1)) + (@rewrite_var__5 (Var "y")) + (y (Num 1)) + (x (Var "z")))) +(let prf15 + (Sym + (= (Var "y") t42) + (Rule + (= t42 (Var "y")) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t43 + t44))) +(let prf16 + (Rule + (= t41 (Num 2)) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Rule + (= t41 t41) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t43 + t44)) + (substitution + (@rewrite_var__2 t41) + (x 1) + (y 1)))) +(let t45 + (premises + (Congr + (= t4 (Add t39 t40)) + prf14 + (Congr (= (Var "y") t40) prf15 prf16 0) + 1))) +(let t46 (@rewrite_var__5 t4)) +(let t47 + (substitution + (z (Num 2)) + t46 + (y (Num 1)) + (x (Var "z")))) +(let t48 (Add t41 (Num 1))) +(let t49 (Add (Num 2) (Num 1))) +(let t50 (Add (Var "y") (Var "z"))) +(let prf17 + (Rule + (= t50 t4) + (name + "(rewrite (Add x y) (Add y x))") + t16 + (substitution + (y (Var "y")) + (x (Var "z")) + (@rewrite_var__ t4)))) +(let prf18 (Sym (= t4 t50) prf17)) +(let t51 + (premises + (Congr + (= t48 t49) + (Rule + (= t48 t48) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + (premises + (Congr + (= t4 (Add t42 t39)) + (Congr + (= t4 (Add t42 (Var "z"))) + prf18 + prf15 + 0) + prf13 + 1)) + (substitution + (z (Num 1)) + t46 + (y t41) + (x (Var "z")))) + prf16 + 0))) +(let t52 (Add (Num 2) (Var "x"))) +(let t53 (Add t2 (Neg (Num 2)))) +(let t54 (premises (Fiat (= t2 t2)))) +(let t55 (z t2)) +(let t56 + (substitution + t55 + (x (Var "x")) + (y (Num 2)))) +(let prf19 + (Rule + (= t53 (Var "x")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t54 + t56)) +(let prf20 (Sym (= (Var "x") t53) prf19)) +(let prf21 + (Rule + (= t52 t2) + (name + "(rewrite (Add x y) (Add y x))") + t54 + (substitution + (y (Num 2)) + (x (Var "x")) + (@rewrite_var__ t2)))) +(let prf22 (Sym (= t2 t52) prf21)) +(let t57 + (premises + (Congr + (= (Var "x") (Add t52 (Neg (Num 2)))) + prf20 + prf22 + 0))) +(let t58 (z (Neg (Num 2)))) +(let t59 + (substitution + t58 + (y (Var "x")) + (@rewrite_var__1 (Var "x")) + (x (Num 2)))) +(let prf23 + (Rule + (= t35 t35) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t57 + t59)) +(let t60 (Add (Neg (Num 2)) t2)) +(let t61 (premises prf20)) +(let t62 (y (Neg (Num 2)))) +(let t63 (x t2)) +(let prf24 + (Sym + (= (Neg (Num 2)) (Num -2)) + (Rule + (= (Num -2) (Neg (Num 2))) + (name + "(rewrite (Neg (Num n)) (Num (- 0 n)))") + (premises + (Rule + (= + (Neg (Num 2)) + (Neg (Num 2))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t54 + t56)) + (substitution + (@rewrite_var__4 + (Neg (Num 2))) + (n 2))))) +(let prf25 + (Sym + (= t2 (Num 7)) + (Fiat (= (Num 7) t2)))) +(let prf26 + (Sym + (= (Var "x") (Num 5)) + (Rule + (= (Num 5) (Var "x")) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= (Var "x") (Add (Num -2) (Num 7))) + (Congr + (= (Var "x") (Add (Num -2) t2)) + (Sym + (= (Var "x") t60) + (Rule + (= t60 (Var "x")) + (name + "(rewrite (Add x y) (Add y x))") + t61 + (substitution + t62 + t63 + (@rewrite_var__ (Var "x"))))) + prf24 + 0) + prf25 + 1)) + (substitution + (@rewrite_var__2 (Var "x")) + (x -2) + (y 7))))) +(let prf27 + (Rule + (= (Num 3) t35) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t35 (Add (Num 5) (Num -2))) + (Congr + (= t35 (Add (Num 5) (Neg (Num 2)))) + prf23 + prf26 + 0) + prf24 + 1)) + (substitution (@rewrite_var__2 t35) (x 5) (y -2)))) +(let prf28 (Fiat (= (Num 6) t4))) +(let prf29 + (Rule + (= (Var "z") (Num 2)) + (name + "(rule ((= (Mul (Num x) y) (Num z)) + (= (% z x) 0)) + ((union y (Num (/ z x)))) + )") + (premises + (Trans + (= t34 (Num 6)) + (Sym + (= t34 t4) + (Congr + (= t4 t34) + (Trans + (= t4 t36) + (Sym + (= t4 t38) + (Rule + (= t38 t4) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t45 + t47)) + (Congr + (= t38 t36) + (Rule + (= t38 t38) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t45 + t47) + (Trans + (= t37 t35) + (Rule + (= t37 t48) + (name "(rewrite (Add x y) (Add y x))") + t51 + (substitution + (y (Num 1)) + (x (Num 2)) + (@rewrite_var__ t48))) + (Trans + (= t48 t35) + (Sym + (= t48 (Num 3)) + (Rule + (= (Num 3) t48) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + t51 + (substitution (@rewrite_var__2 t48) (x 2) (y 1)))) + prf27)) + 0)) + (Sym (= t35 (Num 3)) prf27) + 0)) + (Sym (= t4 (Num 6)) prf28)) + (Fiat (= 0 0))) + (substitution (z 6) (x 3) (y (Var "z"))))) +(let t64 (Add t2 t35)) +(let t65 (Add (Num 2) t64)) +(let t66 (Add (Neg (Var "x")) (Neg (Num 2)))) +(let t67 (Add t66 (Num 2))) +(let t68 (Add (Neg (Var "x")) t64)) +(let t69 (Add (Neg (Var "x")) t2)) +(let t70 (Add (Num 2) t35)) +(let prf30 + (Rule + (= t70 (Var "x")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t57 + t59)) +(let prf31 (Sym (= (Var "x") t70) prf30)) +(let t71 (Add t2 (Neg (Var "x")))) +(let prf32 + (Sym + (= (Num 2) t71) + (Rule + (= t71 (Num 2)) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf21) + (substitution t55 (x (Num 2)) (y (Var "x")))))) +(let t72 (y (Neg (Var "x")))) +(let prf33 + (Sym + (= (Num 2) t69) + (Rule + (= t69 (Num 2)) + (name "(rewrite (Add x y) (Add y x))") + (premises prf32) + (substitution t72 t63 (@rewrite_var__ (Num 2)))))) +(let t73 + (premises + (Congr (= (Var "x") (Add t69 t35)) prf31 prf33 0))) +(let t74 (z t35)) +(let t75 (y t2)) +(let t76 (x (Neg (Var "x")))) +(let t77 (substitution t74 t75 (@rewrite_var__1 (Var "x")) t76)) +(let t78 (Neg (Neg (Num 2)))) +(let t79 (Add t66 t78)) +(let t80 (Add (Num 2) (Neg (Num 2)))) +(let t81 + (premises + (Rule + (= t66 t66) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t80 (Add t71 (Neg (Num 2)))) + (Rule + (= t80 t80) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t61 + (substitution + t58 + (y (Num 2)) + (@rewrite_var__1 (Var "x")) + (x (Var "x")))) + prf32 + 0)) + (substitution t58 t72 (@rewrite_var__1 t80) t63)))) +(let t82 (substitution (z t66) t76 t62)) +(let t83 (Add (Num 2) t0)) +(let t84 (Add (Var "x") t35)) +(let t85 (Add (Num 2) t84)) +(let prf34 + (Rule + (= t64 t64) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t73 + t77)) +(let t86 (@rewrite_var__1 t64)) +(let t87 (Add t35 (Neg (Num 2)))) +(let t88 (Add t2 t87)) +(let t89 (Add (Var "x") t49)) +(let t90 (Add (Num 2) t87)) +(let t91 (@rewrite_var__1 t35)) +(let t92 (Add (Num 1) t41)) +(let t93 (Add t92 (Neg (Num 2)))) +(let prf35 + (Congr + (= t92 t37) + (Rule + (= t92 t92) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + (premises + (Congr + (= t4 (Add t39 t42)) + prf14 + prf15 + 1)) + (substitution + (z t41) + t46 + (y (Num 1)) + (x (Var "z")))) + prf16 + 1)) +(let t94 (premises (Sym (= t37 t92) prf35))) +(let t95 + (substitution + (z t92) + (x (Num 1)) + (y (Num 2)))) +(let t96 (premises prf35)) +(let prf36 + (Trans + (= t92 t35) + (Sym + (= t92 (Num 3)) + (Rule + (= (Num 3) t92) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + t96 + (substitution + (@rewrite_var__2 t92) + (x 1) + (y 2)))) + prf27)) +(let prf37 + (Congr + (= t88 (Add t2 (Num 1))) + (Rule + (= t88 t88) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t35 (Add t69 t87)) + (Sym + (= t35 t90) + (Rule + (= t90 t35) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t35 (Add t70 (Neg (Num 2)))) + prf23 + prf31 + 0)) + (substitution + t58 + (y t35) + t91 + (x (Num 2))))) + prf33 + 0)) + (substitution (z t87) t75 t91 t76)) + (Trans + (= t87 (Num 1)) + (Sym + (= t87 t93) + (Congr + (= t93 t87) + (Rule + (= t93 t93) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t94 + t95) + prf36 + 0)) + (Rule + (= t93 (Num 1)) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t94 + t95)) + 1)) +(let t97 (premises prf37)) +(let t98 (@rewrite_var__1 t88)) +(let t99 + (substitution + (z (Num 1)) + (y (Num 2)) + t98 + (x (Var "x")))) +(let t100 (Add (Num 2) t4)) +(let t101 (Add (Var "x") (Num 1))) +(let t102 (Add (Num 2) t101)) +(let t103 + (premises + (Congr (= t88 (Add t52 (Num 1))) prf37 prf22 0))) +(let t104 + (substitution + (z (Num 1)) + (y (Var "x")) + t98 + (x (Num 2)))) +(let t105 (Add (Num 1) (Var "x"))) +(let t106 (@rewrite_var__1 t2)) +(let prf38 + (Rule + (= t105 t105) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t2 (Add t41 (Var "x"))) + prf22 + (Sym (= (Num 2) t41) prf16) + 0)) + (substitution + (z (Var "x")) + (y (Num 1)) + t106 + (x (Num 1))))) +(let prop0 (= t0 t5)) +(let t107 (Add (Neg (Var "z")) (Var "z"))) +(let t108 (Add t107 (Var "z"))) +(let t109 (Add t4 t108)) +(let prop1 (= t109 t5)) +(let t110 (Add t4 t107)) +(let t111 (Add t4 (Neg (Var "z")))) +(let t112 + (premises + (Congr + (= t5 (Add t110 (Var "z"))) + prf7 + (Sym + (= t4 t110) + (Rule + (= t110 t4) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t4 (Add t111 (Var "z"))) + prf18 + (Sym + (= (Var "y") t111) + (Rule + (= t111 (Var "y")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf17) + (substitution + t17 + (x (Var "y")) + (y (Var "z"))))) + 0)) + (substitution + (z (Var "z")) + t11 + t12 + t18))) + 0))) +(let t113 + (substitution + (z (Var "z")) + (y t107) + t33 + t18)) +(let t114 (Add (Var "z") (Neg (Var "z")))) +(let t115 (Add t114 (Var "z"))) +(let t116 (Add (Var "z") t114)) +(let t117 + (premises + (Sym + (= (Var "z") t116) + (Rule + (= t116 (Var "z")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= + (Var "z") + (Add t10 (Neg (Var "z")))) + prf2 + prf4 + 0)) + (substitution + (z (Neg (Var "z"))) + (y (Var "z")) + (@rewrite_var__1 (Var "z")) + (x (Var "z"))))))) +(let t118 + (substitution + (y t114) + (x (Var "z")) + (@rewrite_var__ (Var "z")))) +(let t119 (Add (Var "z") t0)) +(let t120 (Add t5 (Var "z"))) +(let t121 (Add (Var "x") (Var "x"))) +(let t122 (Add (Num 2) t121)) +(let prf39 + (Rule + (= t3 t3) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr (= t2 (Add t69 (Var "x"))) prf22 prf33 0)) + (substitution (z (Var "x")) t75 t106 t76))) +(let t123 (Add (Var "x") t70)) +(let t124 (premises prf34)) +(let t125 (substitution t74 (y (Num 2)) t86 (x (Var "x")))) +(Trans + (= t1 (Num 12)) + (Trans + (= t1 t3) + (Sym (= t1 t6) prf11) + (Trans + (= t6 t3) + (Trans + (= t6 t27) + (Sym + (= t6 t28) + (Rule + (= t28 t6) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t6 (Add t25 (Var "y"))) prf11 prf12 0)) + (substitution (z (Var "y")) t20 (@rewrite_var__1 t6) (x (Var "z"))))) + (Congr + (= t28 t27) + (Rule + (= t28 t28) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Rule + (= t29 t29) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t5 (Add t30 (Var "z"))) + prf7 + (Sym + (= t4 t30) + (Rule + (= t30 t4) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t31 + t32)) + 0)) + (substitution (z (Var "z")) (y t26) t33 t21))) + (substitution (y (Var "z")) (x t26) (@rewrite_var__ t29))) + prf29 + 0)) + (Trans + (= t27 t3) + (Sym + (= t27 t65) + (Congr + (= t65 t27) + (Rule + (= t65 t65) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= (Var "x") (Add t67 t64)) + (Sym + (= (Var "x") t68) + (Rule + (= t68 (Var "x")) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t73 + t77)) + (Trans + (= (Neg (Var "x")) t67) + (Sym + (= (Neg (Var "x")) t79) + (Rule + (= t79 (Neg (Var "x"))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t81 + t82)) + (Congr + (= t79 t67) + (Rule + (= t79 t79) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t81 + t82) + (Rule + (= t78 (Num 2)) + (name "(rewrite (Neg (Neg x)) x)") + (premises + (Rule + (= t78 t78) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf19) + (substitution (z (Var "x")) t63 t62))) + (substitution (x (Num 2)) (@rewrite_var__3 t78))) + 1)) + 0)) + (substitution + (z t64) + (y (Num 2)) + (@rewrite_var__1 (Var "x")) + (x t66))) + (Trans + (= t64 t26) + (Congr + (= t64 t83) + (Sym + (= t64 t85) + (Rule + (= t85 t64) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t64 (Add t52 t35)) prf34 prf22 0)) + (substitution t74 (y (Var "x")) t86 (x (Num 2))))) + (Trans + (= t84 t0) + (Trans + (= t84 t88) + (Sym + (= t84 t89) + (Congr + (= t89 t84) + (Rule + (= t89 t89) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t97 + t99) + (Trans + (= t49 t35) + (Rule + (= t49 t92) + (name "(rewrite (Add x y) (Add y x))") + t96 + (substitution + (y (Num 2)) + (x (Num 1)) + (@rewrite_var__ t92))) + prf36) + 1)) + (Rule + (= t89 t88) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t97 + t99)) + (Trans + (= t88 t0) + (Trans + (= t88 t100) + (Sym + (= t88 t102) + (Rule + (= t102 t88) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t103 + t104)) + (Congr + (= t102 t100) + (Rule + (= t102 t102) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t103 + t104) + (Trans + (= t101 t4) + (Trans + (= t101 (Num 6)) + (Rule + (= t101 t105) + (name "(rewrite (Add x y) (Add y x))") + (premises prf38) + (substitution + (y (Var "x")) + (x (Num 1)) + (@rewrite_var__ t105))) + (Rule + (= t105 (Num 6)) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t105 (Add (Num 1) (Num 5))) + prf38 + prf26 + 1)) + (substitution (@rewrite_var__2 t105) (x 1) (y 5)))) + prf28) + 1)) + (Trans + (= t100 t0) + (Sym + (= t100 t25) + (Congr + (= t25 t100) + (Rule + (= t25 t25) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Trans + prop0 + (Trans + (= t0 t109) + (Trans prop0 prf12 prf8) + (Sym + (= t5 t109) + (Rule + prop1 + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t112 + t113))) + (Congr + prop1 + (Rule + (= t109 t109) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t112 + t113) + (Trans + (= t108 (Var "z")) + (Sym + (= t108 t115) + (Congr + (= t115 t108) + (Rule + (= t115 t115) + (name "(rewrite (Add x y) (Add y x))") + t117 + t118) + (Rule + (= t114 t107) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Rule + (= t107 t107) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= + (Var "y") + (Add t9 (Var "z"))) + prf4 + prf2 + 0)) + (substitution + (z (Var "z")) + t11 + (@rewrite_var__1 (Var "y")) + (x (Var "y"))))) + (substitution + (y (Var "z")) + t13 + (@rewrite_var__ t107))) + 0)) + (Rule + (= t115 (Var "z")) + (name "(rewrite (Add x y) (Add y x))") + t117 + t118)) + 1))) + (substitution (y (Var "z")) t18 (@rewrite_var__ t0))) + prf29 + 0)) + prf9))) + 1) + (Trans + (= t83 t26) + (Sym + (= t83 t119) + (Congr + (= t119 t83) + (Rule + (= t119 t119) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Congr + (= t120 (Add t0 (Var "z"))) + (Rule + (= t120 t120) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr (= t4 (Add t7 (Var "z"))) prf18 prf6 0)) + (substitution (z (Var "z")) t23 t12 t21)) + prf10 + 0)) + (substitution (y (Var "z")) (x t0) (@rewrite_var__ t120))) + prf29 + 0)) + (Rule + (= t119 t26) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Rule + (= t26 t26) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t31 + t32)) + (substitution + (z (Var "y")) + (y (Var "y")) + (@rewrite_var__1 t26) + (x (Var "z")))))) + 1)) + (Sym + (= t65 t3) + (Congr + (= t3 t65) + (Sym + (= t3 t122) + (Rule + (= t122 t3) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t3 (Add t52 (Var "x"))) prf39 prf22 0)) + (substitution + (z (Var "x")) + (y (Var "x")) + (@rewrite_var__1 t3) + (x (Num 2))))) + (Trans + (= t121 t64) + (Sym + (= t121 t123) + (Congr + (= t123 t121) + (Rule + (= t123 t123) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t124 + t125) + prf30 + 1)) + (Rule + (= t123 t64) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t124 + t125)) + 1))))) + (Sym + (= t3 (Num 12)) + (Rule + (= (Num 12) t3) + (name "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t3 (Add (Num 7) (Num 5))) + (Congr (= t3 (Add (Num 7) (Var "x"))) prf39 prf25 0) + prf26 + 1)) + (substitution (@rewrite_var__2 t3) (x 7) (y 5))))) +(let t0 (Mul (Num 2) (Var "y"))) +(let t1 (Add t0 (Var "y"))) +(let t2 (Add (Var "x") (Num 2))) +(let t3 (Add t2 (Var "x"))) +(let t4 (Add (Var "y") (Var "y"))) +(let t5 (Add t4 (Var "y"))) +(let t6 (Add (Var "z") (Var "y"))) +(let t7 (Add t6 (Var "z"))) +(let t8 (Add t7 (Var "y"))) +(let t9 (Add t6 (Var "y"))) +(let t10 (Add (Num 2) t9)) +(let t11 (Add (Var "x") (Neg (Num 2)))) +(let t12 (Add t2 t11)) +(let t13 (Add (Num 2) t12)) +(let t14 (Add (Var "x") (Var "x"))) +(let t15 (Add (Num 2) t14)) +(let t16 (Add (Num 2) (Var "x"))) +(let t17 (Add (Neg (Var "x")) t2)) +(let t18 (premises (Fiat (= t2 t2)))) +(let prf0 + (Rule + (= t16 t2) + (name "(rewrite (Add x y) (Add y x))") + t18 + (substitution + (y (Num 2)) + (x (Var "x")) + (@rewrite_var__ t2)))) +(let prf1 (Sym (= t2 t16) prf0)) +(let t19 (Add t2 (Neg (Var "x")))) +(let t20 (z t2)) +(let prf2 + (Sym + (= (Num 2) t19) + (Rule + (= t19 (Num 2)) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf0) + (substitution + t20 + (x (Num 2)) + (y (Var "x")))))) +(let t21 (y (Neg (Var "x")))) +(let t22 (x t2)) +(let prf3 + (Sym + (= (Num 2) t17) + (Rule + (= t17 (Num 2)) + (name "(rewrite (Add x y) (Add y x))") + (premises prf2) + (substitution t21 t22 (@rewrite_var__ (Num 2)))))) +(let t23 (y t2)) +(let t24 (@rewrite_var__1 t2)) +(let t25 (x (Neg (Var "x")))) +(let prf4 + (Rule + (= t3 t3) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr (= t2 (Add t17 (Var "x"))) prf1 prf3 0)) + (substitution (z (Var "x")) t23 t24 t25))) +(let t26 (Add (Num 2) t11)) +(let t27 (Add (Var "x") t26)) +(let t28 (Add t2 (Neg (Num 2)))) +(let t29 + (substitution + t20 + (x (Var "x")) + (y (Num 2)))) +(let prf5 + (Rule + (= t28 (Var "x")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t18 + t29)) +(let prf6 (Sym (= (Var "x") t28) prf5)) +(let t30 + (premises + (Congr + (= (Var "x") (Add t16 (Neg (Num 2)))) + prf6 + prf1 + 0))) +(let t31 (z (Neg (Num 2)))) +(let t32 + (substitution + t31 + (y (Var "x")) + (@rewrite_var__1 (Var "x")) + (x (Num 2)))) +(let prf7 + (Rule + (= t26 (Var "x")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t30 + t32)) +(let prf8 (Sym (= (Var "x") t26) prf7)) +(let t33 + (premises + (Congr (= (Var "x") (Add t17 t11)) prf8 prf3 0))) +(let t34 (z t11)) +(let t35 (substitution t34 t23 (@rewrite_var__1 (Var "x")) t25)) +(let prf9 + (Rule + (= t12 t12) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t33 + t35)) +(let t36 (premises prf9)) +(let t37 (@rewrite_var__1 t12)) +(let t38 (substitution t34 (y (Num 2)) t37 (x (Var "x")))) +(let t39 (Add (Neg (Var "x")) (Neg (Num 2)))) +(let t40 (Add t39 (Num 2))) +(let t41 (Add (Neg (Var "x")) t12)) +(let t42 (Neg (Neg (Num 2)))) +(let t43 (Add t39 t42)) +(let t44 (Add (Num 2) (Neg (Num 2)))) +(let t45 (premises prf6)) +(let t46 + (premises + (Rule + (= t39 t39) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t44 (Add t19 (Neg (Num 2)))) + (Rule + (= t44 t44) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t45 + (substitution + t31 + (y (Num 2)) + (@rewrite_var__1 (Var "x")) + (x (Var "x")))) + prf2 + 0)) + (substitution t31 t21 (@rewrite_var__1 t44) t22)))) +(let t47 (y (Neg (Num 2)))) +(let t48 (substitution (z t39) t25 t47)) +(let t49 (Add (Num 2) t4)) +(let t50 (Add (Var "x") t11)) +(let t51 (Add (Num 2) t50)) +(let t52 (Add t11 (Neg (Num 2)))) +(let t53 (Add t2 t52)) +(let t54 (Add (Num 2) (Num 1))) +(let t55 (Add (Var "x") t54)) +(let t56 (Add (Num 2) t52)) +(let prf10 + (Rule + (= t11 t11) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t30 + t32)) +(let t57 (@rewrite_var__1 t11)) +(let t58 (Add (Num 1) (Num 1))) +(let t59 (Add (Num 1) t58)) +(let t60 (Add t59 (Neg (Num 2)))) +(let t61 (Add (Num 1) (Num 2))) +(let t62 (Mul (Num 1) (Var "z"))) +(let t63 (Mul t58 (Var "z"))) +(let prf11 (Fiat (= t6 t6))) +(let prf12 + (Sym + (= (Var "z") t62) + (Rule + (= t62 (Var "z")) + (name + "(rule ((= x (Var v))) + ((union (Mul (Num 1) x) x)) + )") + (premises + (Fiat + (= + (Var "z") + (Var "z")))) + (substitution + (v "z") + (x (Var "z")))))) +(let prf13 + (Congr + (= t6 (Add t62 (Var "y"))) + prf11 + prf12 + 0)) +(let t64 + (Add + (Var "z") + (Var "z"))) +(let prf14 + (Fiat + (= + t64 + (Var "y")))) +(let prf15 + (Sym + (= + (Var "y") + t64) + prf14)) +(let t65 + (premises + (Congr + (= + (Var "y") + (Add t62 t62)) + (Congr + (= + (Var "y") + (Add + t62 + (Var "z"))) + prf15 + prf12 + 0) + prf12 + 1))) +(let t66 + (substitution + (z (Num 1)) + (@rewrite_var__5 + (Var "y")) + (y (Num 1)) + (x (Var "z")))) +(let prf16 + (Sym + (= (Var "y") t63) + (Rule + (= t63 (Var "y")) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t65 + t66))) +(let t67 (@rewrite_var__5 t6)) +(let prf17 + (Rule + (= t58 (Num 2)) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Rule + (= t58 t58) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t65 + t66)) + (substitution + (@rewrite_var__2 t58) + (x 1) + (y 1)))) +(let prf18 + (Congr + (= t59 t61) + (Rule + (= t59 t59) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + (premises + (Congr + (= t6 (Add t62 t63)) + prf13 + prf16 + 1)) + (substitution + (z t58) + t67 + (y (Num 1)) + (x (Var "z")))) + prf17 + 1)) +(let t68 (premises (Sym (= t61 t59) prf18))) +(let t69 + (substitution + (z t59) + (x (Num 1)) + (y (Num 2)))) +(let t70 (premises prf18)) +(let t71 + (Add + (Neg (Num 2)) + t2)) +(let prf19 + (Sym + (= + (Neg (Num 2)) + (Num -2)) + (Rule + (= + (Num -2) + (Neg (Num 2))) + (name + "(rewrite (Neg (Num n)) (Num (- 0 n)))") + (premises + (Rule + (= + (Neg + (Num 2)) + (Neg + (Num 2))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t18 + t29)) + (substitution + (@rewrite_var__4 + (Neg (Num 2))) + (n 2))))) +(let prf20 + (Sym + (= t2 (Num 7)) + (Fiat (= (Num 7) t2)))) +(let prf21 + (Sym + (= (Var "x") (Num 5)) + (Rule + (= (Num 5) (Var "x")) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= + (Var "x") + (Add (Num -2) (Num 7))) + (Congr + (= + (Var "x") + (Add (Num -2) t2)) + (Sym + (= (Var "x") t71) + (Rule + (= t71 (Var "x")) + (name + "(rewrite (Add x y) (Add y x))") + t45 + (substitution + t47 + t22 + (@rewrite_var__ + (Var "x"))))) + prf19 + 0) + prf20 + 1)) + (substitution + (@rewrite_var__2 + (Var "x")) + (x -2) + (y 7))))) +(let prf22 + (Rule + (= (Num 3) t11) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t11 (Add (Num 5) (Num -2))) + (Congr + (= + t11 + (Add (Num 5) (Neg (Num 2)))) + prf10 + prf21 + 0) + prf19 + 1)) + (substitution + (@rewrite_var__2 t11) + (x 5) + (y -2)))) +(let prf23 + (Trans + (= t59 t11) + (Sym + (= t59 (Num 3)) + (Rule + (= (Num 3) t59) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + t70 + (substitution + (@rewrite_var__2 t59) + (x 1) + (y 2)))) + prf22)) +(let prf24 + (Congr + (= t53 (Add t2 (Num 1))) + (Rule + (= t53 t53) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t11 (Add t17 t52)) + (Sym + (= t11 t56) + (Rule + (= t56 t11) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t11 (Add t26 (Neg (Num 2)))) + prf10 + prf8 + 0)) + (substitution + t31 + (y t11) + t57 + (x (Num 2))))) + prf3 + 0)) + (substitution (z t52) t23 t57 t25)) + (Trans + (= t52 (Num 1)) + (Sym + (= t52 t60) + (Congr + (= t60 t52) + (Rule + (= t60 t60) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t68 + t69) + prf23 + 0)) + (Rule + (= t60 (Num 1)) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t68 + t69)) + 1)) +(let t72 (premises prf24)) +(let t73 (@rewrite_var__1 t53)) +(let t74 + (substitution + (z (Num 1)) + (y (Num 2)) + t73 + (x (Var "x")))) +(let t75 (Add (Num 2) t6)) +(let t76 (Add (Var "x") (Num 1))) +(let t77 (Add (Num 2) t76)) +(let t78 + (premises + (Congr (= t53 (Add t16 (Num 1))) prf24 prf1 0))) +(let t79 + (substitution + (z (Num 1)) + (y (Var "x")) + t73 + (x (Num 2)))) +(let t80 (Add (Num 1) (Var "x"))) +(let prf25 + (Rule + (= t80 t80) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t2 (Add t58 (Var "x"))) + prf1 + (Sym (= (Num 2) t58) prf17) + 0)) + (substitution + (z (Var "x")) + (y (Num 1)) + t24 + (x (Num 1))))) +(let prf26 (Fiat (= (Num 6) t6))) +(let t81 (Add (Var "z") t6)) +(let prop0 (= t4 t7)) +(let t82 (Add (Neg (Var "z")) (Var "z"))) +(let t83 (Add t82 (Var "z"))) +(let t84 (Add t6 t83)) +(let t85 + (Add + (Neg (Var "z")) + (Var "y"))) +(let t86 + (Add + (Var "y") + (Neg (Var "z")))) +(let prf27 + (Sym + (= (Var "z") t86) + (Rule + (= t86 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf14) + (substitution + (z (Var "y")) + (x (Var "z")) + (y (Var "z")))))) +(let t87 (y (Neg (Var "z")))) +(let t88 (@rewrite_var__1 t6)) +(let t89 (x (Neg (Var "z")))) +(let prf28 + (Rule + (= t4 t4) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t6 (Add t85 (Var "y"))) + prf11 + (Sym + (= (Var "z") t85) + (Rule + (= t85 (Var "z")) + (name + "(rewrite (Add x y) (Add y x))") + (premises prf27) + (substitution + t87 + (x (Var "y")) + (@rewrite_var__ + (Var "z"))))) + 0)) + (substitution + (z (Var "y")) + (y (Var "y")) + t88 + t89))) +(let t90 (@rewrite_var__1 t4)) +(let prf29 + (Rule + (= t81 t4) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t4 (Add t64 (Var "y"))) + prf28 + prf15 + 0)) + (substitution + (z (Var "y")) + (y (Var "z")) + t90 + (x (Var "z"))))) +(let prf30 (Sym (= t4 t81) prf29)) +(let t91 (Add (Neg (Var "y")) t6)) +(let t92 + (Add + t6 + (Neg (Var "y")))) +(let t93 (premises prf11)) +(let t94 (z t6)) +(let t95 (x t6)) +(let prf31 + (Sym + (= (Var "z") t91) + (Rule + (= t91 (Var "z")) + (name + "(rewrite (Add x y) (Add y x))") + (premises + (Sym + (= (Var "z") t92) + (Rule + (= t92 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t93 + (substitution + t94 + (x (Var "z")) + (y (Var "y")))))) + (substitution + (y (Neg (Var "y"))) + t95 + (@rewrite_var__ (Var "z")))))) +(let t96 + (premises + (Congr + (= + (Var "y") + (Add t91 (Var "z"))) + prf15 + prf31 + 0))) +(let t97 (y t6)) +(let t98 (x (Neg (Var "y")))) +(let t99 + (substitution + (z (Var "z")) + t97 + (@rewrite_var__1 (Var "y")) + t98)) +(let prf32 + (Rule + (= t7 t7) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t96 + t99)) +(let prf33 + (Rule + (= t81 t7) + (name "(rewrite (Add x y) (Add y x))") + (premises prf32) + (substitution + (y (Var "z")) + t95 + (@rewrite_var__ t7)))) +(let prop1 (= t84 t7)) +(let t100 (Add t6 t82)) +(let t101 (Add t6 (Neg (Var "z")))) +(let t102 + (Add + (Var "y") + (Var "z"))) +(let prf34 + (Rule + (= t102 t6) + (name + "(rewrite (Add x y) (Add y x))") + t93 + (substitution + (y (Var "y")) + (x (Var "z")) + (@rewrite_var__ t6)))) +(let prf35 (Sym (= t6 t102) prf34)) +(let t103 + (premises + (Congr + (= t7 (Add t100 (Var "z"))) + prf32 + (Sym + (= t6 t100) + (Rule + (= t100 t6) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t6 (Add t101 (Var "z"))) + prf35 + (Sym + (= (Var "y") t101) + (Rule + (= t101 (Var "y")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf34) + (substitution + t94 + (x (Var "y")) + (y (Var "z"))))) + 0)) + (substitution + (z (Var "z")) + t87 + t88 + t95))) + 0))) +(let t104 (@rewrite_var__1 t7)) +(let t105 + (substitution + (z (Var "z")) + (y t82) + t104 + t95)) +(let t106 (Add (Var "z") (Neg (Var "z")))) +(let t107 (Add t106 (Var "z"))) +(let t108 (Add (Var "z") t106)) +(let t109 + (premises + (Sym + (= (Var "z") t108) + (Rule + (= t108 (Var "z")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= + (Var "z") + (Add + t64 + (Neg (Var "z")))) + prf27 + prf15 + 0)) + (substitution + (z (Neg (Var "z"))) + (y (Var "z")) + (@rewrite_var__1 (Var "z")) + (x (Var "z"))))))) +(let t110 + (substitution + (y t106) + (x (Var "z")) + (@rewrite_var__ (Var "z")))) +(let t111 (Mul (Num 3) (Var "z"))) +(let t112 (Mul t11 (Var "z"))) +(let t113 (Mul t61 (Var "z"))) +(let t114 (Mul (Num 2) (Var "z"))) +(let t115 + (premises + (Congr + (= t6 (Add t62 t114)) + prf13 + (Congr + (= (Var "y") t114) + prf16 + prf17 + 0) + 1))) +(let t116 + (substitution + (z (Num 2)) + t67 + (y (Num 1)) + (x (Var "z")))) +(let t117 (Add t58 (Num 1))) +(let t118 + (premises + (Congr + (= t117 t54) + (Rule + (= t117 t117) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + (premises + (Congr + (= t6 (Add t63 t62)) + (Congr + (= + t6 + (Add t63 (Var "z"))) + prf35 + prf16 + 0) + prf12 + 1)) + (substitution + (z (Num 1)) + t67 + (y t58) + (x (Var "z")))) + prf17 + 0))) +(let prf36 + (Rule + (= (Var "z") (Num 2)) + (name + "(rule ((= (Mul (Num x) y) (Num z)) + (= (% z x) 0)) + ((union y (Num (/ z x)))) + )") + (premises + (Trans + (= t111 (Num 6)) + (Sym + (= t111 t6) + (Congr + (= t6 t111) + (Trans + (= t6 t112) + (Sym + (= t6 t113) + (Rule + (= t113 t6) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t115 + t116)) + (Congr + (= t113 t112) + (Rule + (= t113 t113) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t115 + t116) + (Trans + (= t61 t11) + (Rule + (= t61 t117) + (name + "(rewrite (Add x y) (Add y x))") + t118 + (substitution + (y (Num 1)) + (x (Num 2)) + (@rewrite_var__ t117))) + (Trans + (= t117 t11) + (Sym + (= t117 (Num 3)) + (Rule + (= (Num 3) t117) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + t118 + (substitution + (@rewrite_var__2 t117) + (x 2) + (y 1)))) + prf22)) + 0)) + (Sym (= t11 (Num 3)) prf22) + 0)) + (Sym (= t6 (Num 6)) prf26)) + (Fiat (= 0 0))) + (substitution (z 6) (x 3) (y (Var "z"))))) +(let t119 (Add (Var "z") t4)) +(let t120 (Add t7 (Var "z"))) +(let t121 (Add (Neg (Var "y")) t7)) +(let prf37 + (Sym + (= (Var "y") t121) + (Rule + (= t121 (Var "y")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t96 + t99))) +(let t122 (y t7)) +(let prf38 (Trans (= t7 t4) (Sym (= t7 t81) prf33) prf29)) +(let t123 + (premises + (Congr (= t6 (Add t91 (Var "y"))) prf11 prf31 0))) +(let t124 (substitution (z (Var "y")) t97 t88 t98)) +(let t125 (Add (Var "z") t9)) +(let t126 (Add t9 (Var "z"))) +(let t127 (Add (Neg (Var "y")) t9)) +(let prf39 + (Congr + (= t8 t5) + (Rule + (= t8 t8) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr (= t4 (Add t121 (Var "y"))) prf28 prf37 0)) + (substitution (z (Var "y")) t122 t90 t98)) + prf38 + 0)) +(let t128 (Mul t58 (Var "y"))) +(let t129 (Mul (Num 1) (Var "y"))) +(let prf40 + (Sym + (= (Var "y") t129) + (Rule + (= t129 (Var "y")) + (name + "(rule ((= x (Var v))) + ((union (Mul (Num 1) x) x)) + )") + (premises (Fiat (= (Var "y") (Var "y")))) + (substitution (v "y") (x (Var "y")))))) +(let t130 + (premises + (Congr + (= t4 (Add t129 t129)) + (Congr (= t4 (Add t129 (Var "y"))) prf28 prf40 0) + prf40 + 1))) +(let t131 + (substitution + (z (Num 1)) + (@rewrite_var__5 t4) + (y (Num 1)) + (x (Var "y")))) +(Trans + (= t1 (Num 12)) + (Sym + (= t1 t3) + (Congr + (= t3 t1) + (Trans + (= t3 t5) + (Trans + (= t3 t8) + (Trans + (= t3 t10) + (Congr + (= t3 t13) + (Sym + (= t3 t15) + (Rule + (= t15 t3) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t3 (Add t16 (Var "x"))) prf4 prf1 0)) + (substitution + (z (Var "x")) + (y (Var "x")) + (@rewrite_var__1 t3) + (x (Num 2))))) + (Trans + (= t14 t12) + (Sym + (= t14 t27) + (Congr + (= t27 t14) + (Rule + (= t27 t27) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t36 + t38) + prf7 + 1)) + (Rule + (= t27 t12) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t36 + t38)) + 1) + (Congr + (= t13 t10) + (Rule + (= t13 t13) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= (Var "x") (Add t40 t12)) + (Sym + (= (Var "x") t41) + (Rule + (= t41 (Var "x")) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t33 + t35)) + (Trans + (= (Neg (Var "x")) t40) + (Sym + (= (Neg (Var "x")) t43) + (Rule + (= t43 (Neg (Var "x"))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t46 + t48)) + (Congr + (= t43 t40) + (Rule + (= t43 t43) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t46 + t48) + (Rule + (= t42 (Num 2)) + (name "(rewrite (Neg (Neg x)) x)") + (premises + (Rule + (= t42 t42) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf5) + (substitution (z (Var "x")) t22 t47))) + (substitution (x (Num 2)) (@rewrite_var__3 t42))) + 1)) + 0)) + (substitution + (z t12) + (y (Num 2)) + (@rewrite_var__1 (Var "x")) + (x t39))) + (Trans + (= t12 t9) + (Congr + (= t12 t49) + (Sym + (= t12 t51) + (Rule + (= t51 t12) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t12 (Add t16 t11)) prf9 prf1 0)) + (substitution t34 (y (Var "x")) t37 (x (Num 2))))) + (Trans + (= t50 t4) + (Trans + (= t50 t53) + (Sym + (= t50 t55) + (Congr + (= t55 t50) + (Rule + (= t55 t55) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t72 + t74) + (Trans + (= t54 t11) + (Rule + (= t54 t59) + (name "(rewrite (Add x y) (Add y x))") + t70 + (substitution + (y (Num 2)) + (x (Num 1)) + (@rewrite_var__ t59))) + prf23) + 1)) + (Rule + (= t55 t53) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t72 + t74)) + (Trans + (= t53 t4) + (Trans + (= t53 t75) + (Sym + (= t53 t77) + (Rule + (= t77 t53) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t78 + t79)) + (Congr + (= t77 t75) + (Rule + (= t77 t77) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t78 + t79) + (Trans + (= t76 t6) + (Trans + (= t76 (Num 6)) + (Rule + (= t76 t80) + (name "(rewrite (Add x y) (Add y x))") + (premises prf25) + (substitution + (y (Var "x")) + (x (Num 1)) + (@rewrite_var__ t80))) + (Rule + (= t80 (Num 6)) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t80 (Add (Num 1) (Num 5))) + prf25 + prf21 + 1)) + (substitution (@rewrite_var__2 t80) (x 1) (y 5)))) + prf26) + 1)) + (Trans + (= t75 t4) + (Sym + (= t75 t81) + (Congr + (= t81 t75) + (Rule + (= t81 t81) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Trans + prop0 + (Trans + (= t4 t84) + (Trans prop0 prf30 prf33) + (Sym + (= t7 t84) + (Rule + prop1 + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t103 + t105))) + (Congr + prop1 + (Rule + (= t84 t84) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t103 + t105) + (Trans + (= t83 (Var "z")) + (Sym + (= t83 t107) + (Congr + (= t107 t83) + (Rule + (= t107 t107) + (name + "(rewrite (Add x y) (Add y x))") + t109 + t110) + (Rule + (= t106 t82) + (name + "(rewrite (Add x y) (Add y x))") + (premises + (Rule + (= t82 t82) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= + (Var "y") + (Add t86 (Var "z"))) + prf15 + prf27 + 0)) + (substitution + (z (Var "z")) + t87 + (@rewrite_var__1 (Var "y")) + (x (Var "y"))))) + (substitution + (y (Var "z")) + t89 + (@rewrite_var__ t82))) + 0)) + (Rule + (= t107 (Var "z")) + (name "(rewrite (Add x y) (Add y x))") + t109 + t110)) + 1))) + (substitution + (y (Var "z")) + t95 + (@rewrite_var__ t4))) + prf36 + 0)) + prf29))) + 1) + (Trans + (= t49 t9) + (Sym + (= t49 t119) + (Congr + (= t119 t49) + (Rule + (= t119 t119) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Congr + (= t120 (Add t4 (Var "z"))) + (Rule + (= t120 t120) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t6 (Add t121 (Var "z"))) + prf35 + prf37 + 0)) + (substitution (z (Var "z")) t122 t88 t98)) + prf38 + 0)) + (substitution + (y (Var "z")) + (x t4) + (@rewrite_var__ t120))) + prf36 + 0)) + (Rule + (= t119 t9) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Rule + (= t9 t9) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t123 + t124)) + (substitution + (z (Var "y")) + (y (Var "y")) + (@rewrite_var__1 t9) + (x (Var "z")))))) + 1)) + (Trans + (= t10 t8) + (Sym + (= t10 t125) + (Congr + (= t125 t10) + (Rule + (= t125 t125) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Rule + (= t126 t126) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t7 (Add t127 (Var "z"))) + prf32 + (Sym + (= t6 t127) + (Rule + (= t127 t6) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t123 + t124)) + 0)) + (substitution (z (Var "z")) (y t9) t104 t98))) + (substitution (y (Var "z")) (x t9) (@rewrite_var__ t126))) + prf36 + 0)) + (Rule + (= t125 t8) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t8 (Add t81 (Var "y"))) prf39 prf30 0)) + (substitution + (z (Var "y")) + t97 + (@rewrite_var__1 t8) + (x (Var "z")))))) + prf39) + (Trans + (= t4 t0) + (Sym + (= t4 t128) + (Rule + (= t128 t4) + (name "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t130 + t131)) + (Congr + (= t128 t0) + (Rule + (= t128 t128) + (name "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t130 + t131) + prf17 + 0)) + 0)) + (Sym + (= t3 (Num 12)) + (Rule + (= (Num 12) t3) + (name "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t3 (Add (Num 7) (Num 5))) + (Congr (= t3 (Add (Num 7) (Var "x"))) prf4 prf20 0) + prf21 + 1)) + (substitution (@rewrite_var__2 t3) (x 7) (y 5))))) +(let t0 (Mul (Num 3) (Var "y"))) +(let t1 (Add (Var "x") (Num 2))) +(let t2 (Add t1 (Var "x"))) +(let t3 (Add (Var "x") (Neg (Num 2)))) +(let t4 (Mul t3 (Var "y"))) +(let t5 (Add (Var "z") (Var "y"))) +(let t6 (Add t5 (Var "z"))) +(let t7 (Add t6 (Var "y"))) +(let t8 (Add t5 (Var "y"))) +(let t9 (Add (Num 2) t8)) +(let t10 (Add t1 t3)) +(let t11 (Add (Num 2) t10)) +(let t12 (Add (Var "x") (Var "x"))) +(let t13 (Add (Num 2) t12)) +(let t14 (Add (Num 2) (Var "x"))) +(let t15 (Add (Neg (Var "x")) t1)) +(let t16 (premises (Fiat (= t1 t1)))) +(let prf0 + (Rule + (= t14 t1) + (name "(rewrite (Add x y) (Add y x))") + t16 + (substitution + (y (Num 2)) + (x (Var "x")) + (@rewrite_var__ t1)))) +(let prf1 (Sym (= t1 t14) prf0)) +(let t17 (Add t1 (Neg (Var "x")))) +(let t18 (z t1)) +(let prf2 + (Sym + (= (Num 2) t17) + (Rule + (= t17 (Num 2)) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf0) + (substitution + t18 + (x (Num 2)) + (y (Var "x")))))) +(let t19 (y (Neg (Var "x")))) +(let t20 (x t1)) +(let prf3 + (Sym + (= (Num 2) t15) + (Rule + (= t15 (Num 2)) + (name "(rewrite (Add x y) (Add y x))") + (premises prf2) + (substitution t19 t20 (@rewrite_var__ (Num 2)))))) +(let t21 (y t1)) +(let t22 (@rewrite_var__1 t1)) +(let t23 (x (Neg (Var "x")))) +(let prf4 + (Rule + (= t2 t2) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr (= t1 (Add t15 (Var "x"))) prf1 prf3 0)) + (substitution (z (Var "x")) t21 t22 t23))) +(let t24 (Add (Num 2) t3)) +(let t25 (Add (Var "x") t24)) +(let t26 (Add t1 (Neg (Num 2)))) +(let t27 + (substitution + t18 + (x (Var "x")) + (y (Num 2)))) +(let prf5 + (Rule + (= t26 (Var "x")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t16 + t27)) +(let prf6 (Sym (= (Var "x") t26) prf5)) +(let t28 + (premises + (Congr + (= (Var "x") (Add t14 (Neg (Num 2)))) + prf6 + prf1 + 0))) +(let t29 (z (Neg (Num 2)))) +(let t30 + (substitution + t29 + (y (Var "x")) + (@rewrite_var__1 (Var "x")) + (x (Num 2)))) +(let prf7 + (Rule + (= t24 (Var "x")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t28 + t30)) +(let prf8 (Sym (= (Var "x") t24) prf7)) +(let t31 + (premises + (Congr (= (Var "x") (Add t15 t3)) prf8 prf3 0))) +(let t32 (z t3)) +(let t33 (substitution t32 t21 (@rewrite_var__1 (Var "x")) t23)) +(let prf9 + (Rule + (= t10 t10) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t31 + t33)) +(let t34 (premises prf9)) +(let t35 (@rewrite_var__1 t10)) +(let t36 (substitution t32 (y (Num 2)) t35 (x (Var "x")))) +(let t37 (Add (Neg (Var "x")) (Neg (Num 2)))) +(let t38 (Add t37 (Num 2))) +(let t39 (Add (Neg (Var "x")) t10)) +(let t40 (Neg (Neg (Num 2)))) +(let t41 (Add t37 t40)) +(let t42 (Add (Num 2) (Neg (Num 2)))) +(let t43 (premises prf6)) +(let t44 + (premises + (Rule + (= t37 t37) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t42 (Add t17 (Neg (Num 2)))) + (Rule + (= t42 t42) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t43 + (substitution + t29 + (y (Num 2)) + (@rewrite_var__1 (Var "x")) + (x (Var "x")))) + prf2 + 0)) + (substitution t29 t19 (@rewrite_var__1 t42) t20)))) +(let t45 (y (Neg (Num 2)))) +(let t46 (substitution (z t37) t23 t45)) +(let t47 (Add (Var "y") (Var "y"))) +(let t48 (Add (Num 2) t47)) +(let t49 (Add (Var "x") t3)) +(let t50 (Add (Num 2) t49)) +(let t51 (Add t3 (Neg (Num 2)))) +(let t52 (Add t1 t51)) +(let t53 (Add (Num 2) (Num 1))) +(let t54 (Add (Var "x") t53)) +(let t55 (Add (Num 2) t51)) +(let prf10 + (Rule + (= t3 t3) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t28 + t30)) +(let t56 (@rewrite_var__1 t3)) +(let t57 (Add (Num 1) (Num 1))) +(let t58 (Add (Num 1) t57)) +(let t59 (Add t58 (Neg (Num 2)))) +(let t60 (Add (Num 1) (Num 2))) +(let t61 (Mul (Num 1) (Var "z"))) +(let t62 (Mul t57 (Var "z"))) +(let prf11 (Fiat (= t5 t5))) +(let prf12 + (Sym + (= (Var "z") t61) + (Rule + (= t61 (Var "z")) + (name + "(rule ((= x (Var v))) + ((union (Mul (Num 1) x) x)) + )") + (premises + (Fiat + (= + (Var "z") + (Var "z")))) + (substitution + (v "z") + (x (Var "z")))))) +(let prf13 + (Congr + (= t5 (Add t61 (Var "y"))) + prf11 + prf12 + 0)) +(let t63 + (Add + (Var "z") + (Var "z"))) +(let prf14 + (Fiat + (= + t63 + (Var "y")))) +(let prf15 + (Sym + (= + (Var "y") + t63) + prf14)) +(let t64 + (premises + (Congr + (= + (Var "y") + (Add t61 t61)) + (Congr + (= + (Var "y") + (Add + t61 + (Var "z"))) + prf15 + prf12 + 0) + prf12 + 1))) +(let t65 + (substitution + (z (Num 1)) + (@rewrite_var__5 + (Var "y")) + (y (Num 1)) + (x (Var "z")))) +(let prf16 + (Sym + (= (Var "y") t62) + (Rule + (= t62 (Var "y")) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t64 + t65))) +(let t66 (@rewrite_var__5 t5)) +(let prf17 + (Rule + (= t57 (Num 2)) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Rule + (= t57 t57) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t64 + t65)) + (substitution + (@rewrite_var__2 t57) + (x 1) + (y 1)))) +(let prf18 + (Congr + (= t58 t60) + (Rule + (= t58 t58) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + (premises + (Congr + (= t5 (Add t61 t62)) + prf13 + prf16 + 1)) + (substitution + (z t57) + t66 + (y (Num 1)) + (x (Var "z")))) + prf17 + 1)) +(let t67 (premises (Sym (= t60 t58) prf18))) +(let t68 + (substitution + (z t58) + (x (Num 1)) + (y (Num 2)))) +(let t69 (premises prf18)) +(let t70 + (Add + (Neg (Num 2)) + t1)) +(let prf19 + (Sym + (= + (Neg (Num 2)) + (Num -2)) + (Rule + (= + (Num -2) + (Neg (Num 2))) + (name + "(rewrite (Neg (Num n)) (Num (- 0 n)))") + (premises + (Rule + (= + (Neg + (Num 2)) + (Neg + (Num 2))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t16 + t27)) + (substitution + (@rewrite_var__4 + (Neg (Num 2))) + (n 2))))) +(let prf20 + (Sym + (= t1 (Num 7)) + (Fiat (= (Num 7) t1)))) +(let prf21 + (Sym + (= (Var "x") (Num 5)) + (Rule + (= (Num 5) (Var "x")) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= + (Var "x") + (Add (Num -2) (Num 7))) + (Congr + (= + (Var "x") + (Add (Num -2) t1)) + (Sym + (= (Var "x") t70) + (Rule + (= t70 (Var "x")) + (name + "(rewrite (Add x y) (Add y x))") + t43 + (substitution + t45 + t20 + (@rewrite_var__ + (Var "x"))))) + prf19 + 0) + prf20 + 1)) + (substitution + (@rewrite_var__2 + (Var "x")) + (x -2) + (y 7))))) +(let prf22 + (Rule + (= (Num 3) t3) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t3 (Add (Num 5) (Num -2))) + (Congr + (= + t3 + (Add (Num 5) (Neg (Num 2)))) + prf10 + prf21 + 0) + prf19 + 1)) + (substitution + (@rewrite_var__2 t3) + (x 5) + (y -2)))) +(let prf23 + (Trans + (= t58 t3) + (Sym + (= t58 (Num 3)) + (Rule + (= (Num 3) t58) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + t69 + (substitution + (@rewrite_var__2 t58) + (x 1) + (y 2)))) + prf22)) +(let prf24 + (Congr + (= t52 (Add t1 (Num 1))) + (Rule + (= t52 t52) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t3 (Add t15 t51)) + (Sym + (= t3 t55) + (Rule + (= t55 t3) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t3 (Add t24 (Neg (Num 2)))) + prf10 + prf8 + 0)) + (substitution + t29 + (y t3) + t56 + (x (Num 2))))) + prf3 + 0)) + (substitution (z t51) t21 t56 t23)) + (Trans + (= t51 (Num 1)) + (Sym + (= t51 t59) + (Congr + (= t59 t51) + (Rule + (= t59 t59) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t67 + t68) + prf23 + 0)) + (Rule + (= t59 (Num 1)) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t67 + t68)) + 1)) +(let t71 (premises prf24)) +(let t72 (@rewrite_var__1 t52)) +(let t73 + (substitution + (z (Num 1)) + (y (Num 2)) + t72 + (x (Var "x")))) +(let prf25 + (Trans + (= t53 t3) + (Rule + (= t53 t58) + (name "(rewrite (Add x y) (Add y x))") + t69 + (substitution + (y (Num 2)) + (x (Num 1)) + (@rewrite_var__ t58))) + prf23)) +(let t74 (Add (Num 2) t5)) +(let t75 (Add (Var "x") (Num 1))) +(let t76 (Add (Num 2) t75)) +(let t77 + (premises + (Congr (= t52 (Add t14 (Num 1))) prf24 prf1 0))) +(let t78 + (substitution + (z (Num 1)) + (y (Var "x")) + t72 + (x (Num 2)))) +(let t79 (Add (Num 1) (Var "x"))) +(let prf26 + (Rule + (= t79 t79) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t1 (Add t57 (Var "x"))) + prf1 + (Sym (= (Num 2) t57) prf17) + 0)) + (substitution + (z (Var "x")) + (y (Num 1)) + t22 + (x (Num 1))))) +(let prf27 (Fiat (= (Num 6) t5))) +(let t80 (Add (Var "z") t5)) +(let prop0 (= t47 t6)) +(let t81 (Add (Neg (Var "z")) (Var "z"))) +(let t82 (Add t81 (Var "z"))) +(let t83 (Add t5 t82)) +(let t84 + (Add + (Neg (Var "z")) + (Var "y"))) +(let t85 + (Add + (Var "y") + (Neg (Var "z")))) +(let prf28 + (Sym + (= (Var "z") t85) + (Rule + (= t85 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf14) + (substitution + (z (Var "y")) + (x (Var "z")) + (y (Var "z")))))) +(let t86 (y (Neg (Var "z")))) +(let t87 (@rewrite_var__1 t5)) +(let t88 (x (Neg (Var "z")))) +(let prf29 + (Rule + (= t47 t47) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t5 (Add t84 (Var "y"))) + prf11 + (Sym + (= (Var "z") t84) + (Rule + (= t84 (Var "z")) + (name + "(rewrite (Add x y) (Add y x))") + (premises prf28) + (substitution + t86 + (x (Var "y")) + (@rewrite_var__ + (Var "z"))))) + 0)) + (substitution + (z (Var "y")) + (y (Var "y")) + t87 + t88))) +(let t89 (@rewrite_var__1 t47)) +(let prf30 + (Rule + (= t80 t47) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t47 (Add t63 (Var "y"))) + prf29 + prf15 + 0)) + (substitution + (z (Var "y")) + (y (Var "z")) + t89 + (x (Var "z"))))) +(let prf31 (Sym (= t47 t80) prf30)) +(let t90 (Add (Neg (Var "y")) t5)) +(let t91 + (Add + t5 + (Neg (Var "y")))) +(let t92 (premises prf11)) +(let t93 (z t5)) +(let t94 (x t5)) +(let prf32 + (Sym + (= (Var "z") t90) + (Rule + (= t90 (Var "z")) + (name + "(rewrite (Add x y) (Add y x))") + (premises + (Sym + (= (Var "z") t91) + (Rule + (= t91 (Var "z")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t92 + (substitution + t93 + (x (Var "z")) + (y (Var "y")))))) + (substitution + (y (Neg (Var "y"))) + t94 + (@rewrite_var__ (Var "z")))))) +(let t95 + (premises + (Congr + (= + (Var "y") + (Add t90 (Var "z"))) + prf15 + prf32 + 0))) +(let t96 (y t5)) +(let t97 (x (Neg (Var "y")))) +(let t98 + (substitution + (z (Var "z")) + t96 + (@rewrite_var__1 (Var "y")) + t97)) +(let prf33 + (Rule + (= t6 t6) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t95 + t98)) +(let prf34 + (Rule + (= t80 t6) + (name "(rewrite (Add x y) (Add y x))") + (premises prf33) + (substitution + (y (Var "z")) + t94 + (@rewrite_var__ t6)))) +(let prop1 (= t83 t6)) +(let t99 (Add t5 t81)) +(let t100 (Add t5 (Neg (Var "z")))) +(let t101 + (Add + (Var "y") + (Var "z"))) +(let prf35 + (Rule + (= t101 t5) + (name + "(rewrite (Add x y) (Add y x))") + t92 + (substitution + (y (Var "y")) + (x (Var "z")) + (@rewrite_var__ t5)))) +(let prf36 (Sym (= t5 t101) prf35)) +(let t102 + (premises + (Congr + (= t6 (Add t99 (Var "z"))) + prf33 + (Sym + (= t5 t99) + (Rule + (= t99 t5) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t5 (Add t100 (Var "z"))) + prf36 + (Sym + (= (Var "y") t100) + (Rule + (= t100 (Var "y")) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf35) + (substitution + t93 + (x (Var "y")) + (y (Var "z"))))) + 0)) + (substitution + (z (Var "z")) + t86 + t87 + t94))) + 0))) +(let t103 (@rewrite_var__1 t6)) +(let t104 + (substitution + (z (Var "z")) + (y t81) + t103 + t94)) +(let t105 (Add (Var "z") (Neg (Var "z")))) +(let t106 (Add t105 (Var "z"))) +(let t107 (Add (Var "z") t105)) +(let t108 + (premises + (Sym + (= (Var "z") t107) + (Rule + (= t107 (Var "z")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= + (Var "z") + (Add + t63 + (Neg (Var "z")))) + prf28 + prf15 + 0)) + (substitution + (z (Neg (Var "z"))) + (y (Var "z")) + (@rewrite_var__1 (Var "z")) + (x (Var "z"))))))) +(let t109 + (substitution + (y t105) + (x (Var "z")) + (@rewrite_var__ (Var "z")))) +(let t110 (Mul (Num 3) (Var "z"))) +(let t111 (Mul t3 (Var "z"))) +(let t112 (Mul t60 (Var "z"))) +(let t113 (Mul (Num 2) (Var "z"))) +(let t114 + (premises + (Congr + (= t5 (Add t61 t113)) + prf13 + (Congr + (= (Var "y") t113) + prf16 + prf17 + 0) + 1))) +(let t115 + (substitution + (z (Num 2)) + t66 + (y (Num 1)) + (x (Var "z")))) +(let t116 (Add t57 (Num 1))) +(let t117 + (premises + (Congr + (= t116 t53) + (Rule + (= t116 t116) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + (premises + (Congr + (= t5 (Add t62 t61)) + (Congr + (= + t5 + (Add t62 (Var "z"))) + prf36 + prf16 + 0) + prf12 + 1)) + (substitution + (z (Num 1)) + t66 + (y t57) + (x (Var "z")))) + prf17 + 0))) +(let prf37 (Sym (= t3 (Num 3)) prf22)) +(let prf38 + (Rule + (= (Var "z") (Num 2)) + (name + "(rule ((= (Mul (Num x) y) (Num z)) + (= (% z x) 0)) + ((union y (Num (/ z x)))) + )") + (premises + (Trans + (= t110 (Num 6)) + (Sym + (= t110 t5) + (Congr + (= t5 t110) + (Trans + (= t5 t111) + (Sym + (= t5 t112) + (Rule + (= t112 t5) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t114 + t115)) + (Congr + (= t112 t111) + (Rule + (= t112 t112) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t114 + t115) + (Trans + (= t60 t3) + (Rule + (= t60 t116) + (name + "(rewrite (Add x y) (Add y x))") + t117 + (substitution + (y (Num 1)) + (x (Num 2)) + (@rewrite_var__ t116))) + (Trans + (= t116 t3) + (Sym + (= t116 (Num 3)) + (Rule + (= (Num 3) t116) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + t117 + (substitution + (@rewrite_var__2 t116) + (x 2) + (y 1)))) + prf22)) + 0)) + prf37 + 0)) + (Sym (= t5 (Num 6)) prf27)) + (Fiat (= 0 0))) + (substitution (z 6) (x 3) (y (Var "z"))))) +(let t118 (Add (Var "z") t47)) +(let t119 (Add t6 (Var "z"))) +(let t120 (Add (Neg (Var "y")) t6)) +(let prf39 + (Sym + (= (Var "y") t120) + (Rule + (= t120 (Var "y")) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t95 + t98))) +(let t121 (y t6)) +(let prf40 (Trans (= t6 t47) (Sym (= t6 t80) prf34) prf30)) +(let t122 + (premises + (Congr (= t5 (Add t90 (Var "y"))) prf11 prf32 0))) +(let t123 (substitution (z (Var "y")) t96 t87 t97)) +(let t124 (Add (Var "z") t8)) +(let t125 (Add t8 (Var "z"))) +(let t126 (Add (Neg (Var "y")) t8)) +(let prf41 + (Congr + (= t7 (Add t47 (Var "y"))) + (Rule + (= t7 t7) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr (= t47 (Add t120 (Var "y"))) prf29 prf39 0)) + (substitution (z (Var "y")) t121 t89 t97)) + prf40 + 0)) +(let t127 (Mul t53 (Var "y"))) +(let t128 (Mul (Num 2) (Var "y"))) +(let t129 (Mul (Num 1) (Var "y"))) +(let t130 (Mul t57 (Var "y"))) +(let prf42 + (Sym + (= (Var "y") t129) + (Rule + (= t129 (Var "y")) + (name + "(rule ((= x (Var v))) + ((union (Mul (Num 1) x) x)) + )") + (premises (Fiat (= (Var "y") (Var "y")))) + (substitution (v "y") (x (Var "y")))))) +(let t131 + (premises + (Congr + (= t47 (Add t129 t129)) + (Congr (= t47 (Add t129 (Var "y"))) prf29 prf42 0) + prf42 + 1))) +(let t132 + (substitution + (z (Num 1)) + (@rewrite_var__5 t47) + (y (Num 1)) + (x (Var "y")))) +(let t133 + (premises + (Congr + (= t7 (Add t128 t129)) + (Congr + (= t7 (Add t128 (Var "y"))) + prf41 + (Trans + (= t47 t128) + (Sym + (= t47 t130) + (Rule + (= t130 t47) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t131 + t132)) + (Congr + (= t130 t128) + (Rule + (= t130 t130) + (name + "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t131 + t132) + prf17 + 0)) + 0) + prf42 + 1))) +(let t134 + (substitution + (z (Num 1)) + (@rewrite_var__5 t7) + (y (Num 2)) + (x (Var "y")))) +(Trans + (= t0 (Num 12)) + (Sym + (= t0 t2) + (Congr + (= t2 t0) + (Trans + (= t2 t4) + (Trans + (= t2 t7) + (Trans + (= t2 t9) + (Congr + (= t2 t11) + (Sym + (= t2 t13) + (Rule + (= t13 t2) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t2 (Add t14 (Var "x"))) prf4 prf1 0)) + (substitution + (z (Var "x")) + (y (Var "x")) + (@rewrite_var__1 t2) + (x (Num 2))))) + (Trans + (= t12 t10) + (Sym + (= t12 t25) + (Congr + (= t25 t12) + (Rule + (= t25 t25) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t34 + t36) + prf7 + 1)) + (Rule + (= t25 t10) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t34 + t36)) + 1) + (Congr + (= t11 t9) + (Rule + (= t11 t11) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= (Var "x") (Add t38 t10)) + (Sym + (= (Var "x") t39) + (Rule + (= t39 (Var "x")) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t31 + t33)) + (Trans + (= (Neg (Var "x")) t38) + (Sym + (= (Neg (Var "x")) t41) + (Rule + (= t41 (Neg (Var "x"))) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t44 + t46)) + (Congr + (= t41 t38) + (Rule + (= t41 t41) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + t44 + t46) + (Rule + (= t40 (Num 2)) + (name "(rewrite (Neg (Neg x)) x)") + (premises + (Rule + (= t40 t40) + (name + "(rule ((= (Add x y) z)) + ((union (Add z (Neg y)) x)) + )") + (premises prf5) + (substitution (z (Var "x")) t20 t45))) + (substitution (x (Num 2)) (@rewrite_var__3 t40))) + 1)) + 0)) + (substitution + (z t10) + (y (Num 2)) + (@rewrite_var__1 (Var "x")) + (x t37))) + (Trans + (= t10 t8) + (Congr + (= t10 t48) + (Sym + (= t10 t50) + (Rule + (= t50 t10) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t10 (Add t14 t3)) prf9 prf1 0)) + (substitution t32 (y (Var "x")) t35 (x (Num 2))))) + (Trans + (= t49 t47) + (Trans + (= t49 t52) + (Sym + (= t49 t54) + (Congr + (= t54 t49) + (Rule + (= t54 t54) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t71 + t73) + prf25 + 1)) + (Rule + (= t54 t52) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t71 + t73)) + (Trans + (= t52 t47) + (Trans + (= t52 t74) + (Sym + (= t52 t76) + (Rule + (= t76 t52) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t77 + t78)) + (Congr + (= t76 t74) + (Rule + (= t76 t76) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t77 + t78) + (Trans + (= t75 t5) + (Trans + (= t75 (Num 6)) + (Rule + (= t75 t79) + (name "(rewrite (Add x y) (Add y x))") + (premises prf26) + (substitution + (y (Var "x")) + (x (Num 1)) + (@rewrite_var__ t79))) + (Rule + (= t79 (Num 6)) + (name + "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t79 (Add (Num 1) (Num 5))) + prf26 + prf21 + 1)) + (substitution (@rewrite_var__2 t79) (x 1) (y 5)))) + prf27) + 1)) + (Trans + (= t74 t47) + (Sym + (= t74 t80) + (Congr + (= t80 t74) + (Rule + (= t80 t80) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Trans + prop0 + (Trans + (= t47 t83) + (Trans prop0 prf31 prf34) + (Sym + (= t6 t83) + (Rule + prop1 + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t102 + t104))) + (Congr + prop1 + (Rule + (= t83 t83) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t102 + t104) + (Trans + (= t82 (Var "z")) + (Sym + (= t82 t106) + (Congr + (= t106 t82) + (Rule + (= t106 t106) + (name + "(rewrite (Add x y) (Add y x))") + t108 + t109) + (Rule + (= t105 t81) + (name + "(rewrite (Add x y) (Add y x))") + (premises + (Rule + (= t81 t81) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= + (Var "y") + (Add t85 (Var "z"))) + prf15 + prf28 + 0)) + (substitution + (z (Var "z")) + t86 + (@rewrite_var__1 (Var "y")) + (x (Var "y"))))) + (substitution + (y (Var "z")) + t88 + (@rewrite_var__ t81))) + 0)) + (Rule + (= t106 (Var "z")) + (name "(rewrite (Add x y) (Add y x))") + t108 + t109)) + 1))) + (substitution + (y (Var "z")) + t94 + (@rewrite_var__ t47))) + prf38 + 0)) + prf30))) + 1) + (Trans + (= t48 t8) + (Sym + (= t48 t118) + (Congr + (= t118 t48) + (Rule + (= t118 t118) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Congr + (= t119 (Add t47 (Var "z"))) + (Rule + (= t119 t119) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t5 (Add t120 (Var "z"))) + prf36 + prf39 + 0)) + (substitution (z (Var "z")) t121 t87 t97)) + prf40 + 0)) + (substitution + (y (Var "z")) + (x t47) + (@rewrite_var__ t119))) + prf38 + 0)) + (Rule + (= t118 t8) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Rule + (= t8 t8) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t122 + t123)) + (substitution + (z (Var "y")) + (y (Var "y")) + (@rewrite_var__1 t8) + (x (Var "z")))))) + 1)) + (Trans + (= t9 t7) + (Sym + (= t9 t124) + (Congr + (= t124 t9) + (Rule + (= t124 t124) + (name "(rewrite (Add x y) (Add y x))") + (premises + (Rule + (= t125 t125) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises + (Congr + (= t6 (Add t126 (Var "z"))) + prf33 + (Sym + (= t5 t126) + (Rule + (= t126 t5) + (name + "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + t122 + t123)) + 0)) + (substitution (z (Var "z")) (y t8) t103 t97))) + (substitution (y (Var "z")) (x t8) (@rewrite_var__ t125))) + prf38 + 0)) + (Rule + (= t124 t7) + (name "(rewrite (Add (Add x y) z) (Add x (Add y z)))") + (premises (Congr (= t7 (Add t80 (Var "y"))) prf41 prf31 0)) + (substitution + (z (Var "y")) + t96 + (@rewrite_var__1 t7) + (x (Var "z")))))) + (Trans + (= t7 t4) + (Sym + (= t7 t127) + (Rule + (= t127 t7) + (name "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t133 + t134)) + (Congr + (= t127 t4) + (Rule + (= t127 t127) + (name "(rewrite (Add (Mul y x) (Mul z x)) (Mul (Add y z) x))") + t133 + t134) + prf25 + 0))) + prf37 + 0)) + (Sym + (= t2 (Num 12)) + (Rule + (= (Num 12) t2) + (name "(rewrite (Add (Num x) (Num y)) (Num (+ x y)))") + (premises + (Congr + (= t2 (Add (Num 7) (Num 5))) + (Congr (= t2 (Add (Num 7) (Var "x"))) prf4 prf20 0) + prf21 + 1)) + (substitution (@rewrite_var__2 t2) (x 7) (y 5))))) diff --git a/egglog/tests/snapshots/files__proof_integration__integer_math_desugar_proof_testing.snap b/egglog/tests/snapshots/files__proof_integration__integer_math_desugar_proof_testing.snap new file mode 100644 index 0000000..0c33500 --- /dev/null +++ b/egglog/tests/snapshots/files__proof_integration__integer_math_desugar_proof_testing.snap @@ -0,0 +1,64 @@ +--- +source: egglog/tests/files.rs +expression: proof_snapshot +--- +(let t0 (Mul (Var "a") (Pow (Const 2) (Const 3)))) +(let t1 (Mul (Var "b") (Const 2))) +(let t2 (Sub t1 t1)) +(let t3 (Add (Var "c") t2)) +(let t4 (Div t0 t3)) +(let t5 (LShift (Var "a") (Const 3))) +(let t6 (Not (Not (Const 1)))) +(let t7 (Mul (Var "c") t6)) +(let t8 (Div t5 t7)) +(let t9 (Div t0 (Var "c"))) +(Trans + (= t4 t8) + (Congr + (= t4 t9) + (Fiat (= t4 t4)) + (Rule + (= t3 (Var "c")) + (name "(rewrite (Add a (Const 0)) a)") + (premises + (Congr + (= t3 (Add (Var "c") (Const 0))) + (Fiat (= t3 t3)) + (Sym + (= t2 (Const 0)) + (Rule + (= (Const 0) t2) + (name "(rewrite (Sub a a) (Const 0))") + (premises (Fiat (= t2 t2))) + (substitution (a t1) (@rewrite_var__15 t2)))) + 1)) + (substitution (a (Var "c")) (@rewrite_var__12 t3))) + 1) + (Sym + (= t9 t8) + (Congr + (= t8 t9) + (Congr + (= t8 (Div t0 t7)) + (Fiat (= t8 t8)) + (Rule + (= t5 t0) + (name "(rewrite (Mul x (Pow (Const 2) y)) (LShift x y))") + (premises (Fiat (= t0 t0))) + (substitution (y (Const 3)) (@rewrite_var__24 t0) (x (Var "a")))) + 0) + (Rule + (= t7 (Var "c")) + (name "(rewrite (Mul a (Const 1)) a)") + (premises + (Congr + (= t7 (Mul (Var "c") (Const 1))) + (Fiat (= t7 t7)) + (Rule + (= t6 (Const 1)) + (name "(rewrite (Not (Not x)) x)") + (premises (Fiat (= t6 t6))) + (substitution (@rewrite_var__26 t6) (x (Const 1)))) + 1)) + (substitution (a (Var "c")) (@rewrite_var__14 t7))) + 1))) diff --git a/egglog/tests/snapshots/files__proof_integration__integer_math_proof_testing.snap b/egglog/tests/snapshots/files__proof_integration__integer_math_proof_testing.snap new file mode 100644 index 0000000..0c33500 --- /dev/null +++ b/egglog/tests/snapshots/files__proof_integration__integer_math_proof_testing.snap @@ -0,0 +1,64 @@ +--- +source: egglog/tests/files.rs +expression: proof_snapshot +--- +(let t0 (Mul (Var "a") (Pow (Const 2) (Const 3)))) +(let t1 (Mul (Var "b") (Const 2))) +(let t2 (Sub t1 t1)) +(let t3 (Add (Var "c") t2)) +(let t4 (Div t0 t3)) +(let t5 (LShift (Var "a") (Const 3))) +(let t6 (Not (Not (Const 1)))) +(let t7 (Mul (Var "c") t6)) +(let t8 (Div t5 t7)) +(let t9 (Div t0 (Var "c"))) +(Trans + (= t4 t8) + (Congr + (= t4 t9) + (Fiat (= t4 t4)) + (Rule + (= t3 (Var "c")) + (name "(rewrite (Add a (Const 0)) a)") + (premises + (Congr + (= t3 (Add (Var "c") (Const 0))) + (Fiat (= t3 t3)) + (Sym + (= t2 (Const 0)) + (Rule + (= (Const 0) t2) + (name "(rewrite (Sub a a) (Const 0))") + (premises (Fiat (= t2 t2))) + (substitution (a t1) (@rewrite_var__15 t2)))) + 1)) + (substitution (a (Var "c")) (@rewrite_var__12 t3))) + 1) + (Sym + (= t9 t8) + (Congr + (= t8 t9) + (Congr + (= t8 (Div t0 t7)) + (Fiat (= t8 t8)) + (Rule + (= t5 t0) + (name "(rewrite (Mul x (Pow (Const 2) y)) (LShift x y))") + (premises (Fiat (= t0 t0))) + (substitution (y (Const 3)) (@rewrite_var__24 t0) (x (Var "a")))) + 0) + (Rule + (= t7 (Var "c")) + (name "(rewrite (Mul a (Const 1)) a)") + (premises + (Congr + (= t7 (Mul (Var "c") (Const 1))) + (Fiat (= t7 t7)) + (Rule + (= t6 (Const 1)) + (name "(rewrite (Not (Not x)) x)") + (premises (Fiat (= t6 t6))) + (substitution (@rewrite_var__26 t6) (x (Const 1)))) + 1)) + (substitution (a (Var "c")) (@rewrite_var__14 t7))) + 1))) diff --git a/egglog/tests/snapshots/files__proof_integration__math_proof_testing.snap b/egglog/tests/snapshots/files__proof_integration__math_proof_testing.snap new file mode 100644 index 0000000..dee259f --- /dev/null +++ b/egglog/tests/snapshots/files__proof_integration__math_proof_testing.snap @@ -0,0 +1,9121 @@ +--- +source: egglog/tests/files.rs +expression: proof_snapshot +--- +(let t0 (Add (Const 6.0) (Const 7.0))) +(let t1 (Add (Const 5.0) t0)) +(let t2 (Add (Const 4.0) t1)) +(let t3 (Add (Const 3.0) t2)) +(let t4 (Add (Const 2.0) t3)) +(let t5 (Add (Const 1.0) t4)) +(let t6 (Add (Const 2.0) (Const 1.0))) +(let t7 (Add (Const 3.0) t6)) +(let t8 (Add (Const 4.0) t7)) +(let t9 (Add (Const 5.0) t8)) +(let t10 (Add (Const 6.0) t9)) +(let t11 (Add (Const 2.0) (Const 3.0))) +(let t12 (Add (Const 1.0) t11)) +(let t13 (Add (Const 5.0) (Const 6.0))) +(let t14 (Add (Const 4.0) t13)) +(let t15 (Add t12 t14)) +(let t16 (Add (Const 7.0) t15)) +(let t17 (Add t15 (Const 7.0))) +(let t18 (Add t14 (Const 7.0))) +(let t19 (Add t12 t2)) +(let t20 (Add t11 t2)) +(let prf0 (Fiat (= t5 t5))) +(let t21 (c t2)) +(let t22 + (premises + (Congr + (= t5 (Add (Const 1.0) t20)) + prf0 + (Sym + (= t4 t20) + (Rule + (= t20 t4) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + (premises (Fiat (= t4 t4))) + (substitution + (@rewrite_var__39 t4) + (a (Const 2.0)) + (b (Const 3.0)) + t21))) + 1))) +(let t23 (@rewrite_var__39 t5)) +(let t24 (substitution t23 (a (Const 1.0)) (b t11) t21)) +(let t25 (Add t13 (Const 7.0))) +(let prf1 (Fiat (= t2 t2))) +(let t26 + (premises + (Congr + (= t2 (Add (Const 4.0) t25)) + prf1 + (Sym + (= t1 t25) + (Rule + (= t25 t1) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + (premises (Fiat (= t1 t1))) + (substitution + (@rewrite_var__39 t1) + (a (Const 5.0)) + (b (Const 6.0)) + (c (Const 7.0))))) + 1))) +(let t27 (@rewrite_var__39 t2)) +(let t28 (substitution t27 (a (Const 4.0)) (b t13) (c (Const 7.0)))) +(let t29 + (premises + (Congr + (= t5 (Add t12 t18)) + (Sym + (= t5 t19) + (Rule + (= t19 t5) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + t22 + t24)) + (Sym + (= t2 t18) + (Rule + (= t18 t2) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + t26 + t28)) + 1))) +(let t30 (a t12)) +(let t31 (substitution t23 t30 (b t14) (c (Const 7.0)))) +(let t32 (Add (Const 1.0) (Const 2.0))) +(let t33 (Add (Const 4.0) (Const 5.0))) +(let t34 (Add (Const 3.0) t33)) +(let t35 (Add t32 t34)) +(let t36 (Add (Const 6.0) t35)) +(let t37 (Add t35 (Const 6.0))) +(let t38 (Add t12 t33)) +(let t39 (Add t38 (Const 6.0))) +(let t40 (Add t33 (Const 6.0))) +(let t41 + (premises + (Congr + (= t15 (Add t12 t40)) + (Rule + (= t15 t15) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + t29 + t31) + (Sym + (= t14 t40) + (Rule + (= t40 t14) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + (premises + (Rule + (= t14 t14) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + t26 + t28)) + (substitution + (@rewrite_var__39 t14) + (a (Const 4.0)) + (b (Const 5.0)) + (c (Const 6.0))))) + 1))) +(let t42 (b t33)) +(let t43 (substitution (@rewrite_var__39 t15) t30 t42 (c (Const 6.0)))) +(let t44 (Add t32 (Const 3.0))) +(let t45 (Add t44 t33)) +(let t46 (Add t33 t0)) +(let t47 (Add t44 t2)) +(let t48 (Add t32 t3)) +(let t49 (premises prf0)) +(let t50 + (substitution + t23 + (a (Const 1.0)) + (b (Const 2.0)) + (c t3))) +(let prf2 + (Sym + (= t5 t48) + (Rule + (= t48 t5) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + t49 + t50))) +(let t51 (premises prf2)) +(let t52 (a t32)) +(let t53 (substitution t23 t52 (b (Const 3.0)) t21)) +(let prf3 + (Sym + (= t5 t47) + (Rule + (= t47 t5) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + t51 + t53))) +(let t54 (c t0)) +(let prf4 + (Sym + (= t2 t46) + (Rule + (= t46 t2) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + (premises prf1) + (substitution + t27 + (a (Const 4.0)) + (b (Const 5.0)) + t54)))) +(let t55 (a t44)) +(let prf5 + (Rule + (= t44 t12) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + (premises + (Rule + (= t12 t12) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + t22 + t24)) + (substitution + (@rewrite_var__39 t12) + (a (Const 1.0)) + (b (Const 2.0)) + (c (Const 3.0))))) +(let t56 (Add t34 t0)) +(let prf6 (Fiat (= t3 t3))) +(let t57 + (premises + (Congr (= t3 (Add (Const 3.0) t46)) prf6 prf4 1))) +(let t58 (@rewrite_var__39 t3)) +(let t59 (substitution t58 (a (Const 3.0)) t42 t54)) +(let prf7 + (Rule + (= t35 t35) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + (premises + (Congr + (= t5 (Add t32 t56)) + prf2 + (Sym + (= t3 t56) + (Rule + (= t56 t3) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + t57 + t59)) + 1)) + (substitution t23 t52 (b t34) t54))) +(let t60 (@rewrite_var__39 t35)) +(let t61 (Add (Const 3.0) (Const 4.0))) +(let t62 (Add t32 t61)) +(let t63 (Add (Const 5.0) t62)) +(let t64 (Add t62 (Const 5.0))) +(let t65 (Add t61 (Const 5.0))) +(let t66 (b t61)) +(let t67 (Add t62 t1)) +(let t68 (Add t61 t1)) +(let t69 (c t1)) +(let t70 + (premises + (Congr + (= t5 (Add t32 t68)) + prf2 + (Sym + (= t3 t68) + (Rule + (= t68 t3) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + (premises prf6) + (substitution + t58 + (a (Const 3.0)) + (b (Const 4.0)) + t69))) + 1))) +(let t71 (substitution t23 t52 t66 t69)) +(let t72 (a t62)) +(let t73 (Add (Const 4.0) t12)) +(let t74 (Add t12 (Const 4.0))) +(let t75 (Add t44 (Const 4.0))) +(let t76 (Add (Const 3.0) t32)) +(Congr + (= t5 (Add (Const 7.0) t10)) + (Sym + (= t5 t16) + (Rule + (= t16 t5) + (name "(rewrite (Add a b) (Add b a) :ruleset add-ac)") + (premises + (Sym + (= t5 t17) + (Rule + (= t17 t5) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + t29 + t31))) + (substitution (a t15) (@rewrite_var__38 t5) (b (Const 7.0))))) + (Congr + (= t15 t10) + (Sym + (= t15 t36) + (Rule + (= t36 t15) + (name "(rewrite (Add a b) (Add b a) :ruleset add-ac)") + (premises + (Trans + (= t15 t37) + (Sym + (= t15 t39) + (Rule + (= t39 t15) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + t41 + t43)) + (Congr + (= t39 t37) + (Rule + (= t39 t39) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + t41 + t43) + (Trans + (= t38 t35) + (Sym + (= t38 t45) + (Congr + (= t45 t38) + (Rule + (= t45 t45) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + (premises (Congr (= t5 (Add t44 t46)) prf3 prf4 1)) + (substitution t23 t55 t42 t54)) + prf5 + 0)) + (Rule + (= t45 t35) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + (premises prf7) + (substitution t60 t52 (b (Const 3.0)) (c t33)))) + 0))) + (substitution (a t35) (@rewrite_var__38 t15) (b (Const 6.0))))) + (Congr + (= t35 t9) + (Trans + (= t35 t63) + (Sym + (= t35 t64) + (Rule + (= t64 t35) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + (premises + (Congr + (= t35 (Add t32 t65)) + prf7 + (Sym + (= t34 t65) + (Rule + (= t65 t34) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + (premises + (Rule + (= t34 t34) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + t57 + t59)) + (substitution + (@rewrite_var__39 t34) + (a (Const 3.0)) + (b (Const 4.0)) + (c (Const 5.0))))) + 1)) + (substitution t60 t52 t66 (c (Const 5.0))))) + (Sym + (= t64 t63) + (Rule + (= t63 t64) + (name "(rewrite (Add a b) (Add b a) :ruleset add-ac)") + (premises + (Rule + (= t64 t64) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + (premises + (Sym + (= t5 t67) + (Rule + (= t67 t5) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + t70 + t71))) + (substitution t23 t72 (b (Const 5.0)) t54))) + (substitution t72 (@rewrite_var__38 t64) (b (Const 5.0)))))) + (Congr + (= t62 t8) + (Sym + (= t62 t73) + (Rule + (= t73 t62) + (name "(rewrite (Add a b) (Add b a) :ruleset add-ac)") + (premises + (Trans + (= t62 t74) + (Sym + (= t62 t75) + (Rule + (= t75 t62) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + (premises + (Rule + (= t62 t62) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + t70 + t71)) + (substitution + (@rewrite_var__39 t62) + t52 + (b (Const 3.0)) + (c (Const 4.0))))) + (Congr + (= t75 t74) + (Rule + (= t75 t75) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + (premises prf3) + (substitution t23 t55 (b (Const 4.0)) t69)) + prf5 + 0))) + (substitution t30 (@rewrite_var__38 t62) (b (Const 4.0))))) + (Congr + (= t12 t7) + (Trans + (= t12 t76) + (Sym (= t12 t44) prf5) + (Sym + (= t44 t76) + (Rule + (= t76 t44) + (name "(rewrite (Add a b) (Add b a) :ruleset add-ac)") + (premises + (Rule + (= t44 t44) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + t51 + t53)) + (substitution t52 (@rewrite_var__38 t44) (b (Const 3.0)))))) + (Sym + (= t32 t6) + (Rule + (= t6 t32) + (name "(rewrite (Add a b) (Add b a) :ruleset add-ac)") + (premises + (Rule + (= t32 t32) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c) :ruleset add-ac)") + t49 + t50)) + (substitution + (a (Const 1.0)) + (@rewrite_var__38 t32) + (b (Const 2.0))))) + 1) + 1) + 1) + 1) + 1) +(let t0 (Add (Var "x") (Var "x"))) +(let t1 (Add t0 (Var "x"))) +(let t2 (Add t1 (Var "x"))) +(let t3 (Add (Const 1.0) (Const 1.0))) +(let t4 (Add t3 t3)) +(let t5 (Mul t4 (Var "x"))) +(let t6 (Mul (Var "x") t4)) +(let t7 (Mul (Var "x") t3)) +(let t8 (Add t0 t0)) +(let t9 (Add (Var "x") t0)) +(let t10 (Add (Var "x") t1)) +(let t11 (Mul (Var "x") (Const 1.0))) +(let prf0 + (Sym + (= (Var "x") t11) + (Rule + (= t11 (Var "x")) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + (premises + (Rule + (= (MathU (Var "x")) (MathU (Var "x"))) + (name + "(rule ((= e (Var x))) + ((MathU e)) + )") + (premises (Fiat (= (Var "x") (Var "x")))) + (substitution (e (Var "x")) (x "x")))) + (substitution (a (Var "x")))))) +(let t12 + (premises + (Congr + (= t0 (Add t11 t11)) + (Congr + (= t0 (Add t11 (Var "x"))) + (Fiat (= t0 t0)) + prf0 + 0) + prf0 + 1))) +(let t13 + (substitution + (c (Const 1.0)) + (a (Var "x")) + (@rewrite_var__16 t0) + (b (Const 1.0)))) +(let prf1 + (Sym + (= t0 t7) + (Rule + (= t7 t0) + (name + "(rewrite (Add (Mul a b) (Mul a c)) (Mul a (Add b c)))") + t12 + t13))) +(let t14 + (premises + (Congr + (= t2 (Add t7 t7)) + (Congr + (= t2 (Add t7 t0)) + (Sym + (= t2 t8) + (Rule + (= t8 t2) + (name "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + (premises + (Congr + (= t2 (Add (Var "x") t9)) + (Sym + (= t2 t10) + (Rule + (= t10 t2) + (name "(rewrite (Add a b) (Add b a))") + (premises (Fiat (= t2 t2))) + (substitution + (@rewrite_var__4 t2) + (a t1) + (b (Var "x"))))) + (Sym + (= t1 t9) + (Rule + (= t9 t1) + (name "(rewrite (Add a b) (Add b a))") + (premises (Fiat (= t1 t1))) + (substitution + (@rewrite_var__4 t1) + (a t0) + (b (Var "x"))))) + 1)) + (substitution + (c t0) + (a (Var "x")) + (@rewrite_var__6 t2) + (b (Var "x"))))) + prf1 + 0) + prf1 + 1))) +(let t15 (substitution (c t3) (a (Var "x")) (@rewrite_var__16 t2) (b t3))) +(let prf2 + (Sym + (= t3 (Const 2.0)) + (Rule + (= (Const 2.0) t3) + (name "(rewrite (Add (Const a) (Const b)) (Const (+ a b)))") + (premises + (Rule + (= t3 t3) + (name + "(rewrite (Add (Mul a b) (Mul a c)) (Mul a (Add b c)))") + t12 + t13)) + (substitution (a 1.0) (b 1.0) (@rewrite_var__ t3))))) +(Congr + (= t2 (Mul (Const 4.0) (Var "x"))) + (Sym + (= t2 t5) + (Rule + (= t5 t2) + (name "(rewrite (Mul a b) (Mul b a))") + (premises + (Sym + (= t2 t6) + (Rule + (= t6 t2) + (name "(rewrite (Add (Mul a b) (Mul a c)) (Mul a (Add b c)))") + t14 + t15))) + (substitution (a (Var "x")) (@rewrite_var__5 t2) (b t4)))) + (Sym + (= t4 (Const 4.0)) + (Rule + (= (Const 4.0) t4) + (name "(rewrite (Add (Const a) (Const b)) (Const (+ a b)))") + (premises + (Congr + (= t4 (Add (Const 2.0) (Const 2.0))) + (Congr + (= t4 (Add (Const 2.0) t3)) + (Rule + (= t4 t4) + (name "(rewrite (Add (Mul a b) (Mul a c)) (Mul a (Add b c)))") + t14 + t15) + prf2 + 0) + prf2 + 1)) + (substitution (a 2.0) (b 2.0) (@rewrite_var__ t4)))) + 0) +(let t0 (Mul (Pow (Const 2.0) (Var "x")) (Pow (Const 2.0) (Var "y")))) +(let t1 (Pow (Const 2.0) (Add (Var "x") (Var "y")))) +(Sym + (= t0 t1) + (Rule + (= t1 t0) + (name "(rewrite (Mul (Pow a b) (Pow a c)) (Pow a (Add b c)))") + (premises (Fiat (= t0 t0))) + (substitution + (@rewrite_var__17 t0) + (a (Const 2.0)) + (b (Var "x")) + (c (Var "y"))))) +(let t0 (Sub (Const 2.0) (Const 1.0))) +(let t1 (Mul t0 (Var "a"))) +(let t2 (Sub (Var "a") t1)) +(let t3 (Add (Const 1.0) t2)) +(let t4 (Add (Const 1.0) (Const 0.0))) +(let t5 (MathU t0)) +(let t6 (premises (Fiat (= t0 t0)))) +(let prf0 + (Rule + (= t0 (Const 1.0)) + (name "(rewrite (Sub (Const a) (Const b)) (Const (- a b)))") + t6 + (substitution (@rewrite_var__1 t0) (a 2.0) (b 1.0)))) +(let t7 (Mul (Var "a") (Const 1.0))) +(let t8 (Mul (Var "a") t0)) +(let t9 (premises (Fiat (= t1 t1)))) +(let t10 (substitution (a t0) (@rewrite_var__5 t1) (b (Var "a")))) +(Sym + (= t3 (Const 1.0)) + (Congr + (= (Const 1.0) t3) + (Sym + (= (Const 1.0) t4) + (Rule + (= t4 (Const 1.0)) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + (premises + (Congr + (= t5 (MathU (Const 1.0))) + (Rule + (= t5 t5) + (name + "(rule ((= e (Sub x y))) + ((MathU e)) + )") + t6 + (substitution (y (Const 1.0)) (e t0) (x (Const 2.0)))) + prf0 + 0)) + (substitution (a (Const 1.0))))) + (Rule + (= (Const 0.0) t2) + (name "(rewrite (Sub a a) (Const 0.0))") + (premises + (Congr + (= t2 (Sub (Var "a") (Var "a"))) + (Fiat (= t2 t2)) + (Rule + (= t1 (Var "a")) + (name "(rewrite (Mul a (Const 1.0)) a)") + (premises + (Trans + (= t1 t7) + (Sym + (= t1 t8) + (Rule (= t8 t1) (name "(rewrite (Mul a b) (Mul b a))") t9 t10)) + (Congr + (= t8 t7) + (Rule (= t8 t8) (name "(rewrite (Mul a b) (Mul b a))") t9 t10) + prf0 + 1))) + (substitution (a (Var "a")) (@rewrite_var__12 t1))) + 1)) + (substitution (@rewrite_var__13 t2) (a (Var "a")))) + 1)) +(let t0 (Add (Const 1.0) (Sqrt (Var "five")))) +(let t1 (Div t0 (Const 2.0))) +(let t2 (Sub (Const 1.0) (Sqrt (Var "five")))) +(let t3 (Div t2 (Const 2.0))) +(let t4 (Sub t1 t3)) +(let t5 (Div (Const 1.0) t4)) +(let t6 (Mul (Const 1.0) (Sqrt (Var "five")))) +(let t7 (Pow (Const 2.0) (Const -1.0))) +(let t8 (Add t7 t7)) +(let t9 (Mul t8 (Sqrt (Var "five")))) +(let t10 (Mul (Sqrt (Var "five")) t8)) +(let t11 (Mul t7 (Sqrt (Var "five")))) +(let t12 (Add t11 t11)) +(let t13 (Mul (Const -1.0) t3)) +(let t14 (Add t13 t7)) +(let t15 (Add t14 t11)) +(let t16 (Add t7 t11)) +(let t17 (Add t13 t1)) +(let t18 (Add t1 t13)) +(let t19 (premises (Fiat (= t4 t4)))) +(let t20 (a t1)) +(let t21 (substitution t20 (b t3) (@rewrite_var__8 t4))) +(let prf0 + (Sym + (= t4 t17) + (Rule + (= t17 t4) + (name "(rewrite (Add a b) (Add b a))") + (premises + (Sym + (= t4 t18) + (Rule + (= t18 t4) + (name + "(rewrite (Sub a b) (Add a (Mul (Const -1.0) b)))") + t19 + t21))) + (substitution (@rewrite_var__4 t4) t20 (b t13))))) +(let t22 (Mul t7 (Const 1.0))) +(let t23 (Add t22 t11)) +(let t24 (Mul t7 t0)) +(let t25 (Mul t0 t7)) +(let t26 (MathU t0)) +(let t27 + (premises + (Fiat (= t0 t0)))) +(let t28 + (premises + (Rule + (= t26 t26) + (name + "(rule ((= e (Add x y))) + ((MathU e)) + )") + t27 + (substitution + (y (Sqrt (Var "five"))) + (e t0) + (x (Const 1.0)))))) +(let t29 (a t0)) +(let t30 (substitution t29)) +(let prf1 (Fiat (= () ()))) +(let prf2 + (Rule + (= + (is-not-zero (Const 2.0)) + (is-not-zero (Const 2.0))) + (name + "(rule ((MathU x) + (!= x (Const 0.0))) + ((is-not-zero x)) + )") + (premises + (Rule + (= + (MathU (Const 2.0)) + (MathU (Const 2.0))) + (name + "(rule ((= e (Const x))) + ((MathU e)) + )") + (premises + (Fiat + (= + (Const 2.0) + (Const 2.0)))) + (substitution + (e (Const 2.0)) + (x 2.0))) + (Rule + (= (Const 0.0) (Const 0.0)) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + t28 + t30) + prf1) + (substitution + (x (Const 2.0)) + (@v313 (Const 0.0))))) +(let t31 (premises (Fiat (= t1 t1)) prf2)) +(let t32 + (substitution + t29 + (b (Const 2.0)) + (@rewrite_var__9 t1))) +(let t33 (b t7)) +(let prf3 + (Rule + (= t24 t1) + (name "(rewrite (Mul a b) (Mul b a))") + (premises + (Sym + (= t1 t25) + (Rule + (= t25 t1) + (name + "(rewrite (Div a b) (Mul a (Pow b (Const -1.0))) :when ((is-not-zero b)))") + t31 + t32))) + (substitution t29 (@rewrite_var__5 t1) t33))) +(let prf4 (Sym (= t1 t24) prf3)) +(let t34 (premises prf4)) +(let t35 (a t7)) +(let t36 (@rewrite_var__15 t1)) +(let t37 (c (Sqrt (Var "five")))) +(let t38 (substitution t35 t36 (b (Const 1.0)) t37)) +(let t39 (MathU t7)) +(let prf5 + (Rule + (= t7 t7) + (name + "(rewrite (Div a b) (Mul a (Pow b (Const -1.0))) :when ((is-not-zero b)))") + t31 + t32)) +(let prf6 + (Rule + (= t22 t7) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + (premises + (Rule + (= t39 t39) + (name + "(rule ((= e (Pow x y))) + ((MathU e)) + )") + (premises prf5) + (substitution + (y (Const -1.0)) + (e t7) + (x (Const 2.0))))) + (substitution t35))) +(let t40 + (premises + (Congr + (= t4 (Add t13 t16)) + prf0 + (Trans + (= t1 t16) + (Sym + (= t1 t23) + (Rule + (= t23 t1) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t34 + t38)) + (Congr + (= t23 t16) + (Rule + (= t23 t23) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t34 + t38) + prf6 + 0)) + 1))) +(let t41 (c t11)) +(let t42 (a t13)) +(let t43 (@rewrite_var__6 t4)) +(let t44 (substitution t41 t42 t43 t33)) +(let t45 (Add (Const 0.0) t11)) +(let t46 (Mul (Const -1.0) t7)) +(let t47 (Add t7 t46)) +(let t48 (Add t47 t11)) +(let t49 (Add t46 t11)) +(let t50 (Add t7 t13)) +(let t51 (Mul (Const -1.0) (Sqrt (Var "five")))) +(let t52 (Mul t7 t51)) +(let t53 (Mul (Const -1.0) t52)) +(let t54 (Add t46 t53)) +(let t55 (Add t7 t52)) +(let prf7 + (Rule + (= t13 t13) + (name + "(rewrite (Sub a b) (Add a (Mul (Const -1.0) b)))") + t19 + t21)) +(let t56 (Add t22 t52)) +(let t57 (Add (Const 1.0) t51)) +(let t58 (Mul t7 t2)) +(let t59 (Mul t2 t7)) +(let t60 (a t2)) +(let prf8 + (Sym + (= t3 t59) + (Rule + (= t59 t3) + (name + "(rewrite (Div a b) (Mul a (Pow b (Const -1.0))) :when ((is-not-zero b)))") + (premises + (Fiat (= t3 t3)) + prf2) + (substitution + t60 + (b (Const 2.0)) + (@rewrite_var__9 t3))))) +(let prf9 + (Sym + (= t3 t58) + (Rule + (= t58 t3) + (name + "(rewrite (Mul a b) (Mul b a))") + (premises prf8) + (substitution + t60 + (@rewrite_var__5 t3) + t33)))) +(let t61 (b (Sqrt (Var "five")))) +(let prf10 + (Sym + (= t2 t57) + (Rule + (= t57 t2) + (name + "(rewrite (Sub a b) (Add a (Mul (Const -1.0) b)))") + (premises (Fiat (= t2 t2))) + (substitution + (a (Const 1.0)) + t61 + (@rewrite_var__8 t2))))) +(let t62 + (premises + (Congr + (= t3 (Mul t7 t57)) + prf9 + prf10 + 1))) +(let t63 (@rewrite_var__15 t3)) +(let t64 + (substitution + t35 + t63 + (b (Const 1.0)) + (c t51))) +(let t65 (@rewrite_var__15 t13)) +(let t66 (Mul (Sqrt (Var "five")) t7)) +(let t67 (Mul (Const -1.0) t51)) +(let t68 (Mul t67 t7)) +(let t69 (Mul t51 t7)) +(let t70 (Add t52 t7)) +(let t71 (Add t52 t22)) +(let t72 + (Add + t51 + (Const 1.0))) +(let t73 (b t51)) +(let prf11 + (Sym + (= t2 t72) + (Rule + (= t72 t2) + (name + "(rewrite (Add a b) (Add b a))") + (premises prf10) + (substitution + (@rewrite_var__4 + t2) + (a (Const 1.0)) + t73)))) +(let t74 + (premises + (Congr + (= t3 (Mul t7 t72)) + prf9 + prf11 + 1))) +(let t75 + (substitution + t35 + t63 + t73 + (c (Const 1.0)))) +(let t76 + (premises + (Congr + (= t13 (Mul (Const -1.0) t70)) + prf7 + (Trans + (= t3 t70) + (Sym + (= t3 t71) + (Rule + (= t71 t3) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t74 + t75)) + (Congr + (= t71 t70) + (Rule + (= t71 t71) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t74 + t75) + prf6 + 1)) + 1))) +(let t77 (c t7)) +(let t78 + (substitution + (a (Const -1.0)) + t65 + (b t52) + t77)) +(let t79 (Mul (Sqrt (Var "five")) (Const 1.0))) +(let t80 (Mul (Const -1.0) (Const -1.0))) +(let t81 (Mul (Sqrt (Var "five")) t80)) +(let t82 (Mul t80 (Sqrt (Var "five")))) +(let t83 (Mul (Const -1.0) t2)) +(let t84 + (@rewrite_var__7 + t13)) +(let t85 + (premises + (Rule + (= t67 t67) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + (premises + (Congr + (= + t83 + (Mul (Const -1.0) t72)) + (Rule + (= t83 t83) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + (premises + (Congr + (= + t13 + (Mul + (Const -1.0) + t59)) + prf7 + prf8 + 1)) + (substitution + t84 + (a (Const -1.0)) + (b t2) + t77)) + prf11 + 1)) + (substitution + (a (Const -1.0)) + (@rewrite_var__15 t83) + t73 + (c (Const 1.0)))))) +(let t86 + (substitution + (@rewrite_var__7 t67) + (a (Const -1.0)) + (b (Const -1.0)) + t37)) +(let t87 + (premises + (Sym + (= t67 t82) + (Rule + (= t82 t67) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t85 + t86)))) +(let t88 + (substitution + (a t80) + (@rewrite_var__5 t67) + t61)) +(let t89 (MathU (Sqrt (Var "five")))) +(let t90 + (premises + (Rule + (= t89 t89) + (name + "(rule ((= e (Sqrt x))) + ((MathU e)) + )") + (premises + (Fiat + (= + (Sqrt (Var "five")) + (Sqrt (Var "five"))))) + (substitution + (e (Sqrt (Var "five"))) + (x (Var "five")))))) +(let t91 (a (Sqrt (Var "five")))) +(let t92 (substitution t91)) +(let prf12 + (Rule + (= t79 (Sqrt (Var "five"))) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + t90 + t92)) +(let t93 + (Add + (Sqrt (Var "five")) + (Const 1.0))) +(let t94 (@rewrite_var__4 t0)) +(let t95 + (premises + (Congr + (= t1 (Mul t7 t93)) + prf4 + (Sym + (= t0 t93) + (Rule + (= t93 t0) + (name + "(rewrite (Add a b) (Add b a))") + t27 + (substitution + t94 + (a (Const 1.0)) + t61))) + 1))) +(let t96 (substitution t35 t36 t61 (c (Const 1.0)))) +(let prf13 + (Rule + (= t11 t11) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t95 + t96)) +(let prf14 + (Rule + (= t66 t11) + (name "(rewrite (Mul a b) (Mul b a))") + (premises prf13) + (substitution t35 (@rewrite_var__5 t11) t61))) +(let prf15 + (Trans + (= t53 t11) + (Congr + (= t53 t66) + (Sym + (= t53 t68) + (Rule + (= t68 t53) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + (premises + (Congr + (= t53 (Mul (Const -1.0) t69)) + (Rule + (= t53 t53) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t76 + t78) + (Sym + (= t52 t69) + (Rule + (= t69 t52) + (name + "(rewrite (Mul a b) (Mul b a))") + (premises + (Rule + (= t52 t52) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t74 + t75)) + (substitution + t35 + (@rewrite_var__5 t52) + t73))) + 1)) + (substitution + (@rewrite_var__7 t53) + (a (Const -1.0)) + t73 + t77))) + (Trans + (= t67 (Sqrt (Var "five"))) + (Trans + (= t67 t79) + (Sym + (= t67 t81) + (Rule + (= t81 t67) + (name "(rewrite (Mul a b) (Mul b a))") + t87 + t88)) + (Congr + (= t81 t79) + (Rule + (= t81 t81) + (name "(rewrite (Mul a b) (Mul b a))") + t87 + t88) + (Rule + (= t80 (Const 1.0)) + (name + "(rewrite (Mul (Const a) (Const b)) (Const (* a b)))") + (premises + (Rule + (= t80 t80) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t85 + t86)) + (substitution + (@rewrite_var__2 t80) + (a -1.0) + (b -1.0))) + 1)) + prf12) + 0) + prf14)) +(let t97 + (premises + (Congr + (= t14 (Add t7 t49)) + (Sym + (= t14 t50) + (Rule + (= t50 t14) + (name "(rewrite (Add a b) (Add b a))") + (premises + (Rule + (= t14 t14) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + t40 + t44)) + (substitution (@rewrite_var__4 t14) t42 t33))) + (Congr + (= t13 t49) + (Sym + (= t13 t54) + (Rule + (= t54 t13) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + (premises + (Congr + (= t13 (Mul (Const -1.0) t55)) + prf7 + (Trans + (= t3 t55) + (Sym + (= t3 t56) + (Rule + (= t56 t3) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t62 + t64)) + (Congr + (= t56 t55) + (Rule + (= t56 t56) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t62 + t64) + prf6 + 0)) + 1)) + (substitution + (a (Const -1.0)) + t65 + t33 + (c t52)))) + prf15 + 1) + 1))) +(let t98 (@rewrite_var__6 t14)) +(let t99 (substitution t41 t35 t98 (b t46))) +(let prf16 + (Sym + (= t14 t48) + (Rule + (= t48 t14) + (name "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + t97 + t99))) +(let t100 (Add t11 (Const 0.0))) +(let t101 (Mul t7 (Const 0.0))) +(let t102 (Add t11 t101)) +(let t103 (Add (Sqrt (Var "five")) (Const 0.0))) +(let prf17 + (Sym + (= (Sqrt (Var "five")) t103) + (Rule + (= t103 (Sqrt (Var "five"))) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + t90 + t92))) +(let t104 + (premises + (Congr (= t11 (Mul t7 t103)) prf13 prf17 1))) +(let t105 (@rewrite_var__15 t11)) +(let t106 (substitution t35 t105 t61 (c (Const 0.0)))) +(let t107 (Add (Const 0.0) t0)) +(let t108 (Add t0 (Const 0.0))) +(let t109 + (premises + (Congr + (= t1 (Mul t7 t107)) + prf4 + (Sym + (= t0 t107) + (Rule + (= t107 t0) + (name + "(rewrite (Add a b) (Add b a))") + (premises + (Sym + (= t0 t108) + (Rule + (= t108 t0) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + t28 + t30))) + (substitution + t94 + t29 + (b (Const 0.0))))) + 1))) +(let t110 + (substitution + t35 + t36 + (b (Const 0.0)) + (c t0))) +(let t111 (Div (Const 1.0) (Const 2.0))) +(let prf18 + (Sym + (= t7 (Const 0.5)) + (Rule + (= (Const 0.5) t7) + (name + "(rewrite (Div (Const a) (Const b)) (Const (/ a b)) :when ((!= b 0.0)))") + (premises + (Sym + (= t7 t111) + (Rule + (= t111 t7) + (name + "(rewrite (Pow x (Const -1.0)) (Div (Const 1.0) x) :when ((is-not-zero x)))") + (premises prf5 prf2) + (substitution + (@rewrite_var__21 t7) + (x (Const 2.0))))) + prf1) + (substitution + (a 1.0) + (b 2.0) + (@rewrite_var__3 t7))))) +(let prf19 + (Rule + (= t101 (Const 0.0)) + (name + "(rewrite (Mul (Const a) (Const b)) (Const (* a b)))") + (premises + (Congr + (= t101 (Mul (Const 0.5) (Const 0.0))) + (Rule + (= t101 t101) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t109 + t110) + prf18 + 0)) + (substitution + (@rewrite_var__2 t101) + (a 0.5) + (b 0.0)))) +(let t112 (b t11)) +(let t113 (Add t101 t11)) +(let t114 (Add t11 t7)) +(let t115 (Add t101 t1)) +(let t116 (Add t101 t24)) +(let t117 (Add t11 t22)) +(let prf20 + (Trans + (= t1 t114) + (Sym + (= t1 t117) + (Rule + (= t117 t1) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t95 + t96)) + (Congr + (= t117 t114) + (Rule + (= t117 t117) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t95 + t96) + prf6 + 1))) +(let t118 (Add (Const 0.0) (Sqrt (Var "five")))) +(let t119 (Add t13 t11)) +(let t120 (Add t11 t46)) +(let t121 (Add t11 t13)) +(let t122 (Add t53 t46)) +(let prf21 (Sym (= t11 t66) prf14)) +(let t123 + (premises + (Congr + (= t12 (Add t66 t66)) + (Congr + (= t12 (Add t66 t11)) + (Rule + (= t12 t12) + (name "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + (premises + (Congr + (= t119 (Add t11 t120)) + (Sym + (= t119 t121) + (Rule + (= t121 t119) + (name "(rewrite (Add a b) (Add b a))") + (premises + (Rule + (= t119 t119) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + (premises + (Congr + (= t4 (Add t13 t114)) + prf0 + prf20 + 1)) + (substitution t77 t42 t43 t112))) + (substitution (@rewrite_var__4 t119) t42 t112))) + (Congr + (= t13 t120) + (Sym + (= t13 t122) + (Rule + (= t122 t13) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t76 + t78)) + prf15 + 0) + 1)) + (substitution + (c t46) + (a t11) + (@rewrite_var__6 t119) + t112)) + prf21 + 0) + prf21 + 1))) +(let t124 (substitution t77 t91 (@rewrite_var__16 t12) t33)) +(let t125 + (premises + (Trans + (= t4 t10) + (Congr + (= t4 t12) + (Sym + (= t4 t15) + (Rule + (= t15 t4) + (name "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + t40 + t44)) + (Trans + (= t14 t11) + (Trans + (= t14 t45) + prf16 + (Congr + (= t48 t45) + (Rule + (= t48 t48) + (name "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + (premises + (Congr + (= t14 (Add t47 t100)) + prf16 + (Trans + (= t11 t100) + (Sym + (= t11 t102) + (Rule + (= t102 t11) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t104 + t106)) + (Congr + (= t102 t100) + (Rule + (= t102 t102) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t104 + t106) + prf19 + 1)) + 1)) + (substitution (c (Const 0.0)) (a t47) t98 t112)) + (Rule + (= t47 (Const 0.0)) + (name + "(rewrite (Add (Const a) (Const b)) (Const (+ a b)))") + (premises + (Congr + (= t47 (Add (Const 0.5) (Const -0.5))) + (Congr + (= t47 (Add (Const 0.5) t46)) + (Rule + (= t47 t47) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + t97 + t99) + prf18 + 0) + (Sym + (= t46 (Const -0.5)) + (Rule + (= (Const -0.5) t46) + (name + "(rewrite (Mul (Const a) (Const b)) (Const (* a b)))") + (premises + (Congr + (= t46 (Mul (Const -1.0) (Const 0.5))) + (Rule + (= t46 t46) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + (premises + (Congr + (= t13 (Mul (Const -1.0) t58)) + prf7 + prf9 + 1)) + (substitution + t84 + (a (Const -1.0)) + t33 + (c t2))) + prf18 + 1)) + (substitution + (@rewrite_var__2 t46) + (a -1.0) + (b 0.5)))) + 1)) + (substitution (a 0.5) (b -0.5) (@rewrite_var__ t47))) + 0)) + (Trans + (= t45 t11) + (Sym + (= t45 t113) + (Congr + (= t113 t45) + (Rule + (= t113 t113) + (name "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + (premises + (Congr + (= t1 (Add t101 t114)) + (Trans + (= t1 t115) + (Sym + (= t1 t116) + (Rule + (= t116 t1) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t109 + t110)) + (Congr + (= t116 t115) + (Rule + (= t116 t116) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t109 + t110) + prf3 + 1)) + prf20 + 1)) + (substitution t77 (a t101) (@rewrite_var__6 t1) t112)) + prf19 + 0)) + (Rule + (= t113 t11) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + (premises + (Congr + (= t11 (Mul t7 t118)) + prf13 + (Sym + (= (Sqrt (Var "five")) t118) + (Rule + (= t118 (Sqrt (Var "five"))) + (name "(rewrite (Add a b) (Add b a))") + (premises prf17) + (substitution + (@rewrite_var__4 (Sqrt (Var "five"))) + t91 + (b (Const 0.0))))) + 1)) + (substitution t35 t105 (b (Const 0.0)) t37)))) + 0) + (Sym + (= t12 t10) + (Rule + (= t10 t12) + (name "(rewrite (Add (Mul a b) (Mul a c)) (Mul a (Add b c)))") + t123 + t124))))) +(let t126 (substitution t91 (@rewrite_var__5 t4) (b t8))) +(Congr + (= t5 (Div (Const 1.0) (Sqrt (Var "five")))) + (Fiat (= t5 t5)) + (Trans + (= t4 (Sqrt (Var "five"))) + (Trans + (= t4 t6) + (Sym + (= t4 t9) + (Rule (= t9 t4) (name "(rewrite (Mul a b) (Mul b a))") t125 t126)) + (Congr + (= t9 t6) + (Rule (= t9 t9) (name "(rewrite (Mul a b) (Mul b a))") t125 t126) + (Rule + (= t8 (Const 1.0)) + (name "(rewrite (Add (Const a) (Const b)) (Const (+ a b)))") + (premises + (Congr + (= t8 (Add (Const 0.5) (Const 0.5))) + (Congr + (= t8 (Add (Const 0.5) t7)) + (Rule + (= t8 t8) + (name "(rewrite (Add (Mul a b) (Mul a c)) (Mul a (Add b c)))") + t123 + t124) + prf18 + 0) + prf18 + 1)) + (substitution (a 0.5) (b 0.5) (@rewrite_var__ t8))) + 0)) + (Rule + (= t6 (Sqrt (Var "five"))) + (name "(rewrite (Mul a b) (Mul b a))") + (premises (Sym (= (Sqrt (Var "five")) t79) prf12)) + (substitution t91 (@rewrite_var__5 (Sqrt (Var "five"))) (b (Const 1.0))))) + 1) +(let t0 (Add (Var "x") (Const 3.0))) +(let t1 (Mul t0 (Add (Var "x") (Const 1.0)))) +(let t2 (Mul (Var "x") (Var "x"))) +(let t3 (Mul (Const 4.0) (Var "x"))) +(let t4 (Add t2 t3)) +(let t5 (Mul t0 (Var "x"))) +(let t6 (Add t5 (Var "x"))) +(let t7 (Add t6 (Const 3.0))) +(let t8 (Mul t0 (Const 1.0))) +(let t9 (Add t5 t8)) +(let t10 (premises (Fiat (= t1 t1)))) +(let t11 (a t0)) +(let t12 + (substitution + t11 + (@rewrite_var__15 t1) + (b (Var "x")) + (c (Const 1.0)))) +(let t13 + (premises + (Congr + (= t1 (Add t5 t0)) + (Sym + (= t1 t9) + (Rule + (= t9 t1) + (name "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t10 + t12)) + (Rule + (= t8 t0) + (name "(rewrite (Mul a (Const 1.0)) a)") + (premises + (Rule + (= t8 t8) + (name "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t10 + t12)) + (substitution t11 (@rewrite_var__12 t8))) + 1))) +(let t14 (a t5)) +(let t15 (substitution (c (Const 3.0)) t14 (@rewrite_var__6 t1) (b (Var "x")))) +(let t16 (Mul (Var "x") (Const 3.0))) +(let t17 (Add (Var "x") t16)) +(let t18 (Add t2 t17)) +(let t19 (Add t17 t2)) +(let t20 (Add t16 t2)) +(let t21 (Add (Var "x") t5)) +(let prf0 + (Rule + (= t6 t6) + (name "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + t13 + t15)) +(let t22 (@rewrite_var__4 t6)) +(let t23 (Add (Const 3.0) (Var "x"))) +(let t24 (Mul (Var "x") t0)) +(let prf1 + (Sym + (= t5 t24) + (Rule + (= t24 t5) + (name "(rewrite (Mul a b) (Mul b a))") + (premises + (Rule + (= t5 t5) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t10 + t12)) + (substitution + t11 + (@rewrite_var__5 t5) + (b (Var "x")))))) +(let prf2 + (Sym + (= t0 t23) + (Rule + (= t23 t0) + (name "(rewrite (Add a b) (Add b a))") + (premises (Fiat (= t0 t0))) + (substitution + (@rewrite_var__4 t0) + (a (Var "x")) + (b (Const 3.0)))))) +(let t25 + (premises + (Congr + (= t6 (Add (Var "x") t20)) + (Sym + (= t6 t21) + (Rule + (= t21 t6) + (name "(rewrite (Add a b) (Add b a))") + (premises prf0) + (substitution t22 t14 (b (Var "x"))))) + (Sym + (= t5 t20) + (Rule + (= t20 t5) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + (premises (Congr (= t5 (Mul (Var "x") t23)) prf1 prf2 1)) + (substitution + (a (Var "x")) + (@rewrite_var__15 t5) + (b (Const 3.0)) + (c (Var "x"))))) + 1))) +(let t26 (substitution (c t2) (a (Var "x")) (@rewrite_var__6 t6) (b t16))) +(let t27 (Add (Const 1.0) (Const 3.0))) +(let t28 (Mul t27 (Var "x"))) +(let t29 (Mul (Var "x") t27)) +(let t30 (Mul (Var "x") (Const 1.0))) +(let prf3 + (Sym + (= (Var "x") t30) + (Rule + (= t30 (Var "x")) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + (premises + (Rule + (= (MathU (Var "x")) (MathU (Var "x"))) + (name + "(rule ((= e (Var x))) + ((MathU e)) + )") + (premises (Fiat (= (Var "x") (Var "x")))) + (substitution (e (Var "x")) (x "x")))) + (substitution (a (Var "x")))))) +(let t31 (Add t0 (Const 1.0))) +(let t32 (Add (Const 1.0) t0)) +(Congr + (= t1 (Add t4 (Const 3.0))) + (Sym + (= t1 t7) + (Rule + (= t7 t1) + (name "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + t13 + t15)) + (Congr + (= t6 t4) + (Sym + (= t6 t18) + (Rule + (= t18 t6) + (name "(rewrite (Add a b) (Add b a))") + (premises + (Sym + (= t6 t19) + (Rule + (= t19 t6) + (name "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + t25 + t26))) + (substitution t22 (a t17) (b t2)))) + (Congr + (= t17 t3) + (Sym + (= t17 t28) + (Rule + (= t28 t17) + (name "(rewrite (Mul a b) (Mul b a))") + (premises + (Sym + (= t17 t29) + (Rule + (= t29 t17) + (name "(rewrite (Add (Mul a b) (Mul a c)) (Mul a (Add b c)))") + (premises + (Congr + (= t17 (Add t30 t16)) + (Rule + (= t17 t17) + (name "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + t25 + t26) + prf3 + 0)) + (substitution + (c (Const 3.0)) + (a (Var "x")) + (@rewrite_var__16 t17) + (b (Const 1.0)))))) + (substitution (a (Var "x")) (@rewrite_var__5 t17) (b t27)))) + (Sym + (= t27 (Const 4.0)) + (Rule + (= (Const 4.0) t27) + (name "(rewrite (Add (Const a) (Const b)) (Const (+ a b)))") + (premises + (Rule + (= t27 t27) + (name "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + (premises + (Congr + (= t31 (Add (Const 1.0) t23)) + (Sym + (= t31 t32) + (Rule + (= t32 t31) + (name "(rewrite (Add a b) (Add b a))") + (premises + (Rule + (= t31 t31) + (name + "(rewrite (Add (Mul a b) (Mul a c)) (Mul a (Add b c)))") + (premises + (Congr + (= t6 (Add t24 t30)) + (Congr (= t6 (Add t24 (Var "x"))) prf0 prf1 0) + prf3 + 1)) + (substitution + (c (Const 1.0)) + (a (Var "x")) + (@rewrite_var__16 t6) + (b t0)))) + (substitution (@rewrite_var__4 t31) t11 (b (Const 1.0))))) + prf2 + 1)) + (substitution + (c (Var "x")) + (a (Const 1.0)) + (@rewrite_var__6 t31) + (b (Const 3.0))))) + (substitution (a 1.0) (b 3.0) (@rewrite_var__ t27)))) + 0) + 1) + 0) +(let t0 (Diff (Var "x") (Var "x"))) +(Sym + (= t0 (Const 1.0)) + (Rule + (= (Const 1.0) t0) + (name "(rewrite (Diff (Var x) (Var x)) (Const 1.0))") + (premises (Fiat (= t0 t0))) + (substitution (@rewrite_var__23 t0) (x "x")))) +(let t0 (Diff (Var "x") (Var "y"))) +(let prf0 (Fiat (= t0 t0))) +(let t1 (is-const-or-distinct-var (Var "y") "x")) +(let t2 (is-const-or-distinct-var-demand (Var "y") "x")) +(Sym + (= t0 (Const 0.0)) + (Rule + (= (Const 0.0) t0) + (name + "(rewrite (Diff (Var x) c) (Const 0.0) :when ((is-const-or-distinct-var c x)))") + (premises + prf0 + (Rule + (= t1 t1) + (name + "(rule ((is-const-or-distinct-var-demand (Var w) v) + (!= v w)) + ((is-const-or-distinct-var (Var w) v)) + )") + (premises + (Rule + (= t2 t2) + (name + "(rule ((Diff (Var x) c)) + ((is-const-or-distinct-var-demand c x)) + )") + (premises prf0) + (substitution (x "x") (c (Var "y")))) + (Fiat (= () ()))) + (substitution (v "x") (w "y")))) + (substitution (c (Var "y")) (@rewrite_var__24 t0) (x "x")))) +(let t0 (Mul (Const 2.0) (Var "x"))) +(let t1 (Add (Const 1.0) t0)) +(let t2 (Diff (Var "x") t1)) +(let t3 (Diff (Var "x") (Const 1.0))) +(let t4 (Add t3 (Const 2.0))) +(let t5 (Diff (Var "x") (Const 2.0))) +(let t6 (Mul (Var "x") t5)) +(let t7 (Add t3 t6)) +(let t8 (Add t7 (Const 2.0))) +(let t9 (Diff (Var "x") (Var "x"))) +(let t10 (Mul (Const 2.0) t9)) +(let t11 (Add t7 t10)) +(let t12 (Add t6 t10)) +(let t13 (Diff (Var "x") t0)) +(let t14 (Add t3 t13)) +(let t15 (premises (Fiat (= t2 t2)))) +(let t16 + (substitution + (b t0) + (a (Const 1.0)) + (@rewrite_var__25 t2) + (x (Var "x")))) +(let prf0 + (Sym + (= t2 t14) + (Rule + (= t14 t2) + (name + "(rewrite (Diff x (Add a b)) (Add (Diff x a) (Diff x b)))") + t15 + t16))) +(let t17 (Mul (Var "x") (Const 2.0))) +(let prf1 + (Rule + (= t13 t13) + (name + "(rewrite (Diff x (Add a b)) (Add (Diff x a) (Diff x b)))") + t15 + t16)) +(let t18 + (premises + (Congr + (= t13 (Diff (Var "x") t17)) + prf1 + (Sym + (= t0 t17) + (Rule + (= t17 t0) + (name "(rewrite (Mul a b) (Mul b a))") + (premises (Fiat (= t0 t0))) + (substitution + (a (Const 2.0)) + (@rewrite_var__5 t0) + (b (Var "x"))))) + 1))) +(let t19 (@rewrite_var__26 t13)) +(let t20 + (substitution + t19 + (a (Var "x")) + (x (Var "x")) + (b (Const 2.0)))) +(let t21 + (premises + (Congr + (= t2 (Add t3 t12)) + prf0 + (Sym + (= t13 t12) + (Rule + (= t12 t13) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t18 + t20)) + 1))) +(let t22 (a t3)) +(let t23 (@rewrite_var__6 t2)) +(let t24 (b t6)) +(let t25 (substitution (c t10) t22 t23 t24)) +(let t26 (Mul (Const 2.0) (Const 1.0))) +(let prf2 + (Rule + (= t9 t9) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t18 + t20)) +(let t27 + (premises + (Rule + (= (MathU (Const 2.0)) (MathU (Const 2.0))) + (name + "(rule ((= e (Const x))) + ((MathU e)) + )") + (premises (Fiat (= (Const 2.0) (Const 2.0)))) + (substitution (e (Const 2.0)) (x 2.0))))) +(let t28 (substitution (a (Const 2.0)))) +(let prf3 + (Trans + (= t10 (Const 2.0)) + (Congr + (= t10 t26) + (Rule + (= t10 t10) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t18 + t20) + (Rule + (= t9 (Const 1.0)) + (name "(rewrite (Diff (Var x) (Var x)) (Const 1.0))") + (premises prf2) + (substitution (@rewrite_var__23 t9) (x "x"))) + 1) + (Rule + (= t26 (Const 2.0)) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + t27 + t28))) +(let prf4 + (Congr + (= t2 t8) + (Sym + (= t2 t11) + (Rule + (= t11 t2) + (name "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + t21 + t25)) + prf3 + 1)) +(let t29 (Add t6 t3)) +(let t30 (Add t6 (Const 0.0))) +(let t31 (MathU t6)) +(let t32 + (premises + (Rule + (= t6 t6) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t18 + t20))) +(let t33 + (premises + (Rule + (= t31 t31) + (name + "(rule ((= e (Mul x y))) + ((MathU e)) + )") + t32 + (substitution (y t5) (e t6) (x (Var "x")))))) +(let t34 (a t6)) +(let t35 (substitution t34)) +(let prf5 + (Rule + (= t3 t3) + (name + "(rewrite (Diff x (Add a b)) (Add (Diff x a) (Diff x b)))") + t15 + t16)) +(let t36 (is-const-or-distinct-var (Const 1.0) "x")) +(let t37 (is-const-or-distinct-var-demand (Const 1.0) "x")) +(let prf6 + (Rule + (= (Const 0.0) t3) + (name + "(rewrite (Diff (Var x) c) (Const 0.0) :when ((is-const-or-distinct-var c x)))") + (premises + prf5 + (Rule + (= t36 t36) + (name + "(rule ((is-const-or-distinct-var-demand (Const c) v)) + ((is-const-or-distinct-var (Const c) v)) + )") + (premises + (Rule + (= t37 t37) + (name + "(rule ((Diff (Var x) c)) + ((is-const-or-distinct-var-demand c x)) + )") + (premises prf5) + (substitution (x "x") (c (Const 1.0))))) + (substitution (v "x") (c 1.0)))) + (substitution (c (Const 1.0)) (@rewrite_var__24 t3) (x "x")))) +(let prf7 + (Trans + (= t7 t6) + (Sym + (= t7 t29) + (Rule + (= t29 t7) + (name "(rewrite (Add a b) (Add b a))") + (premises + (Rule + (= t7 t7) + (name "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + t21 + t25)) + (substitution (@rewrite_var__4 t7) t22 t24))) + (Trans + (= t29 t6) + (Sym + (= t29 t30) + (Congr + (= t30 t29) + (Rule + (= t30 t30) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + t33 + t35) + prf6 + 1)) + (Rule + (= t30 t6) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + t33 + t35)))) +(let t38 (Mul (Var "x") t3)) +(let t39 (Mul (Const 1.0) (Var "x"))) +(let t40 (Mul t39 t5)) +(let t41 (Mul (Const 1.0) t7)) +(let t42 (Mul (Const 1.0) t6)) +(let t43 (Mul t6 (Const 1.0))) +(let t44 (Mul t5 (Var "x"))) +(let t45 (Mul t44 (Const 1.0))) +(let t46 (Mul (Var "x") (Const 1.0))) +(let t47 (@rewrite_var__5 t6)) +(let prf8 + (Rule + (= t44 t6) + (name "(rewrite (Mul a b) (Mul b a))") + t32 + (substitution (a (Var "x")) t47 (b t5)))) +(let prf9 + (Sym + (= (Var "x") t46) + (Rule + (= t46 (Var "x")) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + (premises + (Rule + (= (MathU (Var "x")) (MathU (Var "x"))) + (name + "(rule ((= e (Var x))) + ((MathU e)) + )") + (premises (Fiat (= (Var "x") (Var "x")))) + (substitution (e (Var "x")) (x "x")))) + (substitution (a (Var "x")))))) +(let t48 + (premises + (Congr + (= t6 (Mul t5 t46)) + (Sym (= t6 t44) prf8) + prf9 + 1))) +(let t49 + (substitution + (@rewrite_var__7 t6) + (a t5) + (b (Var "x")) + (c (Const 1.0)))) +(let t50 (Mul (Const 1.0) t2)) +(let t51 (Mul t2 (Const 1.0))) +(let t52 (MathU t2)) +(let t53 (a t2)) +(let prf10 + (Congr + (= t41 t42) + (Rule + (= t41 t41) + (name "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + (premises + (Congr + (= t2 (Mul (Const 1.0) t8)) + (Sym + (= t2 t50) + (Rule + (= t50 t2) + (name "(rewrite (Mul a b) (Mul b a))") + (premises + (Sym + (= t2 t51) + (Rule + (= t51 t2) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + (premises + (Rule + (= t52 t52) + (name + "(rule ((= e (Diff x y))) + ((MathU e)) + )") + t15 + (substitution (y t1) (e t2) (x (Var "x"))))) + (substitution t53)))) + (substitution + t53 + (@rewrite_var__5 t2) + (b (Const 1.0))))) + prf4 + 1)) + (substitution + (a (Const 1.0)) + (@rewrite_var__15 t2) + (b t7) + (c (Const 2.0)))) + prf7 + 1)) +(let t54 (premises prf10)) +(let t55 + (substitution + (@rewrite_var__7 t41) + (a (Const 1.0)) + (b (Var "x")) + (c t5))) +(let prf11 + (Rule + (= t5 t5) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t18 + t20)) +(let t56 (is-const-or-distinct-var (Const 2.0) "x")) +(let t57 (is-const-or-distinct-var-demand (Const 2.0) "x")) +(let t58 (Add t3 t10)) +(let t59 (Add t10 t6)) +(let prf12 + (Congr + (= t58 t4) + (Rule + (= t58 t58) + (name "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + (premises + (Congr + (= t2 (Add t3 t59)) + prf0 + (Sym + (= t13 t59) + (Rule + (= t59 t13) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + (premises prf1) + (substitution t19 (a (Const 2.0)) (x (Var "x")) (b (Var "x"))))) + 1)) + (substitution (c t6) t22 t23 (b t10))) + prf3 + 1)) +(let t60 (Add (Const 2.0) t3)) +(let t61 (Add (Const 2.0) (Const 0.0))) +(Trans + (= t2 (Const 2.0)) + (Congr + (= t2 t4) + (Congr (= t2 (Add t6 (Const 2.0))) prf4 prf7 0) + (Trans + (= t6 t3) + (Trans + (= t6 t38) + (Trans + (= t6 t40) + (Trans + (= t6 t41) + (Sym + (= t6 t42) + (Rule + (= t42 t6) + (name "(rewrite (Mul a b) (Mul b a))") + (premises + (Trans + (= t6 t43) + (Sym + (= t6 t45) + (Rule + (= t45 t6) + (name "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t48 + t49)) + (Congr + (= t45 t43) + (Rule + (= t45 t45) + (name "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t48 + t49) + prf8 + 0))) + (substitution t34 t47 (b (Const 1.0))))) + (Sym (= t42 t41) prf10)) + (Sym + (= t41 t40) + (Rule + (= t40 t41) + (name "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t54 + t55))) + (Congr + (= t40 t38) + (Congr + (= t40 t6) + (Rule + (= t40 t40) + (name "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t54 + t55) + (Rule + (= t39 (Var "x")) + (name "(rewrite (Mul a b) (Mul b a))") + (premises prf9) + (substitution + (a (Var "x")) + (@rewrite_var__5 (Var "x")) + (b (Const 1.0)))) + 0) + (Trans + (= t5 t3) + (Rule + (= t5 (Const 0.0)) + (name + "(rewrite (Diff (Var x) c) (Const 0.0) :when ((is-const-or-distinct-var c x)))") + (premises + prf11 + (Rule + (= t56 t56) + (name + "(rule ((is-const-or-distinct-var-demand (Const c) v)) + ((is-const-or-distinct-var (Const c) v)) + )") + (premises + (Rule + (= t57 t57) + (name + "(rule ((Diff (Var x) c)) + ((is-const-or-distinct-var-demand c x)) + )") + (premises prf11) + (substitution (x "x") (c (Const 2.0))))) + (substitution (v "x") (c 2.0)))) + (substitution (c (Const 2.0)) (@rewrite_var__24 t5) (x "x"))) + prf6) + 1)) + (Trans + (= t38 t3) + (Rule + (= t38 (Const 0.0)) + (name "(rewrite (Mul a (Const 0.0)) (Const 0.0))") + (premises + (Congr + (= t38 (Mul (Var "x") (Const 0.0))) + (Rule + (= t38 t38) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + (premises (Congr (= t9 (Diff (Var "x") t46)) prf2 prf9 1)) + (substitution + (@rewrite_var__26 t9) + (a (Var "x")) + (x (Var "x")) + (b (Const 1.0)))) + (Sym (= t3 (Const 0.0)) prf6) + 1)) + (substitution (a (Var "x")) (@rewrite_var__11 t38))) + prf6)) + 0) + (Trans + (= t4 (Const 2.0)) + (Sym (= t4 t58) prf12) + (Trans + (= t58 (Const 2.0)) + (Sym + (= t58 t60) + (Rule + (= t60 t58) + (name "(rewrite (Add a b) (Add b a))") + (premises prf12) + (substitution (@rewrite_var__4 t58) t22 (b (Const 2.0))))) + (Sym + (= t60 (Const 2.0)) + (Congr + (= (Const 2.0) t60) + (Sym + (= (Const 2.0) t61) + (Rule + (= t61 (Const 2.0)) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + t27 + t28)) + prf6 + 1))))) +(let t0 (Mul (Var "y") (Var "x"))) +(let t1 (Diff (Var "x") (Add (Const 1.0) t0))) +(let t2 (Diff (Var "x") (Const 1.0))) +(let t3 (Add t2 (Var "y"))) +(let t4 (Diff (Var "x") (Var "y"))) +(let t5 (Mul (Var "x") t4)) +(let t6 (Add t5 (Var "y"))) +(let t7 (Add t2 t5)) +(let t8 (Diff (Var "x") (Var "x"))) +(let t9 (Mul (Var "y") t8)) +(let t10 (Add t7 t9)) +(let t11 (Add t5 t9)) +(let t12 (Diff (Var "x") t0)) +(let t13 (Add t2 t12)) +(let t14 (premises (Fiat (= t1 t1)))) +(let t15 + (substitution + (b t0) + (a (Const 1.0)) + (@rewrite_var__25 t1) + (x (Var "x")))) +(let t16 (Mul (Var "x") (Var "y"))) +(let prf0 + (Sym + (= t0 t16) + (Rule + (= t16 t0) + (name "(rewrite (Mul a b) (Mul b a))") + (premises (Fiat (= t0 t0))) + (substitution + (a (Var "y")) + (@rewrite_var__5 t0) + (b (Var "x")))))) +(let t17 + (premises + (Congr + (= t12 (Diff (Var "x") t16)) + (Rule + (= t12 t12) + (name + "(rewrite (Diff x (Add a b)) (Add (Diff x a) (Diff x b)))") + t14 + t15) + prf0 + 1))) +(let t18 + (substitution + (@rewrite_var__26 t12) + (a (Var "x")) + (x (Var "x")) + (b (Var "y")))) +(let prf1 + (Sym + (= t12 t11) + (Rule + (= t11 t12) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t17 + t18))) +(let t19 + (premises + (Congr + (= t1 (Add t2 t11)) + (Sym + (= t1 t13) + (Rule + (= t13 t1) + (name + "(rewrite (Diff x (Add a b)) (Add (Diff x a) (Diff x b)))") + t14 + t15)) + prf1 + 1))) +(let t20 (a t2)) +(let t21 (b t5)) +(let t22 (substitution (c t9) t20 (@rewrite_var__6 t1) t21)) +(let t23 (Mul (Const 1.0) (Var "y"))) +(let t24 (Mul t8 (Var "y"))) +(let t25 + (premises + (Rule + (= t9 t9) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t17 + t18))) +(let t26 (substitution (a (Var "y")) (@rewrite_var__5 t9) (b t8))) +(let t27 (Mul (Var "y") (Const 1.0))) +(let t28 + (premises + (Rule + (= (MathU (Var "y")) (MathU (Var "y"))) + (name + "(rule ((= e (Var x))) + ((MathU e)) + )") + (premises (Fiat (= (Var "y") (Var "y")))) + (substitution (e (Var "y")) (x "y"))))) +(let t29 (substitution (a (Var "y")))) +(let prf2 + (Trans + (= t9 (Var "y")) + (Trans + (= t9 t23) + (Sym + (= t9 t24) + (Rule (= t24 t9) (name "(rewrite (Mul a b) (Mul b a))") t25 t26)) + (Congr + (= t24 t23) + (Rule (= t24 t24) (name "(rewrite (Mul a b) (Mul b a))") t25 t26) + (Rule + (= t8 (Const 1.0)) + (name "(rewrite (Diff (Var x) (Var x)) (Const 1.0))") + (premises + (Rule + (= t8 t8) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t17 + t18)) + (substitution (@rewrite_var__23 t8) (x "x"))) + 0)) + (Rule + (= t23 (Var "y")) + (name "(rewrite (Mul a b) (Mul b a))") + (premises + (Sym + (= (Var "y") t27) + (Rule + (= t27 (Var "y")) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + t28 + t29))) + (substitution + (a (Var "y")) + (@rewrite_var__5 (Var "y")) + (b (Const 1.0)))))) +(let t30 (Add t5 t2)) +(let t31 (Add t5 (Const 0.0))) +(let t32 (Add (Const 0.0) (Var "y"))) +(let t33 (Add (Var "y") (Const 0.0))) +(let prf3 + (Sym + (= (Var "y") t33) + (Rule + (= t33 (Var "y")) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + t28 + t29))) +(let prf4 + (Rule + (= t32 (Var "y")) + (name "(rewrite (Add a b) (Add b a))") + (premises prf3) + (substitution + (@rewrite_var__4 (Var "y")) + (a (Var "y")) + (b (Const 0.0))))) +(let prf5 (Sym (= (Var "y") t32) prf4)) +(let t34 (a t5)) +(let prf6 + (Rule + (= t2 t2) + (name + "(rewrite (Diff x (Add a b)) (Add (Diff x a) (Diff x b)))") + t14 + t15)) +(let t35 (is-const-or-distinct-var (Const 1.0) "x")) +(let t36 (is-const-or-distinct-var-demand (Const 1.0) "x")) +(let prf7 + (Rule + (= (Const 0.0) t2) + (name + "(rewrite (Diff (Var x) c) (Const 0.0) :when ((is-const-or-distinct-var c x)))") + (premises + prf6 + (Rule + (= t35 t35) + (name + "(rule ((is-const-or-distinct-var-demand (Const c) v)) + ((is-const-or-distinct-var (Const c) v)) + )") + (premises + (Rule + (= t36 t36) + (name + "(rule ((Diff (Var x) c)) + ((is-const-or-distinct-var-demand c x)) + )") + (premises prf6) + (substitution (x "x") (c (Const 1.0))))) + (substitution (v "x") (c 1.0)))) + (substitution (c (Const 1.0)) (@rewrite_var__24 t2) (x "x")))) +(let t37 (MathU t5)) +(let prf8 + (Rule + (= t5 t5) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t17 + t18)) +(let t38 (Mul (Var "x") t2)) +(let t39 (Diff (Var "x") (Const 0.0))) +(let t40 (Add t4 t39)) +(let t41 (Mul (Var "x") t40)) +(let prop0 (= t5 t41)) +(let t42 (Add t5 (Mul (Var "x") t39))) +(let prf9 + (Rule + (= t4 t4) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t17 + t18)) +(let prf10 + (Rule + (= t40 t4) + (name + "(rewrite (Diff x (Add a b)) (Add (Diff x a) (Diff x b)))") + (premises + (Congr (= t4 (Diff (Var "x") t33)) prf9 prf3 1)) + (substitution + (b (Const 0.0)) + (a (Var "y")) + (@rewrite_var__25 t4) + (x (Var "x"))))) +(let t43 (b t4)) +(let t44 (c t39)) +(let t45 + (premises + (Sym + (= t5 t42) + (Rule + (= t42 t5) + (name "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + (premises (Congr prop0 prf8 (Sym (= t4 t40) prf10) 1)) + (substitution (a (Var "x")) (@rewrite_var__15 t5) t43 t44))))) +(let t46 (substitution t44 (a (Var "x")) (@rewrite_var__16 t5) t43)) +(let t47 (is-const-or-distinct-var (Var "y") "x")) +(let t48 (is-const-or-distinct-var-demand (Var "y") "x")) +(let t49 (Mul (Var "x") (Const 0.0))) +(let prf11 + (Rule + (= t49 t49) + (name "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + (premises (Congr (= t0 (Mul (Var "x") t33)) prf0 prf3 1)) + (substitution + (a (Var "x")) + (@rewrite_var__15 t0) + (b (Var "y")) + (c (Const 0.0))))) +(Trans + (= t1 (Var "y")) + (Congr + (= t1 t3) + (Congr + (= t1 t6) + (Congr + (= t1 (Add t7 (Var "y"))) + (Sym + (= t1 t10) + (Rule + (= t10 t1) + (name "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + t19 + t22)) + prf2 + 1) + (Trans + (= t7 t5) + (Sym + (= t7 t30) + (Rule + (= t30 t7) + (name "(rewrite (Add a b) (Add b a))") + (premises + (Rule + (= t7 t7) + (name "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + t19 + t22)) + (substitution (@rewrite_var__4 t7) t20 t21))) + (Trans + (= t30 t5) + (Sym + (= t30 t31) + (Congr + (= t31 t30) + (Rule + (= t31 t31) + (name "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + (premises + (Congr + (= t12 (Add t5 t32)) + (Congr (= t12 t6) prf1 prf2 1) + prf5 + 1)) + (substitution + (c (Var "y")) + t34 + (@rewrite_var__6 t12) + (b (Const 0.0)))) + prf7 + 1)) + (Rule + (= t31 t5) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + (premises + (Rule + (= t37 t37) + (name + "(rule ((= e (Mul x y))) + ((MathU e)) + )") + (premises prf8) + (substitution (y t4) (e t5) (x (Var "x"))))) + (substitution t34)))) + 0) + (Trans + (= t5 t2) + (Trans + (= t5 t38) + (Sym + prop0 + (Rule + (= t41 t5) + (name "(rewrite (Add (Mul a b) (Mul a c)) (Mul a (Add b c)))") + t45 + t46)) + (Congr + (= t41 t38) + (Rule + (= t41 t41) + (name "(rewrite (Add (Mul a b) (Mul a c)) (Mul a (Add b c)))") + t45 + t46) + (Trans + (= t40 t2) + (Trans + (= t40 (Const 0.0)) + prf10 + (Rule + (= t4 (Const 0.0)) + (name + "(rewrite (Diff (Var x) c) (Const 0.0) :when ((is-const-or-distinct-var c x)))") + (premises + prf9 + (Rule + (= t47 t47) + (name + "(rule ((is-const-or-distinct-var-demand (Var w) v) + (!= v w)) + ((is-const-or-distinct-var (Var w) v)) + )") + (premises + (Rule + (= t48 t48) + (name + "(rule ((Diff (Var x) c)) + ((is-const-or-distinct-var-demand c x)) + )") + (premises prf9) + (substitution (x "x") (c (Var "y")))) + (Fiat (= () ()))) + (substitution (v "x") (w "y")))) + (substitution (c (Var "y")) (@rewrite_var__24 t4) (x "x")))) + prf7) + 1)) + (Trans + (= t38 t2) + (Sym (= t38 t49) (Congr (= t49 t38) prf11 prf7 1)) + (Trans + (= t49 t2) + (Rule + (= t49 (Const 0.0)) + (name "(rewrite (Mul a (Const 0.0)) (Const 0.0))") + (premises prf11) + (substitution (a (Var "x")) (@rewrite_var__11 t49))) + prf7))) + 0) + (Trans + (= t3 (Var "y")) + (Sym + (= t3 t32) + (Congr + (= t32 t3) + (Rule + (= t32 t32) + (name "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + (premises (Congr (= (Var "y") (Add (Const 0.0) t33)) prf5 prf3 1)) + (substitution + (c (Const 0.0)) + (a (Const 0.0)) + (@rewrite_var__6 (Var "y")) + (b (Var "y")))) + prf7 + 0)) + prf4)) +(let t0 (Diff (Var "x") (Ln (Var "x")))) +(let t1 (Div (Const 1.0) (Var "x"))) +(let prf0 (Fiat (= t0 t0))) +(let t2 (MathU t0)) +(Sym + (= t0 t1) + (Rule + (= t1 t0) + (name + "(rewrite (Diff x (Ln x)) (Div (Const 1.0) x) :when ((is-not-zero x)))") + (premises + prf0 + (Rule + (= (is-not-zero (Var "x")) (is-not-zero (Var "x"))) + (name + "(rule ((MathU x) + (!= x (Const 0.0))) + ((is-not-zero x)) + )") + (premises + (Rule + (= (MathU (Var "x")) (MathU (Var "x"))) + (name + "(rule ((= e (Var x))) + ((MathU e)) + )") + (premises (Fiat (= (Var "x") (Var "x")))) + (substitution (e (Var "x")) (x "x"))) + (Rule + (= (Const 0.0) (Const 0.0)) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + (premises + (Rule + (= t2 t2) + (name + "(rule ((= e (Diff x y))) + ((MathU e)) + )") + (premises prf0) + (substitution (y (Ln (Var "x"))) (e t0) (x (Var "x"))))) + (substitution (a t0))) + (Fiat (= () ()))) + (substitution (x (Var "x")) (@v313 (Const 0.0))))) + (substitution (@rewrite_var__29 t0) (x (Var "x"))))) +(let t0 (Pow (Var "x") (Const 3.0))) +(let t1 (Diff (Var "x") t0)) +(let t2 (Pow (Var "x") (Const 2.0))) +(let t3 (Pow (Var "x") (Const -1.0))) +(let t4 (Mul t0 t3)) +(let t5 (Mul (Const 3.0) t4)) +(let t6 (Diff (Var "x") (Var "x"))) +(let t7 (Div (Const 3.0) (Var "x"))) +(let t8 (Mul t6 t7)) +(let t9 (Mul t0 t8)) +(let t10 (Add (Const 0.0) t9)) +(let t11 (Diff (Var "x") (Const 3.0))) +(let t12 (Mul t11 (Ln (Var "x")))) +(let t13 (Add t12 t9)) +(let t14 (Mul t0 t12)) +(let t15 (Add t9 t14)) +(let prop0 (= t1 t15)) +(let t16 (Diff (Var "x") (Const 1.0))) +(let t17 (Mul t0 t16)) +(let t18 (Add t17 t9)) +(let t19 (Add (Const 0.0) t18)) +(let t20 (Add t19 t14)) +(let t21 (Add t18 t14)) +(let t22 (Add (Const 0.0) t1)) +(let t23 (Add t1 (Const 0.0))) +(let t24 (MathU t1)) +(let prf0 (Fiat (= t1 t1))) +(let t25 + (premises + (Rule + (= t24 t24) + (name + "(rule ((= e (Diff x y))) + ((MathU e)) + )") + (premises prf0) + (substitution + (y t0) + (e t1) + (x (Var "x")))))) +(let t26 (a t1)) +(let t27 (substitution t26)) +(let t28 (@rewrite_var__4 t1)) +(let prf1 + (Sym + (= t1 t22) + (Rule + (= t22 t1) + (name "(rewrite (Add a b) (Add b a))") + (premises + (Sym + (= t1 t23) + (Rule + (= t23 t1) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + t25 + t27))) + (substitution t28 t26 (b (Const 0.0)))))) +(let t29 (Add t17 t1)) +(let t30 (Mul (Const 1.0) t1)) +(let t31 (Add t17 t30)) +(let t32 (Mul t0 (Const 1.0))) +(let t33 (MathU t0)) +(let t34 (a t0)) +(let prf2 + (Rule + (= t32 t0) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + (premises + (Rule + (= t33 t33) + (name + "(rule ((= e (Pow x y))) + ((MathU e)) + )") + (premises (Fiat (= t0 t0))) + (substitution + (y (Const 3.0)) + (e t0) + (x (Var "x"))))) + (substitution t34))) +(let t35 + (premises + (Congr + (= t1 (Diff (Var "x") t32)) + prf0 + (Sym (= t0 t32) prf2) + 1))) +(let t36 + (substitution + (@rewrite_var__26 t1) + t34 + (x (Var "x")) + (b (Const 1.0)))) +(let t37 (Mul t1 (Const 1.0))) +(let prf3 + (Rule + (= t30 t1) + (name "(rewrite (Mul a b) (Mul b a))") + (premises + (Sym + (= t1 t37) + (Rule + (= t37 t1) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + t25 + t27))) + (substitution + t26 + (@rewrite_var__5 t1) + (b (Const 1.0))))) +(let prf4 + (Congr + (= t1 t29) + (Sym + (= t1 t31) + (Rule + (= t31 t1) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t35 + t36)) + prf3 + 1)) +(let t38 (Mul t0 (Add t8 t12))) +(let prf5 + (Rule + (= (Const 0.0) (Const 0.0)) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + t25 + t27)) +(let prf6 (Fiat (= () ()))) +(let prf7 + (Rule + (= + (is-not-zero (Var "x")) + (is-not-zero (Var "x"))) + (name + "(rule ((MathU x) + (!= x (Const 0.0))) + ((is-not-zero x)) + )") + (premises + (Rule + (= + (MathU (Var "x")) + (MathU (Var "x"))) + (name + "(rule ((= e (Var x))) + ((MathU e)) + )") + (premises + (Fiat + (= (Var "x") (Var "x")))) + (substitution + (e (Var "x")) + (x "x"))) + prf5 + prf6) + (substitution + (x (Var "x")) + (@v313 (Const 0.0))))) +(let t39 + (premises + prf0 + prf7 + (Rule + (= + (is-not-zero (Const 3.0)) + (is-not-zero (Const 3.0))) + (name + "(rule ((MathU x) + (!= x (Const 0.0))) + ((is-not-zero x)) + )") + (premises + (Rule + (= + (MathU (Const 3.0)) + (MathU (Const 3.0))) + (name + "(rule ((= e (Const x))) + ((MathU e)) + )") + (premises + (Fiat + (= + (Const 3.0) + (Const 3.0)))) + (substitution + (e (Const 3.0)) + (x 3.0))) + prf5 + prf6) + (substitution + (x (Const 3.0)) + (@v313 (Const 0.0)))))) +(let t40 + (substitution + (@rewrite_var__30 t1) + (g (Const 3.0)) + (f (Var "x")) + (x (Var "x")))) +(let t41 + (premises + (Sym + (= t1 t38) + (Rule + (= t38 t1) + (name + "(rewrite (Diff x (Pow f g)) (Mul (Pow f g) (Add (Mul (Diff x f) (Div g f)) (Mul (Diff x g) (Ln f)))) :when ((is-not-zero f) (is-not-zero g)))") + t39 + t40)))) +(let t42 (@rewrite_var__15 t1)) +(let t43 (substitution t34 t42 (b t8) (c t12))) +(let prf8 + (Sym + prop0 + (Rule + (= t15 t1) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t41 + t43))) +(let t44 + (premises + (Congr (= t1 (Add t17 t15)) prf4 prf8 1))) +(let t45 (c t14)) +(let t46 (a t17)) +(let t47 (@rewrite_var__6 t1)) +(let t48 (b t9)) +(let t49 (substitution t45 t46 t47 t48)) +(let t50 + (premises + (Congr + (= t1 (Add (Const 0.0) t21)) + prf1 + (Sym + (= t1 t21) + (Rule + (= t21 t1) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + t44 + t49)) + 1))) +(let t51 (substitution t45 (a (Const 0.0)) t47 (b t18))) +(let t52 (Mul t0 (Const 0.0))) +(let t53 (Mul (Const 1.0) t16)) +(let t54 (Mul t0 t53)) +(let t55 (Mul t53 t0)) +(let t56 (Mul (Const 1.0) t17)) +(let t57 (Mul t17 (Const 1.0))) +(let t58 (MathU t17)) +(let t59 + (premises + (Rule + (= t17 t17) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t35 + t36))) +(let t60 (x t0)) +(let t61 (b t17)) +(let t62 (c t1)) +(let prf9 + (Rule + (= t56 t56) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + (premises + (Congr + (= t1 (Mul (Const 1.0) t29)) + (Sym (= t1 t30) prf3) + prf4 + 1)) + (substitution + (a (Const 1.0)) + t42 + t61 + t62))) +(let t63 (Mul t16 t0)) +(let t64 (@rewrite_var__5 t17)) +(let t65 (b t16)) +(let t66 + (premises + (Trans + (= t17 t55) + (Trans + (= t17 t56) + (Sym + (= t17 t57) + (Rule + (= t57 t17) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + (premises + (Rule + (= t58 t58) + (name + "(rule ((= e (Mul x y))) + ((MathU e)) + )") + t59 + (substitution + (y t16) + (e t17) + t60))) + (substitution t46))) + (Rule + (= t57 t56) + (name + "(rewrite (Mul a b) (Mul b a))") + (premises prf9) + (substitution + (a (Const 1.0)) + (@rewrite_var__5 t56) + t61))) + (Sym + (= t56 t55) + (Rule + (= t55 t56) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + (premises + (Congr + (= t56 (Mul (Const 1.0) t63)) + prf9 + (Sym + (= t17 t63) + (Rule + (= t63 t17) + (name + "(rewrite (Mul a b) (Mul b a))") + t59 + (substitution t34 t64 t65))) + 1)) + (substitution + (@rewrite_var__7 t56) + (a (Const 1.0)) + t65 + (c t0))))))) +(let t67 (substitution (a t53) t64 (b t0))) +(let prf10 + (Rule + (= t54 t17) + (name "(rewrite (Mul a b) (Mul b a))") + t66 + t67)) +(let t68 (Mul t16 (Const 1.0))) +(let t69 (MathU t16)) +(let prf11 + (Rule + (= t16 t16) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t35 + t36)) +(let t70 (premises prf11)) +(let t71 (a t16)) +(let prf12 + (Sym + (= t16 t68) + (Rule + (= t68 t16) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + (premises + (Rule + (= t69 t69) + (name + "(rule ((= e (Diff x y))) + ((MathU e)) + )") + t70 + (substitution + (y (Const 1.0)) + (e t16) + (x (Var "x"))))) + (substitution t71)))) +(let t72 + (is-const-or-distinct-var + (Const 1.0) + "x")) +(let t73 + (is-const-or-distinct-var-demand + (Const 1.0) + "x")) +(let prf13 + (Congr + (= t54 t52) + (Rule + (= t54 t54) + (name "(rewrite (Mul a b) (Mul b a))") + t66 + t67) + (Trans + (= t53 (Const 0.0)) + (Rule + (= t53 t16) + (name "(rewrite (Mul a b) (Mul b a))") + (premises prf12) + (substitution + t71 + (@rewrite_var__5 t16) + (b (Const 1.0)))) + (Rule + (= t16 (Const 0.0)) + (name + "(rewrite (Diff (Var x) c) (Const 0.0) :when ((is-const-or-distinct-var c x)))") + (premises + prf11 + (Rule + (= t72 t72) + (name + "(rule ((is-const-or-distinct-var-demand (Const c) v)) + ((is-const-or-distinct-var (Const c) v)) + )") + (premises + (Rule + (= t73 t73) + (name + "(rule ((Diff (Var x) c)) + ((is-const-or-distinct-var-demand c x)) + )") + t70 + (substitution + (x "x") + (c (Const 1.0))))) + (substitution (v "x") (c 1.0)))) + (substitution + (c (Const 1.0)) + (@rewrite_var__24 t16) + (x "x")))) + 1)) +(let prf14 + (Rule + (= t17 (Const 0.0)) + (name "(rewrite (Mul a (Const 0.0)) (Const 0.0))") + (premises + (Trans (= t17 t52) (Sym (= t17 t54) prf10) prf13)) + (substitution t34 (@rewrite_var__11 t17)))) +(let t74 (Add t9 (Const 0.0))) +(let t75 (MathU t9)) +(let prf15 + (Rule + (= t9 t9) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t41 + t43)) +(let t76 (a t9)) +(let prf16 + (Trans + (= t10 t9) + (Sym + (= t10 t74) + (Rule + (= t74 t10) + (name "(rewrite (Add a b) (Add b a))") + (premises + (Rule + (= t10 t10) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + (premises + (Congr + (= t1 (Add (Const 0.0) t15)) + prf1 + prf8 + 1)) + (substitution t45 (a (Const 0.0)) t47 t48))) + (substitution + (@rewrite_var__4 t10) + (a (Const 0.0)) + t48))) + (Rule + (= t74 t9) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + (premises + (Rule + (= t75 t75) + (name + "(rule ((= e (Mul x y))) + ((MathU e)) + )") + (premises prf15) + (substitution (y t8) (e t9) t60))) + (substitution t76)))) +(let t77 (Mul (Const 0.0) (Ln (Var "x")))) +(let t78 (Mul t0 t11)) +(let t79 (Mul t78 (Ln (Var "x")))) +(let t80 + (premises + (Rule + (= t14 t14) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t41 + t43))) +(let t81 (b t11)) +(let t82 + (substitution + (@rewrite_var__7 t14) + t34 + t81 + (c (Ln (Var "x"))))) +(let prf17 + (Rule + (= t11 t11) + (name + "(rewrite (Diff x (Pow f g)) (Mul (Pow f g) (Add (Mul (Diff x f) (Div g f)) (Mul (Diff x g) (Ln f)))) :when ((is-not-zero f) (is-not-zero g)))") + t39 + t40)) +(let t83 (is-const-or-distinct-var (Const 3.0) "x")) +(let t84 + (is-const-or-distinct-var-demand + (Const 3.0) + "x")) +(let t85 (premises prf17)) +(let prf18 + (Rule + (= t11 (Const 0.0)) + (name + "(rewrite (Diff (Var x) c) (Const 0.0) :when ((is-const-or-distinct-var c x)))") + (premises + prf17 + (Rule + (= t83 t83) + (name + "(rule ((is-const-or-distinct-var-demand (Const c) v)) + ((is-const-or-distinct-var (Const c) v)) + )") + (premises + (Rule + (= t84 t84) + (name + "(rule ((Diff (Var x) c)) + ((is-const-or-distinct-var-demand c x)) + )") + t85 + (substitution (x "x") (c (Const 3.0))))) + (substitution (v "x") (c 3.0)))) + (substitution + (c (Const 3.0)) + (@rewrite_var__24 t11) + (x "x")))) +(let prf19 + (Rule + (= t12 t12) + (name + "(rewrite (Diff x (Pow f g)) (Mul (Pow f g) (Add (Mul (Diff x f) (Div g f)) (Mul (Diff x g) (Ln f)))) :when ((is-not-zero f) (is-not-zero g)))") + t39 + t40)) +(let t86 + (premises + (Congr + (= t1 (Add t9 t12)) + (Congr + prop0 + (Sym + (= t1 t20) + (Rule + (= t20 t1) + (name "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + t50 + t51)) + (Trans + (= t19 t9) + (Congr + (= t19 t10) + (Rule + (= t19 t19) + (name "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + t50 + t51) + (Trans + (= t18 t9) + (Congr + (= t18 t10) + (Rule + (= t18 t18) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + t44 + t49) + prf14 + 0) + prf16) + 1) + prf16) + 0) + (Trans + (= t14 t12) + (Congr + (= t14 t77) + (Sym + (= t14 t79) + (Rule + (= t79 t14) + (name "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t80 + t82)) + (Trans + (= t78 (Const 0.0)) + (Congr + (= t78 t52) + (Rule + (= t78 t78) + (name "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t80 + t82) + prf18 + 1) + (Trans + (= t52 (Const 0.0)) + (Trans (= t52 t17) (Sym (= t52 t54) prf13) prf10) + prf14)) + 0) + (Sym (= t77 t12) (Congr (= t12 t77) prf19 prf18 0))) + 1))) +(let t87 (substitution t28 t76 (b t12))) +(let t88 (Mul (Ln (Var "x")) (Const 0.0))) +(let t89 (Mul (Ln (Var "x")) t11)) +(let t90 (a t11)) +(let prf20 + (Sym + (= t12 t89) + (Rule + (= t89 t12) + (name "(rewrite (Mul a b) (Mul b a))") + (premises prf19) + (substitution t90 (@rewrite_var__5 t12) (b (Ln (Var "x"))))))) +(let t91 (Mul t11 (Const 1.0))) +(let t92 (MathU t11)) +(let t93 (a (Ln (Var "x")))) +(let t94 (Mul t4 (Const 3.0))) +(let t95 (Mul t3 (Const 3.0))) +(let t96 (Mul t0 t7)) +(let t97 (Mul t32 t7)) +(let t98 (Mul (Const 1.0) t7)) +(let t99 + (premises + (Congr + (= t9 (Mul t0 t98)) + prf15 + (Congr + (= t8 t98) + (Rule + (= t8 t8) + (name + "(rewrite (Diff x (Pow f g)) (Mul (Pow f g) (Add (Mul (Diff x f) (Div g f)) (Mul (Diff x g) (Ln f)))) :when ((is-not-zero f) (is-not-zero g)))") + t39 + t40) + (Rule + (= t6 (Const 1.0)) + (name + "(rewrite (Diff (Var x) (Var x)) (Const 1.0))") + (premises + (Rule + (= t6 t6) + (name + "(rewrite (Diff x (Pow f g)) (Mul (Pow f g) (Add (Mul (Diff x f) (Div g f)) (Mul (Diff x g) (Ln f)))) :when ((is-not-zero f) (is-not-zero g)))") + t39 + t40)) + (substitution (@rewrite_var__23 t6) (x "x"))) + 0) + 1))) +(let t100 (@rewrite_var__7 t9)) +(let t101 (substitution t100 t34 (b (Const 1.0)) (c t7))) +(let t102 (Mul (Const 3.0) t3)) +(let t103 (b t3)) +(let t104 + (premises + (Congr + (= t9 (Mul t0 t95)) + (Trans + (= t9 t96) + (Sym + (= t9 t97) + (Rule + (= t97 t9) + (name "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t99 + t101)) + (Congr + (= t97 t96) + (Rule + (= t97 t97) + (name "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t99 + t101) + prf2 + 0)) + (Sym + (= t7 t95) + (Rule + (= t95 t7) + (name "(rewrite (Mul a b) (Mul b a))") + (premises + (Sym + (= t7 t102) + (Rule + (= t102 t7) + (name + "(rewrite (Div a b) (Mul a (Pow b (Const -1.0))) :when ((is-not-zero b)))") + (premises + (Rule + (= t7 t7) + (name + "(rewrite (Diff x (Pow f g)) (Mul (Pow f g) (Add (Mul (Diff x f) (Div g f)) (Mul (Diff x g) (Ln f)))) :when ((is-not-zero f) (is-not-zero g)))") + t39 + t40) + prf7) + (substitution + (a (Const 3.0)) + (b (Var "x")) + (@rewrite_var__9 t7))))) + (substitution (a (Const 3.0)) (@rewrite_var__5 t7) t103))) + 1))) +(let t105 (substitution t100 t34 t103 (c (Const 3.0)))) +(let t106 (Add (Const 1.0) (Const 1.0))) +(let t107 (Pow (Var "x") t106)) +(let t108 (Add (Const -1.0) (Const 3.0))) +(let t109 (Pow (Var "x") t108)) +(let t110 (Mul t3 t0)) +(let t111 + (premises + (Rule + (= t4 t4) + (name "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t104 + t105))) +(let t112 + (premises + (Sym + (= t4 t110) + (Rule + (= t110 t4) + (name "(rewrite (Mul a b) (Mul b a))") + t111 + (substitution t34 (@rewrite_var__5 t4) t103))))) +(let t113 (@rewrite_var__17 t4)) +(let t114 (substitution t113 (a (Var "x")) (b (Const -1.0)) (c (Const 3.0)))) +(let t115 (Add (Const 3.0) (Const -1.0))) +(let t116 + (premises + (Rule + (= t115 t115) + (name "(rewrite (Mul (Pow a b) (Pow a c)) (Pow a (Add b c)))") + t111 + (substitution + t113 + (a (Var "x")) + (b (Const 3.0)) + (c (Const -1.0)))))) +(let t117 (Add t16 t16)) +(let t118 (Add t17 t17)) +(let prf21 + (Rule + (= (Const 2.0) t106) + (name "(rewrite (Add (Const a) (Const b)) (Const (+ a b)))") + (premises + (Rule + (= t106 t106) + (name "(rewrite (Add (Mul a b) (Mul a c)) (Mul a (Add b c)))") + (premises + (Congr + (= t117 (Add t68 t68)) + (Congr + (= t117 (Add t68 t16)) + (Rule + (= t117 t117) + (name + "(rewrite (Add (Mul a b) (Mul a c)) (Mul a (Add b c)))") + (premises + (Rule + (= t118 t118) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + (premises (Congr (= t1 (Add t17 t29)) prf4 prf4 1)) + (substitution t62 t46 t47 t61))) + (substitution (c t16) t34 (@rewrite_var__16 t118) t65)) + prf12 + 0) + prf12 + 1)) + (substitution + (c (Const 1.0)) + t71 + (@rewrite_var__16 t117) + (b (Const 1.0))))) + (substitution (a 1.0) (b 1.0) (@rewrite_var__ t106)))) +(Congr + (= t1 (Mul (Const 3.0) t2)) + (Trans + (= t1 t5) + (Trans + (= t1 t9) + (Trans + (= t1 t10) + (Sym + (= t1 t13) + (Rule (= t13 t1) (name "(rewrite (Add a b) (Add b a))") t86 t87)) + (Congr + (= t13 t10) + (Rule (= t13 t13) (name "(rewrite (Add a b) (Add b a))") t86 t87) + (Rule + (= t12 (Const 0.0)) + (name "(rewrite (Mul a (Const 0.0)) (Const 0.0))") + (premises + (Trans + (= t12 t88) + prf20 + (Congr + (= t89 t88) + (Rule + (= t89 t89) + (name "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + (premises + (Congr + (= t12 (Mul (Ln (Var "x")) t91)) + prf20 + (Sym + (= t11 t91) + (Rule + (= t91 t11) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + (premises + (Rule + (= t92 t92) + (name + "(rule ((= e (Diff x y))) + ((MathU e)) + )") + t85 + (substitution + (y (Const 3.0)) + (e t11) + (x (Var "x"))))) + (substitution t90))) + 1)) + (substitution (@rewrite_var__7 t12) t93 t81 (c (Const 1.0)))) + prf18 + 1))) + (substitution t93 (@rewrite_var__11 t12))) + 0)) + prf16) + (Sym + (= t9 t5) + (Rule + (= t5 t9) + (name "(rewrite (Mul a b) (Mul b a))") + (premises + (Sym + (= t9 t94) + (Rule + (= t94 t9) + (name "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t104 + t105))) + (substitution (a t4) (@rewrite_var__5 t9) (b (Const 3.0)))))) + (Congr + (= t4 t2) + (Trans + (= t4 t107) + (Sym + (= t4 t109) + (Rule + (= t109 t4) + (name "(rewrite (Mul (Pow a b) (Pow a c)) (Pow a (Add b c)))") + t112 + t114)) + (Congr + (= t109 t107) + (Rule + (= t109 t109) + (name "(rewrite (Mul (Pow a b) (Pow a c)) (Pow a (Add b c)))") + t112 + t114) + (Trans + (= t108 t106) + (Trans + (= t108 (Const 2.0)) + (Rule + (= t108 t115) + (name "(rewrite (Add a b) (Add b a))") + t116 + (substitution + (@rewrite_var__4 t115) + (a (Const 3.0)) + (b (Const -1.0)))) + (Rule + (= t115 (Const 2.0)) + (name "(rewrite (Add (Const a) (Const b)) (Const (+ a b)))") + t116 + (substitution (a 3.0) (b -1.0) (@rewrite_var__ t115)))) + prf21) + 1)) + (Sym (= t106 (Const 2.0)) prf21) + 1) + 1) +(let t0 (Pow (Var "x") (Const 3.0))) +(let t1 (Pow (Var "x") (Const 2.0))) +(let t2 (Mul (Const 7.0) t1)) +(let t3 (Sub t0 t2)) +(let t4 (Diff (Var "x") t3)) +(let t5 (Mul (Const 3.0) (Var "x"))) +(let t6 (Sub t5 (Const 14.0))) +(let t7 (Mul (Var "x") t6)) +(let t8 (Mul (Var "x") t5)) +(let t9 (Mul (Const -1.0) (Const 14.0))) +(let t10 (Mul (Var "x") t9)) +(let t11 (Add t8 t10)) +(let t12 (Diff (Var "x") t0)) +(let t13 (Mul (Const -1.0) t2)) +(let t14 (Diff (Var "x") t13)) +(let t15 (Add t12 t14)) +(let t16 (Add t0 t13)) +(let prf0 (Fiat (= t4 t4))) +(let t17 (premises (Fiat (= t3 t3)))) +(let t18 (a t0)) +(let t19 (b t2)) +(let t20 (substitution t18 t19 (@rewrite_var__8 t3))) +(let prf1 + (Sym + (= t3 t16) + (Rule + (= t16 t3) + (name "(rewrite (Sub a b) (Add a (Mul (Const -1.0) b)))") + t17 + t20))) +(let t21 (premises (Congr (= t4 (Diff (Var "x") t16)) prf0 prf1 1))) +(let t22 (b t13)) +(let t23 (substitution t22 t18 (@rewrite_var__25 t4) (x (Var "x")))) +(let prf2 + (Sym + (= t4 t15) + (Rule + (= t15 t4) + (name "(rewrite (Diff x (Add a b)) (Add (Diff x a) (Diff x b)))") + t21 + t23))) +(let t24 (Mul (Const -1.0) (Const 7.0))) +(let t25 (Add t24 t24)) +(let t26 (Mul (Var "x") t25)) +(let t27 (Diff (Var "x") t1)) +(let t28 (Mul t24 t27)) +(let t29 (Add (Const 0.0) t28)) +(let t30 (Diff (Var "x") t24)) +(let t31 (Mul t1 t30)) +(let t32 (Add t31 t28)) +(let t33 (Add t28 t31)) +(let t34 (Mul t24 t1)) +(let prf3 + (Rule + (= t14 t14) + (name + "(rewrite (Diff x (Add a b)) (Add (Diff x a) (Diff x b)))") + t21 + t23)) +(let prf4 + (Rule + (= t13 t13) + (name + "(rewrite (Sub a b) (Add a (Mul (Const -1.0) b)))") + t17 + t20)) +(let t35 (premises prf4)) +(let t36 (@rewrite_var__7 t13)) +(let t37 + (substitution + t36 + (a (Const -1.0)) + (b (Const 7.0)) + (c t1))) +(let prf5 + (Rule + (= t34 t13) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t35 + t37)) +(let prf6 (Sym (= t13 t34) prf5)) +(let t38 + (premises + (Congr (= t14 (Diff (Var "x") t34)) prf3 prf6 1))) +(let t39 (@rewrite_var__26 t14)) +(let t40 (a t24)) +(let t41 (b t1)) +(let t42 (substitution t39 t40 (x (Var "x")) t41)) +(let t43 (@rewrite_var__4 t14)) +(let t44 (a t28)) +(let t45 (b t31)) +(let prf7 + (Sym + (= t14 t32) + (Rule + (= t32 t14) + (name "(rewrite (Add a b) (Add b a))") + (premises + (Sym + (= t14 t33) + (Rule + (= t33 t14) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t38 + t42))) + (substitution t43 t44 t45)))) +(let t46 (Mul (Const 0.0) (Var "x"))) +(let t47 (Diff (Var "x") (Const 7.0))) +(let t48 (Mul t1 t47)) +(let t49 (Mul t1 (Const 0.0))) +(let t50 (Mul (Const 1.0) t1)) +(let t51 (Mul t50 t30)) +(let t52 (Mul (Const 1.0) t31)) +(let t53 (Mul t31 (Const 1.0))) +(let t54 (Mul t30 t1)) +(let t55 (Mul t54 (Const 1.0))) +(let t56 (Mul t1 (Const 1.0))) +(let t57 (a t1)) +(let t58 (@rewrite_var__5 t31)) +(let prf8 + (Rule + (= t54 t31) + (name + "(rewrite (Mul a b) (Mul b a))") + (premises + (Rule + (= t31 t31) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t38 + t42)) + (substitution t57 t58 (b t30)))) +(let prf9 (Sym (= t31 t54) prf8)) +(let t59 (MathU t1)) +(let t60 (premises (Fiat (= t1 t1)))) +(let t61 + (premises + (Rule + (= t59 t59) + (name + "(rule ((= e (Pow x y))) + ((MathU e)) + )") + t60 + (substitution + (y (Const 2.0)) + (e t1) + (x (Var "x")))))) +(let t62 (substitution t57)) +(let prf10 + (Sym + (= t1 t56) + (Rule + (= t56 t1) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + t61 + t62))) +(let t63 + (premises + (Congr (= t31 (Mul t30 t56)) prf9 prf10 1))) +(let t64 (@rewrite_var__7 t31)) +(let t65 (a t30)) +(let t66 (substitution t64 t65 t41 (c (Const 1.0)))) +(let t67 (a t31)) +(let t68 (Mul (Const 1.0) t14)) +(let t69 (Add t14 t12)) +(let t70 (Mul (Const 1.0) t4)) +(let t71 (Mul t4 (Const 1.0))) +(let t72 (MathU t4)) +(let t73 + (premises + (Rule + (= t72 t72) + (name + "(rule ((= e (Diff x y))) + ((MathU e)) + )") + (premises prf0) + (substitution + (y t3) + (e t4) + (x (Var "x")))))) +(let t74 (a t4)) +(let t75 (substitution t74)) +(let prf11 + (Rule + (= t70 t4) + (name + "(rewrite (Mul a b) (Mul b a))") + (premises + (Sym + (= t4 t71) + (Rule + (= t71 t4) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + t73 + t75))) + (substitution + t74 + (@rewrite_var__5 t4) + (b (Const 1.0))))) +(let prf12 (Sym (= t4 t70) prf11)) +(let t76 (@rewrite_var__4 t4)) +(let t77 (a t12)) +(let t78 (b t14)) +(let prf13 + (Sym + (= t4 t69) + (Rule + (= t69 t4) + (name + "(rewrite (Add a b) (Add b a))") + (premises prf2) + (substitution t76 t77 t78)))) +(let t79 (@rewrite_var__15 t4)) +(let t80 + (premises + (Rule + (= t52 t52) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + (premises + (Congr + (= t68 (Mul (Const 1.0) t32)) + (Rule + (= t68 t68) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + (premises + (Congr + (= t4 (Mul (Const 1.0) t69)) + prf12 + prf13 + 1)) + (substitution + (a (Const 1.0)) + t79 + t78 + (c t12))) + prf7 + 1)) + (substitution + (a (Const 1.0)) + (@rewrite_var__15 t68) + t45 + (c t28))))) +(let t81 + (substitution + (@rewrite_var__7 t52) + (a (Const 1.0)) + t41 + (c t30))) +(let prf14 + (Rule + (= t50 t1) + (name "(rewrite (Mul a b) (Mul b a))") + (premises prf10) + (substitution + t57 + (@rewrite_var__5 t1) + (b (Const 1.0))))) +(let prf15 + (Rule + (= t30 t30) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t38 + t42)) +(let t82 (is-const-or-distinct-var (Const -7.0) "x")) +(let t83 (is-const-or-distinct-var-demand t24 "x")) +(let t84 (c t24)) +(let t85 + (premises + (Rule + (= t24 t24) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t35 + t37))) +(let prf16 + (Rule + (= (Const -7.0) t24) + (name + "(rewrite (Mul (Const a) (Const b)) (Const (* a b)))") + t85 + (substitution + (@rewrite_var__2 t24) + (a -1.0) + (b 7.0)))) +(let prf17 (Sym (= t24 (Const -7.0)) prf16)) +(let prf18 + (Rule + (= t30 (Const 0.0)) + (name + "(rewrite (Diff (Var x) c) (Const 0.0) :when ((is-const-or-distinct-var c x)))") + (premises + prf15 + (Congr + (= t82 (is-const-or-distinct-var t24 "x")) + (Rule + (= t82 t82) + (name + "(rule ((is-const-or-distinct-var-demand (Const c) v)) + ((is-const-or-distinct-var (Const c) v)) + )") + (premises + (Congr + (= + t83 + (is-const-or-distinct-var-demand + (Const -7.0) + "x")) + (Rule + (= t83 t83) + (name + "(rule ((Diff (Var x) c)) + ((is-const-or-distinct-var-demand c x)) + )") + (premises prf15) + (substitution (x "x") t84)) + prf17 + 0)) + (substitution (v "x") (c -7.0))) + prf16 + 0)) + (substitution t84 (@rewrite_var__24 t30) (x "x")))) +(let t86 (Mul t50 t47)) +(let prop0 (= t86 t48)) +(let t87 (Mul (Const 1.0) t48)) +(let t88 (Diff (Var "x") t2)) +(let t89 (Mul (Const 1.0) t88)) +(let t90 (Mul (Const 7.0) t27)) +(let t91 (Add t48 t90)) +(let t92 (Mul (Const 1.0) t2)) +(let t93 (Mul t2 (Const -1.0))) +(let t94 (a t2)) +(let prf19 + (Rule + (= t88 t88) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + (premises + (Congr + (= t14 (Diff (Var "x") t93)) + prf3 + (Sym + (= t13 t93) + (Rule + (= t93 t13) + (name + "(rewrite (Mul a b) (Mul b a))") + t35 + (substitution + (a (Const -1.0)) + (@rewrite_var__5 t13) + t19))) + 1)) + (substitution + t39 + t94 + (x (Var "x")) + (b (Const -1.0))))) +(let t95 (Mul t2 (Const 1.0))) +(let t96 (MathU t2)) +(let prf20 (Fiat (= t2 t2))) +(let t97 (premises prf20)) +(let t98 + (premises + (Rule + (= t96 t96) + (name + "(rule ((= e (Mul x y))) + ((MathU e)) + )") + t97 + (substitution + (y t1) + (e t2) + (x (Const 7.0)))))) +(let t99 (substitution t94)) +(let t100 (@rewrite_var__5 t2)) +(let prf21 + (Sym + (= t2 t92) + (Rule + (= t92 t2) + (name + "(rewrite (Mul a b) (Mul b a))") + (premises + (Sym + (= t2 t95) + (Rule + (= t95 t2) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + t98 + t99))) + (substitution + t94 + t100 + (b (Const 1.0)))))) +(let t101 (@rewrite_var__26 t88)) +(let t102 (Mul t1 (Const 7.0))) +(let prf22 + (Sym + (= t2 t102) + (Rule + (= t102 t2) + (name + "(rewrite (Mul a b) (Mul b a))") + t97 + (substitution + (a (Const 7.0)) + t100 + t41)))) +(let t103 + (premises + (Congr + (= t88 (Diff (Var "x") t102)) + prf19 + prf22 + 1))) +(let t104 + (substitution + t101 + t57 + (x (Var "x")) + (b (Const 7.0)))) +(let t105 (b t48)) +(let t106 + (premises + (Rule + (= t87 t87) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + (premises + (Congr + (= t89 (Mul (Const 1.0) t91)) + (Rule + (= t89 t89) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + (premises + (Congr + (= t88 (Diff (Var "x") t92)) + prf19 + prf21 + 1)) + (substitution + t101 + (a (Const 1.0)) + (x (Var "x")) + t19)) + (Sym + (= t88 t91) + (Rule + (= t91 t88) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t103 + t104)) + 1)) + (substitution + (a (Const 1.0)) + (@rewrite_var__15 t89) + t105 + (c t90))))) +(let t107 + (substitution + (@rewrite_var__7 t87) + (a (Const 1.0)) + t41 + (c t47))) +(let t108 (Mul (Const -1.0) t1)) +(let t109 (Mul t108 (Const 7.0))) +(let t110 + (premises + (Congr + (= t13 (Mul (Const -1.0) t102)) + prf4 + prf22 + 1))) +(let t111 + (substitution + t36 + (a (Const -1.0)) + t41 + (c (Const 7.0)))) +(let t112 + (premises + (Congr + (= t14 (Diff (Var "x") t109)) + prf3 + (Sym + (= t13 t109) + (Rule + (= t109 t13) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t110 + t111)) + 1))) +(let t113 (a t108)) +(let t114 + (substitution + t39 + t113 + (x (Var "x")) + (b (Const 7.0)))) +(let prf23 + (Rule + (= t47 t47) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t112 + t114)) +(let t115 (is-const-or-distinct-var (Const 7.0) "x")) +(let t116 + (is-const-or-distinct-var-demand + (Const 7.0) + "x")) +(let t117 (premises prf23)) +(let prf24 + (Rule + (= t47 (Const 0.0)) + (name + "(rewrite (Diff (Var x) c) (Const 0.0) :when ((is-const-or-distinct-var c x)))") + (premises + prf23 + (Rule + (= t115 t115) + (name + "(rule ((is-const-or-distinct-var-demand (Const c) v)) + ((is-const-or-distinct-var (Const c) v)) + )") + (premises + (Rule + (= t116 t116) + (name + "(rule ((Diff (Var x) c)) + ((is-const-or-distinct-var-demand c x)) + )") + t117 + (substitution (x "x") (c (Const 7.0))))) + (substitution (v "x") (c 7.0)))) + (substitution + (c (Const 7.0)) + (@rewrite_var__24 t47) + (x "x")))) +(let t118 (Mul t48 (Const 1.0))) +(let t119 (Mul t47 (Const 1.0))) +(let prf25 + (Rule + (= t48 t48) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t103 + t104)) +(let t120 (MathU t47)) +(let t121 (a t47)) +(let t122 (@rewrite_var__7 t48)) +(let t123 (b t47)) +(let t124 (Mul t47 (Var "x"))) +(let t125 (Mul t124 (Var "x"))) +(let t126 (Mul (Var "x") (Var "x"))) +(let t127 (Mul t47 t1)) +(let prf26 + (Rule + (= t126 t1) + (name "(rewrite (Pow x (Const 2.0)) (Mul x x))") + t60 + (substitution + (@rewrite_var__20 t1) + (x (Var "x"))))) +(let prf27 (Sym (= t1 t126) prf26)) +(let t128 (Mul (Var "x") (Const 0.0))) +(let t129 (Mul (Var "x") t47)) +(let t130 (Mul t108 t47)) +(let t131 (Mul (Const -1.0) (Var "x"))) +(let t132 (Mul (Var "x") t131)) +(let t133 (Mul t47 t108)) +(let t134 (Mul t131 (Var "x"))) +(let t135 (Mul (Const 7.0) (Var "x"))) +(let t136 (Diff (Var "x") t135)) +(let t137 (Mul (Var "x") (Const 7.0))) +(let t138 (Mul (Var "x") t135)) +(let t139 (Mul t135 (Var "x"))) +(let t140 + (premises + (Congr + (= + t2 + (Mul (Const 7.0) t126)) + prf20 + prf27 + 1))) +(let t141 + (substitution + (@rewrite_var__7 t2) + (a (Const 7.0)) + (b (Var "x")) + (c (Var "x")))) +(let prf28 + (Sym + (= t2 t139) + (Rule + (= t139 t2) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t140 + t141))) +(let t142 (b t135)) +(let prf29 + (Rule + (= t135 t135) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t140 + t141)) +(let t143 (Add (Var "x") (Const 0.0))) +(let prf30 + (Rule + (= (MathU (Var "x")) (MathU (Var "x"))) + (name + "(rule ((= e (Var x))) + ((MathU e)) + )") + (premises + (Fiat (= (Var "x") (Var "x")))) + (substitution (e (Var "x")) (x "x")))) +(let t144 (premises prf30)) +(let t145 (substitution (a (Var "x")))) +(let prf31 + (Sym + (= (Var "x") t143) + (Rule + (= t143 (Var "x")) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + t144 + t145))) +(let t146 + (premises + (Rule + (= t128 t128) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + (premises + (Congr (= t1 (Mul (Var "x") t143)) prf27 prf31 1)) + (substitution + (a (Var "x")) + (@rewrite_var__15 t1) + (b (Var "x")) + (c (Const 0.0)))))) +(let prf32 + (Rule + (= t128 (Const 0.0)) + (name "(rewrite (Mul a (Const 0.0)) (Const 0.0))") + t146 + (substitution (a (Var "x")) (@rewrite_var__11 t128)))) +(let prf33 + (Trans + (= t46 (Const 0.0)) + (Rule + (= t46 t128) + (name "(rewrite (Mul a b) (Mul b a))") + t146 + (substitution + (a (Var "x")) + (@rewrite_var__5 t128) + (b (Const 0.0)))) + prf32)) +(let prf34 + (Trans + (= t31 (Const 0.0)) + (Trans + (= t31 t46) + (Trans + (= t31 t48) + (Trans + (= t31 t49) + (Trans + (= t31 t51) + (Sym + (= t31 t52) + (Rule + (= t52 t31) + (name "(rewrite (Mul a b) (Mul b a))") + (premises + (Trans + (= t31 t53) + (Sym + (= t31 t55) + (Rule + (= t55 t31) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t63 + t66)) + (Congr + (= t55 t53) + (Rule + (= t55 t55) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t63 + t66) + prf8 + 0))) + (substitution t67 t58 (b (Const 1.0))))) + (Sym + (= t52 t51) + (Rule + (= t51 t52) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t80 + t81))) + (Congr + (= t51 t49) + (Congr + (= t51 t31) + (Rule + (= t51 t51) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t80 + t81) + prf14 + 0) + prf18 + 1)) + (Trans + (= t49 t48) + (Sym + (= t49 t86) + (Congr + (= t86 t49) + (Congr + prop0 + (Rule + (= t86 t86) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t106 + t107) + prf14 + 0) + prf24 + 1)) + (Trans + prop0 + (Rule + (= t86 t87) + (name "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t106 + t107) + (Trans + (= t87 t48) + (Sym + (= t87 t118) + (Rule + (= t118 t87) + (name "(rewrite (Mul a b) (Mul b a))") + t106 + (substitution + (a (Const 1.0)) + (@rewrite_var__5 t87) + t105))) + (Rule + (= t118 t48) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + (premises + (Congr + (= t48 (Mul t1 t119)) + prf25 + (Sym + (= t47 t119) + (Rule + (= t119 t47) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + (premises + (Rule + (= t120 t120) + (name + "(rule ((= e (Diff x y))) + ((MathU e)) + )") + t117 + (substitution + (y (Const 7.0)) + (e t47) + (x (Var "x"))))) + (substitution t121))) + 1)) + (substitution t122 t57 t123 (c (Const 1.0)))))))) + (Congr + (= t48 t46) + (Sym + (= t48 t125) + (Rule + (= t125 t48) + (name "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + (premises + (Congr + (= t48 (Mul t47 t126)) + (Sym + (= t48 t127) + (Rule + (= t127 t48) + (name "(rewrite (Mul a b) (Mul b a))") + (premises prf25) + (substitution t57 (@rewrite_var__5 t48) t123))) + prf27 + 1)) + (substitution t122 t121 (b (Var "x")) (c (Var "x"))))) + (Trans + (= t124 (Const 0.0)) + (Trans + (= t124 t128) + (Sym + (= t124 t129) + (Rule + (= t129 t124) + (name "(rewrite (Mul a b) (Mul b a))") + (premises + (Rule + (= t124 t124) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + (premises + (Congr + (= t130 (Mul t47 t132)) + (Sym + (= t130 t133) + (Rule + (= t133 t130) + (name "(rewrite (Mul a b) (Mul b a))") + (premises + (Rule + (= t130 t130) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t112 + t114)) + (substitution + t113 + (@rewrite_var__5 t130) + t123))) + (Sym + (= t108 t132) + (Rule + (= t132 t108) + (name "(rewrite (Mul a b) (Mul b a))") + (premises + (Sym + (= t108 t134) + (Rule + (= t134 t108) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + (premises + (Congr + (= + t108 + (Mul (Const -1.0) t126)) + (Rule + (= t108 t108) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t110 + t111) + prf27 + 1)) + (substitution + (@rewrite_var__7 t108) + (a (Const -1.0)) + (b (Var "x")) + (c (Var "x")))))) + (substitution + (a t131) + (@rewrite_var__5 t108) + (b (Var "x"))))) + 1)) + (substitution + (@rewrite_var__7 t130) + t121 + (b (Var "x")) + (c t131)))) + (substitution + t121 + (@rewrite_var__5 t124) + (b (Var "x"))))) + (Congr + (= t129 t128) + (Rule + (= t129 t129) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + (premises + (Congr + (= t136 (Diff (Var "x") t137)) + (Rule + (= t136 t136) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + (premises + (Congr + (= t88 (Diff (Var "x") t138)) + prf19 + (Sym + (= t2 t138) + (Rule + (= t138 t2) + (name "(rewrite (Mul a b) (Mul b a))") + (premises prf28) + (substitution + (a t135) + t100 + (b (Var "x"))))) + 1)) + (substitution + t101 + (a (Var "x")) + (x (Var "x")) + t142)) + (Sym + (= t135 t137) + (Rule + (= t137 t135) + (name "(rewrite (Mul a b) (Mul b a))") + (premises prf29) + (substitution + (a (Const 7.0)) + (@rewrite_var__5 t135) + (b (Var "x"))))) + 1)) + (substitution + (@rewrite_var__26 t136) + (a (Var "x")) + (x (Var "x")) + (b (Const 7.0)))) + prf24 + 1)) + prf32) + 0)) + prf33)) +(let t147 (Add t28 (Const 0.0))) +(let t148 (MathU t28)) +(let prf35 + (Rule + (= t28 t28) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t38 + t42)) +(let t149 (Mul (Var "x") t24)) +(let t150 (Add t149 t149)) +(let t151 (Mul (Const -1.0) t135)) +(let t152 (Add t149 t151)) +(let t153 (Add t151 t151)) +(let t154 (Diff (Var "x") (Var "x"))) +(let t155 (Mul (Var "x") t154)) +(let t156 (Mul t24 t155)) +(let t157 (Add t156 t156)) +(let t158 (Add t155 t155)) +(let prf36 + (Rule + (= t27 t27) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t38 + t42)) +(let t159 + (premises + (Congr + (= t27 (Diff (Var "x") t126)) + prf36 + prf27 + 1))) +(let t160 + (substitution + (@rewrite_var__26 t27) + (a (Var "x")) + (x (Var "x")) + (b (Var "x")))) +(let t161 + (premises + (Congr + (= t28 (Mul t24 t158)) + prf35 + (Sym + (= t27 t158) + (Rule + (= t158 t27) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t159 + t160)) + 1))) +(let t162 + (substitution + t40 + (@rewrite_var__15 t28) + (b t155) + (c t155))) +(let t163 (Mul t24 (Var "x"))) +(let t164 (Mul (Var "x") (Const 1.0))) +(let t165 (Mul t151 (Var "x"))) +(let t166 + (premises + (Congr + (= + t13 + (Mul (Const -1.0) t139)) + prf4 + prf28 + 1))) +(let t167 + (substitution + t36 + (a (Const -1.0)) + t142 + (c (Var "x")))) +(let prf37 + (Sym + (= t13 t165) + (Rule + (= t165 t13) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t166 + t167))) +(let t168 + (premises + (Congr + (= t14 (Diff (Var "x") t165)) + prf3 + prf37 + 1))) +(let t169 (a t151)) +(let t170 + (substitution + t39 + t169 + (x (Var "x")) + (b (Var "x")))) +(let prf38 + (Rule + (= t154 (Const 1.0)) + (name + "(rewrite (Diff (Var x) (Var x)) (Const 1.0))") + (premises + (Rule + (= t154 t154) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t168 + t170)) + (substitution (@rewrite_var__23 t154) (x "x")))) +(let prf39 + (Rule + (= t164 (Var "x")) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + t144 + t145)) +(let prop1 (= t163 t151)) +(let t171 (Mul t24 (Const 1.0))) +(let t172 (Mul t171 (Var "x"))) +(let prop2 (= t163 t172)) +(let prop3 (= t172 t163)) +(let t173 (Mul (Const 1.0) (Var "x"))) +(let prf40 + (Rule + (= t163 t163) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + (premises + (Congr + (= t13 (Mul t24 t126)) + prf6 + prf27 + 1)) + (substitution + t36 + t40 + (b (Var "x")) + (c (Var "x"))))) +(let prf41 (Sym (= (Var "x") t164) prf39)) +(let t174 + (premises + (Congr + (= t163 (Mul t24 t173)) + prf40 + (Sym + (= (Var "x") t173) + (Rule + (= t173 (Var "x")) + (name "(rewrite (Mul a b) (Mul b a))") + (premises prf41) + (substitution + (a (Var "x")) + (@rewrite_var__5 (Var "x")) + (b (Const 1.0))))) + 1))) +(let t175 + (substitution + (@rewrite_var__7 t163) + t40 + (b (Const 1.0)) + (c (Var "x")))) +(let t176 (MathU t24)) +(let t177 + (premises + (Rule + (= t176 t176) + (name + "(rule ((= e (Mul x y))) + ((MathU e)) + )") + t85 + (substitution + (y (Const 7.0)) + (e t24) + (x (Const -1.0)))))) +(let t178 (substitution t40)) +(let prf42 + (Rule + (= t171 t24) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + t177 + t178)) +(let prf43 + (Congr + prop3 + (Rule + (= t172 t172) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t174 + t175) + prf42 + 0)) +(let prf44 + (Rule + prop3 + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t174 + t175)) +(let prf45 + (Rule + (= t151 t151) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t166 + t167)) +(let t179 (@rewrite_var__7 t151)) +(let prf46 + (Rule + prop1 + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + (premises prf45) + (substitution + t179 + (a (Const -1.0)) + (b (Const 7.0)) + (c (Var "x"))))) +(let prf47 + (Trans + (= t156 t151) + (Congr + (= t156 t163) + (Rule + (= t156 t156) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t161 + t162) + (Trans + (= t155 (Var "x")) + (Congr + (= t155 t164) + (Rule + (= t155 t155) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t159 + t160) + prf38 + 1) + prf39) + 1) + (Trans + prop1 + (Sym prop2 prf43) + (Trans (= t172 t151) prf44 prf46)))) +(let prf48 + (Congr + (= t28 t153) + (Congr + (= t28 (Add t151 t156)) + (Sym + (= t28 t157) + (Rule + (= t157 t28) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t161 + t162)) + prf47 + 0) + prf47 + 1)) +(let prop4 (= t151 t163)) +(let prf49 (Sym prop4 prf46)) +(let prf50 + (Rule + (= t149 t163) + (name "(rewrite (Mul a b) (Mul b a))") + (premises prf40) + (substitution + t40 + (@rewrite_var__5 t163) + (b (Var "x"))))) +(let prf51 (Trans (= t151 t149) prf49 (Sym (= t163 t149) prf50))) +(let t180 (b t24)) +(let t181 (Diff (Var "x") t151)) +(let t182 (Mul (Var "x") t181)) +(let t183 (Mul t151 t154)) +(let t184 (Add t182 t183)) +(let t185 (Add t183 t182)) +(let t186 (Mul (Const 1.0) t151)) +(let t187 (Mul t154 t151)) +(let t188 + (premises + (Rule + (= t183 t183) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t168 + t170))) +(let t189 + (substitution + t169 + (@rewrite_var__5 t183) + (b t154))) +(let t190 (Mul t151 (Const 1.0))) +(let t191 (Mul t135 (Const 1.0))) +(let prf52 + (Sym + (= t151 t190) + (Rule + (= t190 t151) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + (premises + (Congr + (= t151 (Mul (Const -1.0) t191)) + prf45 + (Sym + (= t135 t191) + (Rule + (= t191 t135) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + (premises + (Congr + (= t135 (Mul (Const 7.0) t164)) + prf29 + prf41 + 1)) + (substitution + (@rewrite_var__7 t135) + (a (Const 7.0)) + (b (Var "x")) + (c (Const 1.0))))) + 1)) + (substitution + t179 + (a (Const -1.0)) + t142 + (c (Const 1.0)))))) +(let prf53 + (Congr + (= t14 (Add t182 t151)) + (Sym + (= t14 t184) + (Rule + (= t184 t14) + (name "(rewrite (Add a b) (Add b a))") + (premises + (Sym + (= t14 t185) + (Rule + (= t185 t14) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t168 + t170))) + (substitution t43 (a t183) (b t182)))) + (Trans + (= t183 t151) + (Trans + (= t183 t186) + (Sym + (= t183 t187) + (Rule + (= t187 t183) + (name "(rewrite (Mul a b) (Mul b a))") + t188 + t189)) + (Congr + (= t187 t186) + (Rule + (= t187 t187) + (name "(rewrite (Mul a b) (Mul b a))") + t188 + t189) + prf38 + 0)) + (Rule + (= t186 t151) + (name "(rewrite (Mul a b) (Mul b a))") + (premises prf52) + (substitution + t169 + (@rewrite_var__5 t151) + (b (Const 1.0))))) + 1)) +(let t192 (Add (Const 0.0) t151)) +(let t193 (Add t31 t151)) +(let t194 (Mul (Var "x") t30)) +(let t195 (Mul (Var "x") t194)) +(let t196 (Add t195 t151)) +(let t197 (Add t195 t149)) +(let t198 (Add t194 t24)) +(let t199 (Mul t24 t154)) +(let t200 (Add t194 t199)) +(let prf54 + (Rule + (= t181 t181) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t168 + t170)) +(let t201 + (premises + (Congr + (= t181 (Diff (Var "x") t149)) + prf54 + prf51 + 1))) +(let t202 (@rewrite_var__26 t181)) +(let t203 + (substitution + t202 + (a (Var "x")) + (x (Var "x")) + t180)) +(let prf55 + (Congr + (= t181 t198) + (Sym + (= t181 t200) + (Rule + (= t200 t181) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t201 + t203)) + (Trans + (= t199 t24) + (Congr + (= t199 t171) + (Rule + (= t199 t199) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + (premises + (Congr + (= t181 (Diff (Var "x") t163)) + prf54 + (Trans + prop4 + (Trans + (= t151 t172) + prf49 + (Sym prop2 prf44)) + prf43) + 1)) + (substitution + t202 + t40 + (x (Var "x")) + (b (Var "x")))) + prf38 + 1) + prf42) + 1)) +(let t204 + (premises + (Congr + (= t182 (Mul (Var "x") t198)) + (Rule + (= t182 t182) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t168 + t170) + prf55 + 1))) +(let t205 + (substitution + (a (Var "x")) + (@rewrite_var__15 t182) + (b t194) + t84)) +(let t206 (Mul t30 (Var "x"))) +(let t207 (Mul (Var "x") t206)) +(let t208 + (premises + (Congr + (= t31 (Mul t30 t126)) + prf9 + prf27 + 1))) +(let t209 + (substitution + t64 + t65 + (b (Var "x")) + (c (Var "x")))) +(let prf56 + (Rule + (= t194 t206) + (name "(rewrite (Mul a b) (Mul b a))") + (premises + (Rule + (= t206 t206) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t208 + t209)) + (substitution + t65 + (@rewrite_var__5 t206) + (b (Var "x"))))) +(let t210 (Mul t206 (Var "x"))) +(let t211 (b t151)) +(let t212 (Mul t24 (Const 0.0))) +(let t213 (Add t212 t163)) +(let t214 (Add (Const 0.0) (Var "x"))) +(let prf57 + (Sym + (= (Var "x") t214) + (Rule + (= t214 (Var "x")) + (name "(rewrite (Add a b) (Add b a))") + (premises prf31) + (substitution + (@rewrite_var__4 (Var "x")) + (a (Var "x")) + (b (Const 0.0)))))) +(let t215 + (premises + (Congr (= t163 (Mul t24 t214)) prf40 prf57 1))) +(let t216 + (substitution + t40 + (@rewrite_var__15 t163) + (b (Const 0.0)) + (c (Var "x")))) +(let t217 (Add t1 (Const 0.0))) +(let t218 (@rewrite_var__15 t13)) +(let t219 (@rewrite_var__16 t14)) +(let t220 (Add t181 t24)) +(let t221 (Add t24 (Const 0.0))) +(let t222 (Add t24 t206)) +(let t223 (Add t24 t194)) +(let t224 (premises prf55)) +(let t225 (substitution (@rewrite_var__4 t181) (a t194) t180)) +(let prf58 + (Congr + (= t220 t25) + (Rule + (= t220 t220) + (name + "(rewrite (Add (Mul a b) (Mul a c)) (Mul a (Add b c)))") + (premises (Congr (= t14 (Add t182 t149)) prf53 prf51 1)) + (substitution t84 (a (Var "x")) t219 (b t181))) + (Trans + (= t181 t24) + (Congr + (= t181 t221) + (Trans + (= t181 t222) + (Sym + (= t181 t223) + (Rule + (= t223 t181) + (name "(rewrite (Add a b) (Add b a))") + t224 + t225)) + (Congr + (= t223 t222) + (Rule + (= t223 t223) + (name "(rewrite (Add a b) (Add b a))") + t224 + t225) + prf56 + 1)) + (Trans + (= t206 (Const 0.0)) + (Trans + (= t206 t128) + (Sym (= t206 t194) prf56) + (Congr + (= t194 t128) + (Rule + (= t194 t194) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t201 + t203) + prf18 + 1)) + prf32) + 1) + (Rule + (= t221 t24) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + t177 + t178)) + 0)) +(let t226 (premises (Fiat (= t6 t6)))) +(let t227 (substitution (a t5) (b (Const 14.0)) (@rewrite_var__8 t6))) +(let prf59 + (Trans + (= t14 t10) + (Trans + (= t14 t26) + (Trans + (= t14 t28) + (Congr (= t14 t29) prf7 prf34 0) + (Rule + (= t29 t28) + (name "(rewrite (Add a b) (Add b a))") + (premises + (Sym + (= t28 t147) + (Rule + (= t147 t28) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + (premises + (Rule + (= t148 t148) + (name + "(rule ((= e (Mul x y))) + ((MathU e)) + )") + (premises prf35) + (substitution (y t27) (e t28) (x t24)))) + (substitution t44)))) + (substitution (@rewrite_var__4 t28) t44 (b (Const 0.0))))) + (Sym + (= t28 t26) + (Rule + (= t26 t28) + (name "(rewrite (Add (Mul a b) (Mul a c)) (Mul a (Add b c)))") + (premises + (Congr (= t28 t150) (Congr (= t28 t152) prf48 prf51 0) prf51 1)) + (substitution t84 (a (Var "x")) (@rewrite_var__16 t28) t180)))) + (Congr + (= t26 t10) + (Rule + (= t26 t26) + (name "(rewrite (Add (Mul a b) (Mul a c)) (Mul a (Add b c)))") + (premises + (Congr + (= t14 t150) + (Congr + (= t14 t152) + (Congr + (= t14 t153) + prf53 + (Trans + (= t182 t151) + (Trans + (= t182 t192) + (Congr + (= t182 t193) + (Trans + (= t182 t196) + (Sym + (= t182 t197) + (Rule + (= t197 t182) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t204 + t205)) + (Congr + (= t197 t196) + (Rule + (= t197 t197) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t204 + t205) + (Trans (= t149 t151) prf50 prf46) + 1)) + (Trans + (= t195 t31) + (Congr + (= t195 t207) + (Rule + (= t195 t195) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t204 + t205) + prf56 + 1) + (Rule + (= t207 t31) + (name "(rewrite (Mul a b) (Mul b a))") + (premises + (Sym + (= t31 t210) + (Rule + (= t210 t31) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t208 + t209))) + (substitution (a t206) t58 (b (Var "x"))))) + 0) + (Congr + (= t193 t192) + (Rule + (= t193 t193) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + (premises + (Congr (= t14 (Add t31 t153)) prf7 prf48 1)) + (substitution + (c t151) + t67 + (@rewrite_var__6 t14) + t211)) + prf34 + 0)) + (Trans + (= t192 t151) + (Sym + (= t192 t213) + (Congr + (= t213 t192) + (Congr + (= t213 (Add (Const 0.0) t163)) + (Rule + (= t213 t213) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t215 + t216) + (Rule + (= t212 (Const 0.0)) + (name + "(rewrite (Mul (Const a) (Const b)) (Const (* a b)))") + (premises + (Congr + (= t212 (Mul (Const -7.0) (Const 0.0))) + (Rule + (= t212 t212) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + (premises + (Congr + (= t13 (Mul t24 t217)) + prf6 + (Sym + (= t1 t217) + (Rule + (= t217 t1) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + t61 + t62)) + 1)) + (substitution + t40 + t218 + t41 + (c (Const 0.0)))) + prf17 + 0)) + (substitution + (@rewrite_var__2 t212) + (a -7.0) + (b 0.0))) + 0) + prf46 + 1)) + (Trans + (= t213 t151) + (Rule + (= t213 t163) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t215 + t216) + prf46))) + 0) + prf51 + 0) + prf51 + 1)) + (substitution t84 (a (Var "x")) t219 t180)) + (Trans + (= t25 t9) + (Trans + (= t25 (Const -14.0)) + (Sym (= t25 t220) prf58) + (Rule + (= t220 (Const -14.0)) + (name "(rewrite (Add (Const a) (Const b)) (Const (+ a b)))") + (premises + (Congr + (= t220 (Add (Const -7.0) (Const -7.0))) + (Congr (= t220 (Add (Const -7.0) t24)) prf58 prf17 0) + prf17 + 1)) + (substitution (a -7.0) (b -7.0) (@rewrite_var__ t220)))) + (Rule + (= (Const -14.0) t9) + (name "(rewrite (Mul (Const a) (Const b)) (Const (* a b)))") + (premises + (Rule + (= t9 t9) + (name "(rewrite (Sub a b) (Add a (Mul (Const -1.0) b)))") + t226 + t227)) + (substitution (@rewrite_var__2 t9) (a -1.0) (b 14.0)))) + 1))) +(let t228 (Mul t1 (Const 3.0))) +(let t229 (Pow (Var "x") (Const -1.0))) +(let t230 (Mul t0 t229)) +(let t231 (Mul t230 (Const 3.0))) +(let t232 (Div (Const 3.0) (Var "x"))) +(let t233 (Mul t154 t232)) +(let t234 (Mul t0 t233)) +(let t235 (Add (Const 0.0) t234)) +(let t236 (Diff (Var "x") (Const 2.0))) +(let t237 (Mul t236 (Ln (Var "x")))) +(let t238 (Add t237 t234)) +(let t239 (Diff (Var "x") (Const 3.0))) +(let t240 (Mul t239 (Ln (Var "x")))) +(let t241 (Mul t0 t240)) +(let t242 (Add t234 t241)) +(let prop5 (= t12 t242)) +(let t243 (Diff (Var "x") (Const 1.0))) +(let t244 (Mul t0 t243)) +(let t245 (Mul t3 t243)) +(let t246 (Add t245 t234)) +(let t247 (Add t244 t246)) +(let t248 (Add t247 t241)) +(let t249 (Add t246 t241)) +(let t250 (Mul (Const 1.0) t12)) +(let t251 (Add t244 t250)) +(let t252 (Mul t0 (Const 1.0))) +(let prf60 + (Rule + (= t12 t12) + (name + "(rewrite (Diff x (Add a b)) (Add (Diff x a) (Diff x b)))") + t21 + t23)) +(let t253 (MathU t0)) +(let t254 + (premises + (Rule + (= t253 t253) + (name + "(rule ((= e (Pow x y))) + ((MathU e)) + )") + (premises (Fiat (= t0 t0))) + (substitution + (y (Const 3.0)) + (e t0) + (x (Var "x")))))) +(let t255 (substitution t18)) +(let prf61 + (Rule + (= t252 t0) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + t254 + t255)) +(let prf62 (Sym (= t0 t252) prf61)) +(let t256 + (premises + (Congr + (= t12 (Diff (Var "x") t252)) + prf60 + prf62 + 1))) +(let t257 + (substitution + (@rewrite_var__26 t12) + t18 + (x (Var "x")) + (b (Const 1.0)))) +(let prf63 + (Sym + (= t12 t251) + (Rule + (= t251 t12) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t256 + t257))) +(let t258 (Mul t12 (Const 1.0))) +(let prf64 + (Rule + (= t250 t250) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t256 + t257)) +(let t259 (b t12)) +(let t260 (MathU t12)) +(let t261 + (premises + (Rule + (= t260 t260) + (name + "(rule ((= e (Diff x y))) + ((MathU e)) + )") + (premises prf60) + (substitution + (y t0) + (e t12) + (x (Var "x")))))) +(let t262 (substitution t77)) +(let prf65 + (Trans + (= t250 t12) + (Sym + (= t250 t258) + (Rule + (= t258 t250) + (name "(rewrite (Mul a b) (Mul b a))") + (premises prf64) + (substitution + (a (Const 1.0)) + (@rewrite_var__5 t250) + t259))) + (Rule + (= t258 t12) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + t261 + t262))) +(let prf66 (Congr (= t12 (Add t244 t12)) prf63 prf65 1)) +(let t263 (Add t245 t245)) +(let t264 (Add t263 t12)) +(let t265 (Add t245 t12)) +(let t266 (Add (Const 0.0) t12)) +(let t267 (Add t12 (Const 0.0))) +(let t268 (@rewrite_var__4 t12)) +(let prf67 + (Sym + (= t12 t266) + (Rule + (= t266 t12) + (name "(rewrite (Add a b) (Add b a))") + (premises + (Sym + (= t12 t267) + (Rule + (= t267 t12) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + t261 + t262))) + (substitution + t268 + t77 + (b (Const 0.0)))))) +(let t269 (Mul t13 t243)) +(let t270 (Add t269 t12)) +(let t271 (Add t12 t269)) +(let t272 (Add t12 t244)) +(let t273 (Add t272 t269)) +(let t274 (Add t244 t269)) +(let t275 (Add t12 t245)) +(let t276 + (Add + t245 + t4)) +(let t277 + (Add + t245 + t70)) +(let t278 + (Mul + t3 + (Const + 1.0))) +(let t279 + (MathU + t3)) +(let t280 + (x + t0)) +(let t281 + (a + t3)) +(let t282 + (premises + (Congr + (= + t4 + (Diff + (Var + "x") + t278)) + prf0 + (Sym + (= + t3 + t278) + (Rule + (= + t278 + t3) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + (premises + (Rule + (= + t279 + t279) + (name + "(rule ((= e (Sub x y))) + ((MathU e)) + )") + t17 + (substitution + (y + t2) + (e + t3) + t280))) + (substitution + t281))) + 1))) +(let t283 + (substitution + (@rewrite_var__26 + t4) + t281 + (x + (Var + "x")) + (b + (Const + 1.0)))) +(let prf68 + (Congr + (= t4 t276) + (Sym + (= + t4 + t277) + (Rule + (= + t277 + t4) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t282 + t283)) + prf11 + 1)) +(let t284 (c t14)) +(let t285 (a t245)) +(let t286 + (@rewrite_var__6 + t4)) +(let prf69 + (Rule + (= t265 t265) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + (premises + (Congr + (= + t4 + (Add + t245 + t15)) + prf68 + prf2 + 1)) + (substitution + t284 + t285 + t286 + t259))) +(let t287 (Mul t243 t0)) +(let t288 (Mul t243 t13)) +(let t289 (Add t287 t288)) +(let t290 + (Mul + t243 + t3)) +(let prf70 + (Rule + (= + t245 + t245) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t282 + t283)) +(let t291 + (premises + prf70)) +(let t292 + (@rewrite_var__5 + t245)) +(let t293 (b t243)) +(let prf71 + (Sym + (= t245 t290) + (Rule + (= + t290 + t245) + (name + "(rewrite (Mul a b) (Mul b a))") + t291 + (substitution + t281 + t292 + t293)))) +(let t294 + (premises + (Congr + (= + t245 + (Mul t243 t16)) + prf71 + prf1 + 1))) +(let t295 (a t243)) +(let t296 + (@rewrite_var__15 + t245)) +(let t297 (b t0)) +(let t298 + (substitution + t295 + t296 + t297 + (c t13))) +(let t299 + (premises + (Rule + (= t244 t244) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t256 + t257))) +(let t300 + (@rewrite_var__5 + t244)) +(let prf72 + (Rule + (= t287 t244) + (name + "(rewrite (Mul a b) (Mul b a))") + t299 + (substitution + t18 + t300 + t293))) +(let t301 + (Mul + t13 + (Const + 1.0))) +(let t302 + (Mul + t34 + (Const + 1.0))) +(let t303 + (premises + (Congr + (= + t13 + (Mul + t24 + t56)) + prf6 + prf10 + 1))) +(let t304 + (substitution + t36 + t40 + t41 + (c + (Const + 1.0)))) +(let t305 + (premises + (Congr + (= + t14 + (Diff + (Var + "x") + t301)) + prf3 + (Trans + (= + t13 + t301) + (Sym + (= + t13 + t302) + (Rule + (= + t302 + t13) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t303 + t304)) + (Congr + (= + t302 + t301) + (Rule + (= + t302 + t302) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t303 + t304) + prf5 + 0)) + 1))) +(let t306 (a t13)) +(let t307 + (substitution + t39 + t306 + (x (Var "x")) + (b + (Const 1.0)))) +(let prf73 + (Rule + (= t288 t269) + (name + "(rewrite (Mul a b) (Mul b a))") + (premises + (Rule + (= t269 t269) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t305 + t307)) + (substitution + t306 + (@rewrite_var__5 + t269) + t293))) +(let t308 + (premises + (Congr + (= t265 (Add t12 t274)) + (Sym + (= t265 t275) + (Rule + (= t275 t265) + (name + "(rewrite (Add a b) (Add b a))") + (premises prf69) + (substitution + (@rewrite_var__4 + t265) + t285 + t259))) + (Trans + (= t245 t274) + (Sym + (= t245 t289) + (Rule + (= t289 t245) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t294 + t298)) + (Congr + (= t289 t274) + (Congr + (= + t289 + (Add t244 t288)) + (Rule + (= t289 t289) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t294 + t298) + prf72 + 0) + prf73 + 1)) + 1))) +(let t309 (@rewrite_var__6 t265)) +(let t310 (b t244)) +(let t311 + (substitution + (c t269) + t77 + t309 + t310)) +(let t312 (a t244)) +(let t313 (Add t269 t68)) +(let t314 (c t68)) +(let t315 (b t269)) +(let t316 (Mul t151 t243)) +(let t317 (Mul t316 (Var "x"))) +(let t318 (Mul t243 t151)) +(let t319 (Mul t318 (Var "x"))) +(let t320 + (premises + (Congr + (= t269 (Mul t243 t165)) + (Sym + (= t269 t288) + prf73) + prf37 + 1))) +(let t321 + (substitution + (@rewrite_var__7 t269) + t295 + t211 + (c (Var "x")))) +(let t322 + (premises + (Rule + (= t316 t316) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + (premises + (Congr + (= + t181 + (Diff + (Var "x") + t190)) + prf54 + prf52 + 1)) + (substitution + t202 + t169 + (x (Var "x")) + (b (Const 1.0)))))) +(let t323 + (substitution + t169 + (@rewrite_var__5 t316) + t293)) +(let prf74 + (Rule + (= t318 t316) + (name + "(rewrite (Mul a b) (Mul b a))") + t322 + t323)) +(let t324 (Mul (Const 0.0) t151)) +(let prf75 + (Rule + (= t243 t243) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t256 + t257)) +(let t325 + (is-const-or-distinct-var + (Const 1.0) + "x")) +(let t326 + (is-const-or-distinct-var-demand + (Const 1.0) + "x")) +(let t327 (premises prf75)) +(let prf76 + (Rule + (= t243 (Const 0.0)) + (name + "(rewrite (Diff (Var x) c) (Const 0.0) :when ((is-const-or-distinct-var c x)))") + (premises + prf75 + (Rule + (= t325 t325) + (name + "(rule ((is-const-or-distinct-var-demand (Const c) v)) + ((is-const-or-distinct-var (Const c) v)) + )") + (premises + (Rule + (= t326 t326) + (name + "(rule ((Diff (Var x) c)) + ((is-const-or-distinct-var-demand c x)) + )") + t327 + (substitution + (x "x") + (c (Const 1.0))))) + (substitution + (v "x") + (c 1.0)))) + (substitution + (c (Const 1.0)) + (@rewrite_var__24 t243) + (x "x")))) +(let t328 (Mul t151 (Const 0.0))) +(let t329 + (premises + (Rule + (= t328 t328) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + (premises + (Congr + (= + t13 + (Mul t151 t214)) + prf37 + prf57 + 1)) + (substitution + t169 + t218 + (b (Const 0.0)) + (c (Var "x")))))) +(let prf77 + (Trans + (= t269 (Const 0.0)) + (Congr + (= t269 t46) + (Trans + (= t269 t317) + (Sym + (= t269 t319) + (Rule + (= t319 t269) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t320 + t321)) + (Congr + (= t319 t317) + (Rule + (= t319 t319) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t320 + t321) + prf74 + 0)) + (Trans + (= t316 (Const 0.0)) + (Trans + (= t316 t324) + (Sym (= t316 t318) prf74) + (Congr + (= t318 t324) + (Rule + (= t318 t318) + (name + "(rewrite (Mul a b) (Mul b a))") + t322 + t323) + prf76 + 0)) + (Trans + (= t324 (Const 0.0)) + (Rule + (= t324 t328) + (name + "(rewrite (Mul a b) (Mul b a))") + t329 + (substitution + t169 + (@rewrite_var__5 t328) + (b (Const 0.0)))) + (Rule + (= t328 (Const 0.0)) + (name + "(rewrite (Mul a (Const 0.0)) (Const 0.0))") + t329 + (substitution + t169 + (@rewrite_var__11 t328))))) + 0) + prf33)) +(let t330 (Add t12 t68)) +(let t331 (Add t263 t4)) +(let t332 (c t4)) +(let t333 (b t245)) +(let t334 (Add t250 t68)) +(let t335 + (premises + (Congr + (= + t4 + (Mul (Const 1.0) t15)) + prf12 + prf2 + 1))) +(let t336 + (substitution + (a (Const 1.0)) + t79 + t259 + t284)) +(let t337 (a t263)) +(let prf78 + (Rule + (= t264 t264) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + (premises + (Congr + (= t4 (Add t263 t330)) + (Sym + (= t4 t331) + (Rule + (= t331 t4) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + (premises + (Congr + (= t4 (Add t245 t276)) + prf68 + prf68 + 1)) + (substitution + t332 + t285 + t286 + t333))) + (Trans + (= t4 t330) + (Sym + (= t4 t334) + (Rule + (= t334 t4) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t335 + t336)) + (Congr + (= t334 t330) + (Rule + (= t334 t334) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t335 + t336) + prf65 + 0)) + 1)) + (substitution t314 t337 t286 t259))) +(let t338 (Mul t3 (Const 0.0))) +(let t339 (Add t245 t338)) +(let t340 (Add t243 (Const 0.0))) +(let t341 (MathU t243)) +(let t342 + (premises + (Rule + (= t341 t341) + (name + "(rule ((= e (Diff x y))) + ((MathU e)) + )") + t327 + (substitution + (y (Const 1.0)) + (e t243) + (x (Var "x")))))) +(let t343 (substitution t295)) +(let t344 (Mul (Const 1.0) t243)) +(let t345 (Mul t3 t344)) +(let t346 (Mul t344 t3)) +(let t347 + (Mul + (Const 1.0) + t245)) +(let t348 + (Mul + t245 + (Const 1.0))) +(let t349 (MathU t245)) +(let t350 (y t243)) +(let prf79 + (Rule + (= t347 t347) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + (premises + (Congr + (= + t4 + (Mul + (Const + 1.0) + t276)) + prf12 + prf68 + 1)) + (substitution + (a + (Const 1.0)) + t79 + t333 + t332))) +(let t351 + (premises + (Trans + (= t245 t346) + (Trans + (= t245 t347) + (Sym + (= t245 t348) + (Rule + (= t348 t245) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + (premises + (Rule + (= t349 t349) + (name + "(rule ((= e (Mul x y))) + ((MathU e)) + )") + t291 + (substitution + t350 + (e t245) + (x t3)))) + (substitution + t285))) + (Rule + (= t348 t347) + (name + "(rewrite (Mul a b) (Mul b a))") + (premises prf79) + (substitution + (a (Const 1.0)) + (@rewrite_var__5 + t347) + t333))) + (Sym + (= t347 t346) + (Rule + (= t346 t347) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + (premises + (Congr + (= + t347 + (Mul + (Const 1.0) + t290)) + prf79 + prf71 + 1)) + (substitution + (@rewrite_var__7 + t347) + (a (Const 1.0)) + t293 + (c t3))))))) +(let t352 (a t344)) +(let t353 + (substitution + t352 + t292 + (b t3))) +(let t354 + (Mul + t243 + (Const 1.0))) +(let prf80 + (Trans + (= t344 (Const 0.0)) + (Rule + (= t344 t243) + (name + "(rewrite (Mul a b) (Mul b a))") + (premises + (Sym + (= t243 t354) + (Rule + (= t354 t243) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + t342 + t343))) + (substitution + t295 + (@rewrite_var__5 t243) + (b (Const 1.0)))) + prf76)) +(let prf81 + (Sym + (= t263 t245) + (Congr + (= t245 t263) + (Sym + (= t245 t339) + (Rule + (= t339 t245) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + (premises + (Congr + (= t245 (Mul t3 t340)) + prf70 + (Sym + (= t243 t340) + (Rule + (= t340 t243) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + t342 + t343)) + 1)) + (substitution + t281 + t296 + t293 + (c (Const 0.0))))) + (Trans + (= t338 t245) + (Sym + (= t338 t345) + (Congr + (= t345 t338) + (Rule + (= t345 t345) + (name + "(rewrite (Mul a b) (Mul b a))") + t351 + t353) + prf80 + 1)) + (Rule + (= t345 t245) + (name + "(rewrite (Mul a b) (Mul b a))") + t351 + t353)) + 1))) +(let t355 (Add t263 t234)) +(let t356 (Add t355 t241)) +(let t357 (Mul t0 (Add t233 t240))) +(let prf82 + (Rule + (= + (Const 0.0) + (Const 0.0)) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + t73 + t75)) +(let prf83 (Fiat (= () ()))) +(let prf84 + (Rule + (= + (is-not-zero + (Var "x")) + (is-not-zero + (Var "x"))) + (name + "(rule ((MathU x) + (!= x (Const 0.0))) + ((is-not-zero x)) + )") + (premises + prf30 + prf82 + prf83) + (substitution + (x (Var "x")) + (@v313 (Const 0.0))))) +(let t358 + (premises + prf60 + prf84 + (Rule + (= + (is-not-zero + (Const 3.0)) + (is-not-zero + (Const 3.0))) + (name + "(rule ((MathU x) + (!= x (Const 0.0))) + ((is-not-zero x)) + )") + (premises + (Rule + (= + (MathU + (Const 3.0)) + (MathU + (Const 3.0))) + (name + "(rule ((= e (Const x))) + ((MathU e)) + )") + (premises + (Fiat + (= + (Const 3.0) + (Const 3.0)))) + (substitution + (e (Const 3.0)) + (x 3.0))) + prf82 + prf83) + (substitution + (x (Const 3.0)) + (@v313 (Const 0.0)))))) +(let t359 + (substitution + (@rewrite_var__30 t12) + (g (Const 3.0)) + (f (Var "x")) + (x (Var "x")))) +(let t360 + (premises + (Sym + (= t12 t357) + (Rule + (= t357 t12) + (name + "(rewrite (Diff x (Pow f g)) (Mul (Pow f g) (Add (Mul (Diff x f) (Div g f)) (Mul (Diff x g) (Ln f)))) :when ((is-not-zero f) (is-not-zero g)))") + t358 + t359)))) +(let t361 + (substitution + t18 + (@rewrite_var__15 t12) + (b t233) + (c t240))) +(let prf85 + (Sym + prop5 + (Rule + (= t242 t12) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t360 + t361))) +(let t362 + (premises + (Congr + (= t264 (Add t263 t242)) + prf78 + prf85 + 1))) +(let t363 (c t241)) +(let t364 (b t234)) +(let t365 + (substitution + t363 + t337 + (@rewrite_var__6 t264) + t364)) +(let prf86 + (Trans + (= t12 t249) + (Trans + (= t12 t264) + (Trans + (= t12 t265) + prf67 + (Sym + (= t266 t265) + (Congr + (= t265 t266) + (Trans + (= t265 t270) + (Trans + (= t265 t271) + (Sym + (= t265 t273) + (Rule + (= t273 t265) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + t308 + t311)) + (Congr + (= t273 t271) + (Rule + (= t273 t273) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + t308 + t311) + (Rule + (= t272 t12) + (name + "(rewrite (Add a b) (Add b a))") + (premises prf66) + (substitution t268 t312 t259)) + 0)) + (Sym + (= t271 t270) + (Rule + (= t270 t271) + (name + "(rewrite (Add a b) (Add b a))") + (premises + (Rule + (= t271 t271) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + (premises + (Congr + (= t4 (Add t12 t313)) + prf2 + (Sym + (= t14 t313) + (Rule + (= t313 t14) + (name + "(rewrite (Diff x (Mul a b)) (Add (Mul a (Diff x b)) (Mul b (Diff x a))))") + t305 + t307)) + 1)) + (substitution + t314 + t77 + t286 + t315))) + (substitution + (@rewrite_var__4 t271) + t77 + t315)))) + prf77 + 0))) + (Sym + (= t265 t264) + (Congr (= t264 t265) prf78 prf81 0))) + (Congr + (= t264 t249) + (Sym + (= t264 t356) + (Rule + (= t356 t264) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + t362 + t365)) + (Congr + (= t355 t246) + (Rule + (= t355 t355) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + t362 + t365) + prf81 + 0) + 0))) +(let t366 + (premises + (Congr (= t12 (Add t244 t249)) prf66 prf86 1))) +(let t367 (@rewrite_var__6 t12)) +(let t368 (b t246)) +(let t369 (substitution t363 t312 t367 t368)) +(let t370 (Add (Const 0.0) t246)) +(let t371 (Mul t0 (Const 0.0))) +(let t372 (Mul t0 t344)) +(let t373 (Mul t344 t0)) +(let t374 (Mul (Const 1.0) t244)) +(let t375 (Mul t244 (Const 1.0))) +(let t376 (MathU t244)) +(let prf87 + (Rule + (= t374 t374) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + (premises + (Congr + (= + t250 + (Mul (Const 1.0) t251)) + prf64 + prf63 + 1)) + (substitution + (a (Const 1.0)) + (@rewrite_var__15 t250) + t310 + (c t250)))) +(let prf88 (Sym (= t244 t287) prf72)) +(let t377 (c t0)) +(let t378 + (premises + (Trans + (= t244 t373) + (Trans + (= t244 t374) + (Sym + (= t244 t375) + (Rule + (= t375 t244) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + (premises + (Rule + (= t376 t376) + (name + "(rule ((= e (Mul x y))) + ((MathU e)) + )") + t299 + (substitution + t350 + (e t244) + t280))) + (substitution t312))) + (Rule + (= t375 t374) + (name + "(rewrite (Mul a b) (Mul b a))") + (premises prf87) + (substitution + (a (Const 1.0)) + (@rewrite_var__5 t374) + t310))) + (Sym + (= t374 t373) + (Rule + (= t373 t374) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + (premises + (Congr + (= + t374 + (Mul (Const 1.0) t287)) + prf87 + prf88 + 1)) + (substitution + (@rewrite_var__7 t374) + (a (Const 1.0)) + t293 + t377)))))) +(let t379 (substitution t352 t300 t297)) +(let prf89 + (Rule + (= t372 t244) + (name "(rewrite (Mul a b) (Mul b a))") + t378 + t379)) +(let prf90 + (Congr + (= t372 t371) + (Rule + (= t372 t372) + (name "(rewrite (Mul a b) (Mul b a))") + t378 + t379) + prf80 + 1)) +(let prf91 + (Rule + (= t244 (Const 0.0)) + (name + "(rewrite (Mul a (Const 0.0)) (Const 0.0))") + (premises + (Trans + (= t244 t371) + (Sym (= t244 t372) prf89) + prf90)) + (substitution t18 (@rewrite_var__11 t244)))) +(let t380 (Add (Const 0.0) t244)) +(let t381 (Add t269 t244)) +(let t382 (Add t288 t287)) +(let t383 (Add t13 t0)) +(let t384 + (premises + (Congr + (= t245 (Mul t243 t383)) + prf71 + (Sym + (= t3 t383) + (Rule + (= t383 t3) + (name + "(rewrite (Add a b) (Add b a))") + (premises prf1) + (substitution + (@rewrite_var__4 t3) + t18 + t22))) + 1))) +(let t385 (substitution t295 t296 t22 t377)) +(let t386 (Mul (Const 1.0) (Const 0.0))) +(let t387 (Mul t243 t386)) +(let t388 (Add t387 t244)) +(let t389 (Add t244 t387)) +(let t390 (Add t287 t387)) +(let t391 (Add t0 t386)) +(let t392 + (Mul + (Const 1.0) + t0)) +(let t393 (Add t392 t386)) +(let t394 + (Add + t0 + (Const + 0.0))) +(let prf92 + (Rule + (= + t392 + t0) + (name + "(rewrite (Mul a b) (Mul b a))") + (premises + prf62) + (substitution + t18 + (@rewrite_var__5 + t0) + (b + (Const + 1.0))))) +(let prf93 + (Sym + (= + t0 + t392) + prf92)) +(let prf94 + (Sym + (= + t0 + t394) + (Rule + (= + t394 + t0) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + t254 + t255))) +(let t395 + (premises + (Congr + (= + t0 + (Mul + (Const + 1.0) + t394)) + prf93 + prf94 + 1))) +(let t396 + (@rewrite_var__15 + t0)) +(let t397 + (substitution + (a + (Const 1.0)) + t396 + t297 + (c + (Const 0.0)))) +(let t398 + (premises + (Congr + (= + t244 + (Mul t243 t391)) + prf88 + (Trans + (= t0 t391) + (Sym + (= t0 t393) + (Rule + (= t393 t0) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t395 + t397)) + (Congr + (= t393 t391) + (Rule + (= t393 t393) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t395 + t397) + prf92 + 0)) + 1))) +(let t399 (@rewrite_var__15 t244)) +(let t400 + (substitution + t295 + t399 + t297 + (c t386))) +(let t401 + (premises + (Trans + (= t244 t389) + (Sym + (= t244 t390) + (Rule + (= t390 t244) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t398 + t400)) + (Congr + (= t390 t389) + (Rule + (= t390 t390) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t398 + t400) + prf72 + 0)))) +(let t402 + (substitution + (@rewrite_var__4 t244) + t312 + (b t387))) +(let t403 (Add t386 t0)) +(let t404 (Add t386 t392)) +(let t405 + (Add + (Const + 0.0) + t0)) +(let t406 + (premises + (Congr + (= + t0 + (Mul + (Const + 1.0) + t405)) + prf93 + (Sym + (= t0 t405) + (Rule + (= + t405 + t0) + (name + "(rewrite (Add a b) (Add b a))") + (premises + prf94) + (substitution + (@rewrite_var__4 + t0) + t18 + (b + (Const + 0.0))))) + 1))) +(let t407 + (substitution + (a (Const 1.0)) + t396 + (b (Const 0.0)) + t377)) +(let t408 + (Add + (Const 0.0) + t2)) +(let t409 + (Add + t2 + (Const + 0.0))) +(let t410 (Diff (Var "x") (Const 0.0))) +(let t411 (Add t410 t234)) +(let t412 (Add t410 t12)) +(let t413 (Add t12 t410)) +(let t414 + (premises + (Congr + (= + t12 + (Diff + (Var "x") + t394)) + prf60 + prf94 + 1))) +(let t415 + (substitution + (b (Const 0.0)) + t18 + (@rewrite_var__25 t12) + (x (Var "x")))) +(let prf95 + (Rule + (= t410 t410) + (name + "(rewrite (Diff x (Add a b)) (Add (Diff x a) (Diff x b)))") + t414 + t415)) +(let t416 + (is-const-or-distinct-var + (Const 0.0) + "x")) +(let t417 + (is-const-or-distinct-var-demand + (Const 0.0) + "x")) +(let prf96 + (Congr + (= t411 t235) + (Rule + (= t411 t411) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + (premises + (Congr + (= t12 (Add t410 t242)) + (Sym + (= t12 t412) + (Rule + (= t412 t12) + (name + "(rewrite (Add a b) (Add b a))") + (premises + (Sym + (= t12 t413) + (Rule + (= t413 t12) + (name + "(rewrite (Diff x (Add a b)) (Add (Diff x a) (Diff x b)))") + t414 + t415))) + (substitution t268 t77 (b t410)))) + prf85 + 1)) + (substitution t363 (a t410) t367 t364)) + (Rule + (= t410 (Const 0.0)) + (name + "(rewrite (Diff (Var x) c) (Const 0.0) :when ((is-const-or-distinct-var c x)))") + (premises + prf95 + (Rule + (= t416 t416) + (name + "(rule ((is-const-or-distinct-var-demand (Const c) v)) + ((is-const-or-distinct-var (Const c) v)) + )") + (premises + (Rule + (= t417 t417) + (name + "(rule ((Diff (Var x) c)) + ((is-const-or-distinct-var-demand c x)) + )") + (premises prf95) + (substitution + (x "x") + (c (Const 0.0))))) + (substitution (v "x") (c 0.0)))) + (substitution + (c (Const 0.0)) + (@rewrite_var__24 t410) + (x "x"))) + 0)) +(let t418 (Add t234 (Const 0.0))) +(let t419 (MathU t234)) +(let prf97 + (Rule + (= t234 t234) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t360 + t361)) +(let t420 (a t234)) +(let prf98 + (Trans + (= t235 t234) + (Sym (= t235 t411) prf96) + (Trans + (= t411 t234) + (Sym + (= t411 t418) + (Rule + (= t418 t411) + (name "(rewrite (Add a b) (Add b a))") + (premises prf96) + (substitution + (@rewrite_var__4 t411) + (a (Const 0.0)) + t364))) + (Rule + (= t418 t234) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + (premises + (Rule + (= t419 t419) + (name + "(rule ((= e (Mul x y))) + ((MathU e)) + )") + (premises prf97) + (substitution (y t233) (e t234) t280))) + (substitution t420))))) +(let t421 (Mul (Const 0.0) (Ln (Var "x")))) +(let t422 (Mul t0 t239)) +(let t423 (Mul t422 (Ln (Var "x")))) +(let t424 + (premises + (Rule + (= t241 t241) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t360 + t361))) +(let t425 + (substitution + (@rewrite_var__7 t241) + t18 + (b t239) + (c (Ln (Var "x"))))) +(let prf99 + (Rule + (= t239 t239) + (name + "(rewrite (Diff x (Pow f g)) (Mul (Pow f g) (Add (Mul (Diff x f) (Div g f)) (Mul (Diff x g) (Ln f)))) :when ((is-not-zero f) (is-not-zero g)))") + t358 + t359)) +(let t426 (is-const-or-distinct-var (Const 3.0) "x")) +(let t427 + (is-const-or-distinct-var-demand + (Const 3.0) + "x")) +(let t428 + (premises + prf36 + prf84 + (Rule + (= + (is-not-zero (Const 2.0)) + (is-not-zero (Const 2.0))) + (name + "(rule ((MathU x) + (!= x (Const 0.0))) + ((is-not-zero x)) + )") + (premises + (Rule + (= + (MathU (Const 2.0)) + (MathU (Const 2.0))) + (name + "(rule ((= e (Const x))) + ((MathU e)) + )") + (premises + (Fiat (= (Const 2.0) (Const 2.0)))) + (substitution (e (Const 2.0)) (x 2.0))) + prf82 + prf83) + (substitution + (x (Const 2.0)) + (@v313 (Const 0.0)))))) +(let t429 + (substitution + (@rewrite_var__30 t27) + (g (Const 2.0)) + (f (Var "x")) + (x (Var "x")))) +(let prf100 + (Rule + (= t237 t237) + (name + "(rewrite (Diff x (Pow f g)) (Mul (Pow f g) (Add (Mul (Diff x f) (Div g f)) (Mul (Diff x g) (Ln f)))) :when ((is-not-zero f) (is-not-zero g)))") + t428 + t429)) +(let prf101 + (Rule + (= t236 t236) + (name + "(rewrite (Diff x (Pow f g)) (Mul (Pow f g) (Add (Mul (Diff x f) (Div g f)) (Mul (Diff x g) (Ln f)))) :when ((is-not-zero f) (is-not-zero g)))") + t428 + t429)) +(let t430 (is-const-or-distinct-var (Const 2.0) "x")) +(let t431 + (is-const-or-distinct-var-demand + (Const 2.0) + "x")) +(let t432 (premises prf101)) +(let prf102 + (Rule + (= t236 (Const 0.0)) + (name + "(rewrite (Diff (Var x) c) (Const 0.0) :when ((is-const-or-distinct-var c x)))") + (premises + prf101 + (Rule + (= t430 t430) + (name + "(rule ((is-const-or-distinct-var-demand (Const c) v)) + ((is-const-or-distinct-var (Const c) v)) + )") + (premises + (Rule + (= t431 t431) + (name + "(rule ((Diff (Var x) c)) + ((is-const-or-distinct-var-demand c x)) + )") + t432 + (substitution (x "x") (c (Const 2.0))))) + (substitution (v "x") (c 2.0)))) + (substitution + (c (Const 2.0)) + (@rewrite_var__24 t236) + (x "x")))) +(let prf103 + (Trans + (= t241 t237) + (Congr + (= t241 t421) + (Sym + (= t241 t423) + (Rule + (= t423 t241) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t424 + t425)) + (Trans + (= t422 (Const 0.0)) + (Congr + (= t422 t371) + (Rule + (= t422 t422) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t424 + t425) + (Rule + (= t239 (Const 0.0)) + (name + "(rewrite (Diff (Var x) c) (Const 0.0) :when ((is-const-or-distinct-var c x)))") + (premises + prf99 + (Rule + (= t426 t426) + (name + "(rule ((is-const-or-distinct-var-demand (Const c) v)) + ((is-const-or-distinct-var (Const c) v)) + )") + (premises + (Rule + (= t427 t427) + (name + "(rule ((Diff (Var x) c)) + ((is-const-or-distinct-var-demand c x)) + )") + (premises prf99) + (substitution (x "x") (c (Const 3.0))))) + (substitution (v "x") (c 3.0)))) + (substitution + (c (Const 3.0)) + (@rewrite_var__24 t239) + (x "x"))) + 1) + (Trans + (= t371 (Const 0.0)) + (Trans + (= t371 t244) + (Sym (= t371 t372) prf90) + prf89) + prf91)) + 0) + (Sym + (= t421 t237) + (Congr (= t237 t421) prf100 prf102 0)))) +(let t433 (Add t234 t10)) +(let t434 (Add t14 t234)) +(let t435 (Add t241 t434)) +(let t436 (Add t434 t241)) +(let t437 + (premises + (Congr (= t4 (Add t14 t242)) prf13 prf85 1))) +(let t438 (a t14)) +(let t439 (substitution t363 t438 t286 t364)) +(let t440 (Add t234 t14)) +(let t441 (Mul (Ln (Var "x")) (Const 0.0))) +(let t442 (Mul (Ln (Var "x")) t236)) +(let t443 (a t236)) +(let prf104 + (Sym + (= t237 t442) + (Rule + (= t442 t237) + (name "(rewrite (Mul a b) (Mul b a))") + (premises prf100) + (substitution + t443 + (@rewrite_var__5 t237) + (b (Ln (Var "x"))))))) +(let t444 (Mul t236 (Const 1.0))) +(let t445 (MathU t236)) +(let t446 (a (Ln (Var "x")))) +(let t447 (Mul t229 (Const 3.0))) +(let t448 (Mul t0 t232)) +(let t449 (Mul t252 t232)) +(let t450 (Mul (Const 1.0) t232)) +(let t451 + (premises + (Congr + (= t234 (Mul t0 t450)) + prf97 + (Congr + (= t233 t450) + (Rule + (= t233 t233) + (name + "(rewrite (Diff x (Pow f g)) (Mul (Pow f g) (Add (Mul (Diff x f) (Div g f)) (Mul (Diff x g) (Ln f)))) :when ((is-not-zero f) (is-not-zero g)))") + t358 + t359) + prf38 + 0) + 1))) +(let t452 (@rewrite_var__7 t234)) +(let t453 (substitution t452 t18 (b (Const 1.0)) (c t232))) +(let t454 (Mul (Const 3.0) t229)) +(let t455 (b t229)) +(let t456 + (premises + (Congr + (= t234 (Mul t0 t447)) + (Trans + (= t234 t448) + (Sym + (= t234 t449) + (Rule + (= t449 t234) + (name "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t451 + t453)) + (Congr + (= t449 t448) + (Rule + (= t449 t449) + (name "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t451 + t453) + prf61 + 0)) + (Sym + (= t232 t447) + (Rule + (= t447 t232) + (name "(rewrite (Mul a b) (Mul b a))") + (premises + (Sym + (= t232 t454) + (Rule + (= t454 t232) + (name + "(rewrite (Div a b) (Mul a (Pow b (Const -1.0))) :when ((is-not-zero b)))") + (premises + (Rule + (= t232 t232) + (name + "(rewrite (Diff x (Pow f g)) (Mul (Pow f g) (Add (Mul (Diff x f) (Div g f)) (Mul (Diff x g) (Ln f)))) :when ((is-not-zero f) (is-not-zero g)))") + t358 + t359) + prf84) + (substitution + (a (Const 3.0)) + (b (Var "x")) + (@rewrite_var__9 t232))))) + (substitution (a (Const 3.0)) (@rewrite_var__5 t232) t455))) + 1))) +(let t457 (substitution t452 t18 t455 (c (Const 3.0)))) +(let t458 (Add (Const -1.0) (Const 3.0))) +(let t459 (Pow (Var "x") t458)) +(let t460 (Mul t229 t0)) +(let t461 + (premises + (Rule + (= t230 t230) + (name "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t456 + t457))) +(let t462 + (premises + (Sym + (= t230 t460) + (Rule + (= t460 t230) + (name "(rewrite (Mul a b) (Mul b a))") + t461 + (substitution t18 (@rewrite_var__5 t230) t455))))) +(let t463 (@rewrite_var__17 t230)) +(let t464 (substitution t463 (a (Var "x")) (b (Const -1.0)) (c (Const 3.0)))) +(let t465 (Add (Const 3.0) (Const -1.0))) +(let t466 + (premises + (Rule + (= t465 t465) + (name + "(rewrite (Mul (Pow a b) (Pow a c)) (Pow a (Add b c)))") + t461 + (substitution + t463 + (a (Var "x")) + (b (Const 3.0)) + (c (Const -1.0)))))) +(let t467 (Mul t126 (Const 3.0))) +(let t468 (Mul (Var "x") (Const 3.0))) +(let t469 (Add t5 t9)) +(let t470 + (premises + (Congr + (= t7 (Mul (Var "x") t469)) + (Fiat (= t7 t7)) + (Sym + (= t6 t469) + (Rule + (= t469 t6) + (name + "(rewrite (Sub a b) (Add a (Mul (Const -1.0) b)))") + t226 + t227)) + 1))) +(let t471 + (substitution + (a (Var "x")) + (@rewrite_var__15 t7) + (b t5) + (c t9))) +(let t472 + (premises + (Congr + (= t8 (Mul (Var "x") t468)) + (Rule + (= t8 t8) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t470 + t471) + (Sym + (= t5 t468) + (Rule + (= t468 t5) + (name "(rewrite (Mul a b) (Mul b a))") + (premises (Fiat (= t5 t5))) + (substitution + (a (Const 3.0)) + (@rewrite_var__5 t5) + (b (Var "x"))))) + 1))) +(let t473 + (substitution + (@rewrite_var__7 t8) + (a (Var "x")) + (b (Var "x")) + (c (Const 3.0)))) +(Trans + (= t4 t7) + (Congr + (= t4 t11) + (Congr (= t4 (Add t12 t10)) prf2 prf59 1) + (Trans + (= t12 t8) + (Congr + (= t12 t228) + (Trans + (= t12 t231) + (Trans + (= t12 t234) + (Trans + (= t12 t235) + (Sym + (= t12 t238) + (Rule + (= t238 t12) + (name "(rewrite (Add a b) (Add b a))") + (premises + (Congr + (= t12 (Add t234 t237)) + (Congr + prop5 + (Sym + (= t12 t248) + (Rule + (= t248 t12) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + t366 + t369)) + (Trans + (= t247 t234) + (Trans + (= t247 t235) + (Congr + (= t247 t370) + (Rule + (= t247 t247) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + t366 + t369) + prf91 + 0) + (Congr + (= t370 t235) + (Rule + (= t370 t370) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + (premises + (Congr + (= t12 (Add (Const 0.0) t249)) + prf67 + prf86 + 1)) + (substitution t363 (a (Const 0.0)) t367 t368)) + (Trans + (= t246 t234) + (Congr + (= t246 t235) + (Congr + (= t246 (Add t244 t234)) + (Rule + (= t246 t246) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + (premises + (Congr + (= t265 (Add t245 t242)) + prf69 + prf85 + 1)) + (substitution t363 t285 t309 t364)) + (Trans + (= t245 t244) + (Congr + (= t245 t380) + (Trans + (= t245 t381) + (Sym + (= t245 t382) + (Rule + (= t382 t245) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t384 + t385)) + (Congr + (= t382 t381) + (Congr + (= t382 (Add t269 t287)) + (Rule + (= t382 t382) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t384 + t385) + prf73 + 0) + prf72 + 1)) + prf77 + 0) + (Trans + (= t380 t244) + (Sym + (= t380 t388) + (Congr + (= t388 t380) + (Rule + (= t388 t388) + (name + "(rewrite (Add a b) (Add b a))") + t401 + t402) + (Rule + (= t387 (Const 0.0)) + (name + "(rewrite (Mul a (Const 0.0)) (Const 0.0))") + (premises + (Congr + (= + t387 + (Mul t243 (Const 0.0))) + (Rule + (= t387 t387) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + (premises + (Congr + (= t244 (Mul t243 t403)) + prf88 + (Trans + (= t0 t403) + (Sym + (= t0 t404) + (Rule + (= t404 t0) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t406 + t407)) + (Congr + (= t404 t403) + (Rule + (= t404 t404) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t406 + t407) + prf92 + 1)) + 1)) + (substitution + t295 + t399 + (b t386) + t377)) + (Rule + (= t386 (Const 0.0)) + (name + "(rewrite (Mul (Const a) (Const b)) (Const (* a b)))") + (premises + (Rule + (= t386 t386) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + (premises + (Congr + (= + t2 + (Mul + (Const 1.0) + t408)) + prf21 + (Sym + (= t2 t408) + (Rule + (= t408 t2) + (name + "(rewrite (Add a b) (Add b a))") + (premises + (Sym + (= t2 t409) + (Rule + (= + t409 + t2) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + t98 + t99))) + (substitution + (@rewrite_var__4 + t2) + t94 + (b + (Const 0.0))))) + 1)) + (substitution + (a (Const 1.0)) + (@rewrite_var__15 t2) + (b (Const 0.0)) + (c t2)))) + (substitution + (@rewrite_var__2 t386) + (a 1.0) + (b 0.0))) + 1)) + (substitution + t295 + (@rewrite_var__11 t387))) + 0)) + (Rule + (= t388 t244) + (name "(rewrite (Add a b) (Add b a))") + t401 + t402))) + 0) + prf91 + 0) + prf98) + 1)) + prf98) + 0) + prf103 + 1)) + (substitution t268 t420 (b t237)))) + (Congr + (= t238 t235) + (Rule + (= t238 t238) + (name "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + (premises + (Congr + (= t4 (Add t237 t433)) + (Congr + (= t4 (Add t237 t434)) + (Sym + (= t4 t435) + (Rule + (= t435 t4) + (name "(rewrite (Add a b) (Add b a))") + (premises + (Sym + (= t4 t436) + (Rule + (= t436 t4) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + t437 + t439))) + (substitution t76 (a t434) (b t241)))) + prf103 + 0) + (Congr + (= t434 t433) + (Sym + (= t434 t440) + (Rule + (= t440 t434) + (name "(rewrite (Add a b) (Add b a))") + (premises + (Rule + (= t434 t434) + (name + "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + t437 + t439)) + (substitution (@rewrite_var__4 t434) t438 t364))) + prf59 + 1) + 1)) + (substitution (c t10) (a t237) t286 t364)) + (Rule + (= t237 (Const 0.0)) + (name "(rewrite (Mul a (Const 0.0)) (Const 0.0))") + (premises + (Trans + (= t237 t441) + prf104 + (Congr + (= t442 t441) + (Rule + (= t442 t442) + (name "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + (premises + (Congr + (= t237 (Mul (Ln (Var "x")) t444)) + prf104 + (Sym + (= t236 t444) + (Rule + (= t444 t236) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + (premises + (Rule + (= t445 t445) + (name + "(rule ((= e (Diff x y))) + ((MathU e)) + )") + t432 + (substitution + (y (Const 2.0)) + (e t236) + (x (Var "x"))))) + (substitution t443))) + 1)) + (substitution + (@rewrite_var__7 t237) + t446 + (b t236) + (c (Const 1.0)))) + prf102 + 1))) + (substitution t446 (@rewrite_var__11 t237))) + 0)) + prf98) + (Sym + (= t234 t231) + (Rule + (= t231 t234) + (name "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t456 + t457))) + (Trans + (= t230 t1) + (Sym + (= t230 t459) + (Rule + (= t459 t230) + (name "(rewrite (Mul (Pow a b) (Pow a c)) (Pow a (Add b c)))") + t462 + t464)) + (Congr + (= t459 t1) + (Rule + (= t459 t459) + (name "(rewrite (Mul (Pow a b) (Pow a c)) (Pow a (Add b c)))") + t462 + t464) + (Trans + (= t458 (Const 2.0)) + (Rule + (= t458 t465) + (name "(rewrite (Add a b) (Add b a))") + t466 + (substitution + (@rewrite_var__4 t465) + (a (Const 3.0)) + (b (Const -1.0)))) + (Rule + (= t465 (Const 2.0)) + (name "(rewrite (Add (Const a) (Const b)) (Const (+ a b)))") + t466 + (substitution (a 3.0) (b -1.0) (@rewrite_var__ t465)))) + 1)) + 0) + (Trans + (= t228 t8) + (Sym + (= t228 t467) + (Congr + (= t467 t228) + (Rule + (= t467 t467) + (name "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t472 + t473) + prf26 + 0)) + (Rule + (= t467 t8) + (name "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t472 + t473))) + 0) + (Rule + (= t11 t7) + (name "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t470 + t471)) +(let t0 (Integral (Const 1.0) (Var "x"))) +(Sym + (= t0 (Var "x")) + (Rule + (= (Var "x") t0) + (name "(rewrite (Integral (Const 1.0) x) x)") + (premises (Fiat (= t0 t0))) + (substitution (x (Var "x")) (@rewrite_var__31 t0)))) +(let t0 (Integral (Cos (Var "x")) (Var "x"))) +(Sym + (= t0 (Sin (Var "x"))) + (Rule + (= (Sin (Var "x")) t0) + (name "(rewrite (Integral (Cos x) x) (Sin x))") + (premises (Fiat (= t0 t0))) + (substitution (@rewrite_var__33 t0) (x (Var "x"))))) +(let t0 (Integral (Pow (Var "x") (Const 1.0)) (Var "x"))) +(let t1 (Pow (Var "x") (Const 2.0))) +(let t2 (Add (Const 1.0) (Const 1.0))) +(let t3 (Pow (Var "x") t2)) +(let t4 (Div t3 t2)) +(let t5 (premises (Fiat (= t0 t0)))) +(let t6 (substitution (c 1.0) (@rewrite_var__32 t0) (x (Var "x")))) +(let prf0 + (Sym + (= t2 (Const 2.0)) + (Rule + (= (Const 2.0) t2) + (name "(rewrite (Add (Const a) (Const b)) (Const (+ a b)))") + (premises + (Rule + (= t2 t2) + (name + "(rewrite (Integral (Pow x (Const c)) x) (Div (Pow x (Add (Const c) (Const 1.0))) (Add (Const c) (Const 1.0))))") + t5 + t6)) + (substitution (a 1.0) (b 1.0) (@rewrite_var__ t2))))) +(Congr + (= t0 (Div t1 (Const 2.0))) + (Congr + (= t0 (Div t1 t2)) + (Sym + (= t0 t4) + (Rule + (= t4 t0) + (name + "(rewrite (Integral (Pow x (Const c)) x) (Div (Pow x (Add (Const c) (Const 1.0))) (Add (Const c) (Const 1.0))))") + t5 + t6)) + (Congr + (= t3 t1) + (Rule + (= t3 t3) + (name + "(rewrite (Integral (Pow x (Const c)) x) (Div (Pow x (Add (Const c) (Const 1.0))) (Add (Const c) (Const 1.0))))") + t5 + t6) + prf0 + 1) + 0) + prf0 + 1) +(let t0 (Mul (Var "x") (Cos (Var "x")))) +(let t1 (Integral t0 (Var "x"))) +(let t2 (Mul (Var "x") (Sin (Var "x")))) +(let t3 (Integral (Cos (Var "x")) (Var "x"))) +(let t4 (Mul (Var "x") t3)) +(let t5 (Diff (Var "x") (Var "x"))) +(let t6 (Mul t5 t3)) +(let t7 (Integral t6 (Var "x"))) +(let t8 (Mul (Const -1.0) t7)) +(let t9 (Add t4 t8)) +(let prop0 (= t1 t9)) +(let t10 (Mul t5 (Const 0.0))) +(let t11 (Add t10 t4)) +(let t12 (Add t11 t8)) +(let t13 (Add t10 t1)) +(let t14 (Mul t5 t1)) +(let t15 (Add t10 t14)) +(let t16 (Add (Const 0.0) t1)) +(let t17 (Mul t1 t5)) +(let t18 (Mul t1 (Const 1.0))) +(let t19 (MathU t1)) +(let t20 (premises (Fiat (= t1 t1)))) +(let t21 + (premises + (Rule + (= t19 t19) + (name + "(rule ((= e (Integral x y))) + ((MathU e)) + )") + t20 + (substitution + (y (Var "x")) + (e t1) + (x t0))))) +(let t22 (a t1)) +(let t23 (substitution t22)) +(let t24 (b (Cos (Var "x")))) +(let t25 + (substitution + (a (Var "x")) + (@rewrite_var__37 t1) + t24 + (x (Var "x")))) +(let prf0 + (Rule + (= (Const 1.0) t5) + (name + "(rewrite (Diff (Var x) (Var x)) (Const 1.0))") + (premises + (Rule + (= t5 t5) + (name + "(rewrite (Integral (Mul a b) x) (Sub (Mul a (Integral b x)) (Integral (Mul (Diff x a) (Integral b x)) x)))") + t20 + t25)) + (substitution (@rewrite_var__23 t5) (x "x")))) +(let t26 (b t5)) +(let prf1 + (Rule + (= t14 t1) + (name "(rewrite (Mul a b) (Mul b a))") + (premises + (Trans + (= t1 t17) + (Sym + (= t1 t18) + (Rule + (= t18 t1) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + t21 + t23)) + (Congr + (= t18 t17) + (Rule + (= t18 t18) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + t21 + t23) + prf0 + 1))) + (substitution t22 (@rewrite_var__5 t1) t26))) +(let prf2 (Sym (= t1 t14) prf1)) +(let t27 (Add t1 (Const 0.0))) +(let t28 + (premises + (Congr + (= t1 (Mul t5 t16)) + prf2 + (Sym + (= t1 t16) + (Rule + (= t16 t1) + (name "(rewrite (Add a b) (Add b a))") + (premises + (Sym + (= t1 t27) + (Rule + (= t27 t1) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + t21 + t23))) + (substitution + (@rewrite_var__4 t1) + t22 + (b (Const 0.0))))) + 1))) +(let t29 (a t5)) +(let t30 (@rewrite_var__15 t1)) +(let t31 (substitution t29 t30 (b (Const 0.0)) (c t1))) +(let prf3 + (Trans + (= t1 t13) + (Sym + (= t1 t15) + (Rule + (= t15 t1) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t28 + t31)) + (Congr + (= t15 t13) + (Rule + (= t15 t15) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t28 + t31) + prf1 + 1))) +(let t32 (Sub t4 t7)) +(let t33 + (premises + (Sym + (= t1 t32) + (Rule + (= t32 t1) + (name + "(rewrite (Integral (Mul a b) x) (Sub (Mul a (Integral b x)) (Integral (Mul (Diff x a) (Integral b x)) x)))") + t20 + t25)))) +(let t34 (a t4)) +(let t35 (substitution t34 (b t7) (@rewrite_var__8 t1))) +(let prf4 + (Sym + prop0 + (Rule + (= t9 t1) + (name "(rewrite (Sub a b) (Add a (Mul (Const -1.0) b)))") + t33 + t35))) +(let t36 (c t8)) +(let t37 (a t10)) +(let t38 (@rewrite_var__6 t1)) +(let t39 (b t4)) +(let t40 (Add (Const 0.0) t4)) +(let t41 (Mul t5 t8)) +(let t42 (Add t4 t41)) +(let t43 (Mul t5 t4)) +(let t44 (Add t43 t41)) +(let t45 (premises (Congr (= t1 (Mul t5 t9)) prf2 prf4 1))) +(let t46 (substitution t29 t30 t39 t36)) +(let t47 (Mul t4 t5)) +(let t48 (Mul t3 (Var "x"))) +(let t49 (Mul t48 t5)) +(let t50 (Mul (Var "x") t5)) +(let prf5 + (Rule + (= t4 t4) + (name + "(rewrite (Integral (Mul a b) x) (Sub (Mul a (Integral b x)) (Integral (Mul (Diff x a) (Integral b x)) x)))") + t20 + t25)) +(let t51 (premises prf5)) +(let t52 (@rewrite_var__5 t4)) +(let t53 (b t3)) +(let prf6 + (Rule + (= t48 t4) + (name "(rewrite (Mul a b) (Mul b a))") + t51 + (substitution (a (Var "x")) t52 t53))) +(let t54 (Mul (Var "x") (Const 1.0))) +(let t55 + (premises + (Rule + (= + (MathU (Var "x")) + (MathU (Var "x"))) + (name + "(rule ((= e (Var x))) + ((MathU e)) + )") + (premises + (Fiat (= (Var "x") (Var "x")))) + (substitution (e (Var "x")) (x "x"))))) +(let t56 (substitution (a (Var "x")))) +(let t57 + (premises + (Congr + (= t4 (Mul t3 t50)) + (Sym (= t4 t48) prf6) + (Trans + (= (Var "x") t50) + (Sym + (= (Var "x") t54) + (Rule + (= t54 (Var "x")) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + t55 + t56)) + (Congr + (= t54 t50) + (Rule + (= t54 t54) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + t55 + t56) + prf0 + 1)) + 1))) +(let t58 (a t3)) +(let t59 + (substitution + (@rewrite_var__7 t4) + t58 + (b (Var "x")) + (c t5))) +(let t60 (Add (Const 0.0) t0)) +(let t61 (Mul t5 t0)) +(let t62 (Mul t0 t5)) +(let t63 (Mul t0 (Const 1.0))) +(let t64 (MathU t0)) +(let t65 + (premises + (Rule + (= t64 t64) + (name + "(rule ((= e (Mul x y))) + ((MathU e)) + )") + (premises (Fiat (= t0 t0))) + (substitution + (y (Cos (Var "x"))) + (e t0) + (x (Var "x")))))) +(let t66 (a t0)) +(let t67 (substitution t66)) +(let t68 (Add t0 (Const 0.0))) +(let prf7 (Sym (= t5 (Const 1.0)) prf0)) +(let t69 (Add t4 (Const 0.0))) +(let t70 (MathU t4)) +(let t71 (Mul (Cos (Var "x")) t5)) +(let t72 (Mul (Const -1.0) (Const -1.0))) +(let t73 (Mul (Cos (Var "x")) t72)) +(let t74 (Mul t72 (Cos (Var "x")))) +(let t75 (Mul (Const -1.0) (Cos (Var "x")))) +(let t76 (Integral t3 (Var "x"))) +(let prf8 + (Rule + (= t7 t7) + (name + "(rewrite (Integral (Mul a b) x) (Sub (Mul a (Integral b x)) (Integral (Mul (Diff x a) (Integral b x)) x)))") + t20 + t25)) +(let t77 (Mul t3 t5)) +(let prf9 + (Sym + (= t3 (Sin (Var "x"))) + (Rule + (= (Sin (Var "x")) t3) + (name + "(rewrite (Integral (Cos x) x) (Sin x))") + (premises + (Rule + (= t3 t3) + (name + "(rewrite (Integral (Mul a b) x) (Sub (Mul a (Integral b x)) (Integral (Mul (Diff x a) (Integral b x)) x)))") + t20 + t25)) + (substitution + (@rewrite_var__33 t3) + (x (Var "x")))))) +(let t78 + (premises + (Congr + (= t8 (Mul (Const -1.0) t75)) + (Rule + (= t8 t8) + (name + "(rewrite (Sub a b) (Add a (Mul (Const -1.0) b)))") + t33 + t35) + (Trans + (= t7 t75) + (Congr + (= t7 t76) + prf8 + (Rule + (= t6 t3) + (name "(rewrite (Mul a (Const 1.0)) a)") + (premises + (Congr + (= t6 (Mul t3 (Const 1.0))) + (Sym + (= t6 t77) + (Rule + (= t77 t6) + (name "(rewrite (Mul a b) (Mul b a))") + (premises + (Rule + (= t6 t6) + (name + "(rewrite (Integral (Mul a b) x) (Sub (Mul a (Integral b x)) (Integral (Mul (Diff x a) (Integral b x)) x)))") + t20 + t25)) + (substitution t29 (@rewrite_var__5 t6) t53))) + prf7 + 1)) + (substitution t58 (@rewrite_var__12 t6))) + 0) + (Sym + (= t76 t75) + (Rule + (= t75 t76) + (name + "(rewrite (Integral (Sin x) x) (Mul (Const -1.0) (Cos x)))") + (premises + (Congr + (= t76 (Integral (Sin (Var "x")) (Var "x"))) + (Rule + (= t76 t76) + (name + "(rewrite (Integral (Mul a b) x) (Sub (Mul a (Integral b x)) (Integral (Mul (Diff x a) (Integral b x)) x)))") + (premises prf8) + (substitution + t29 + (@rewrite_var__37 t7) + t53 + (x (Var "x")))) + prf9 + 0)) + (substitution (x (Var "x")) (@rewrite_var__34 t76))))) + 1))) +(let t79 + (substitution + (@rewrite_var__7 t8) + (a (Const -1.0)) + (b (Const -1.0)) + (c (Cos (Var "x"))))) +(let t80 + (premises + (Sym + (= t8 t74) + (Rule + (= t74 t8) + (name "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t78 + t79)))) +(let t81 (substitution (a t72) (@rewrite_var__5 t8) t24)) +(let t82 (Mul (Cos (Var "x")) (Const 1.0))) +(let t83 (MathU (Cos (Var "x")))) +(let t84 + (premises + (Rule + (= t83 t83) + (name + "(rule ((= e (Cos x))) + ((MathU e)) + )") + (premises (Fiat (= (Cos (Var "x")) (Cos (Var "x"))))) + (substitution (e (Cos (Var "x"))) (x (Var "x")))))) +(let t85 (substitution (a (Cos (Var "x"))))) +(Congr + (= t1 (Add t2 (Cos (Var "x")))) + (Congr + (= t1 (Add t4 (Cos (Var "x")))) + (Congr + prop0 + (Sym + (= t1 t12) + (Rule + (= t12 t1) + (name "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + (premises (Congr (= t1 (Add t10 t9)) prf3 prf4 1)) + (substitution t36 t37 t38 t39))) + (Trans + (= t11 t4) + (Congr + (= t11 t40) + (Rule + (= t11 t11) + (name "(rewrite (Add a (Add b c)) (Add (Add a b) c))") + (premises + (Congr + (= t1 (Add t10 t42)) + prf3 + (Trans + (= t1 t42) + (Sym + (= t1 t44) + (Rule + (= t44 t1) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t45 + t46)) + (Congr + (= t44 t42) + (Rule + (= t44 t44) + (name + "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + t45 + t46) + (Rule + (= t43 t4) + (name "(rewrite (Mul a b) (Mul b a))") + (premises + (Trans + (= t4 t47) + (Sym + (= t4 t49) + (Rule + (= t49 t4) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t57 + t59)) + (Congr + (= t49 t47) + (Rule + (= t49 t49) + (name + "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t57 + t59) + prf6 + 0))) + (substitution t34 t52 t26)) + 0)) + 1)) + (substitution (c t41) t37 t38 t39)) + (Rule + (= t10 (Const 0.0)) + (name "(rewrite (Mul (Const a) (Const b)) (Const (* a b)))") + (premises + (Congr + (= t10 (Mul (Const 1.0) (Const 0.0))) + (Rule + (= t10 t10) + (name "(rewrite (Mul a (Add b c)) (Add (Mul a b) (Mul a c)))") + (premises + (Congr + (= t0 (Mul t5 t60)) + (Sym + (= t0 t61) + (Rule + (= t61 t0) + (name "(rewrite (Mul a b) (Mul b a))") + (premises + (Trans + (= t0 t62) + (Sym + (= t0 t63) + (Rule + (= t63 t0) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + t65 + t67)) + (Congr + (= t63 t62) + (Rule + (= t63 t63) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + t65 + t67) + prf0 + 1))) + (substitution t66 (@rewrite_var__5 t0) t26))) + (Sym + (= t0 t60) + (Rule + (= t60 t0) + (name "(rewrite (Add a b) (Add b a))") + (premises + (Sym + (= t0 t68) + (Rule + (= t68 t0) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + t65 + t67))) + (substitution + (@rewrite_var__4 t0) + t66 + (b (Const 0.0))))) + 1)) + (substitution + t29 + (@rewrite_var__15 t0) + (b (Const 0.0)) + (c t0))) + prf7 + 0)) + (substitution (@rewrite_var__2 t10) (a 1.0) (b 0.0))) + 0) + (Rule + (= t40 t4) + (name "(rewrite (Add a b) (Add b a))") + (premises + (Sym + (= t4 t69) + (Rule + (= t69 t4) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + (premises + (Rule + (= t70 t70) + (name + "(rule ((= e (Mul x y))) + ((MathU e)) + )") + t51 + (substitution (y t3) (e t4) (x (Var "x"))))) + (substitution t34)))) + (substitution (@rewrite_var__4 t4) t34 (b (Const 0.0))))) + 0) + (Trans + (= t8 (Cos (Var "x"))) + (Trans + (= t8 t71) + (Sym + (= t8 t73) + (Rule (= t73 t8) (name "(rewrite (Mul a b) (Mul b a))") t80 t81)) + (Congr + (= t73 t71) + (Rule (= t73 t73) (name "(rewrite (Mul a b) (Mul b a))") t80 t81) + (Trans + (= t72 t5) + (Rule + (= t72 (Const 1.0)) + (name "(rewrite (Mul (Const a) (Const b)) (Const (* a b)))") + (premises + (Rule + (= t72 t72) + (name "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t78 + t79)) + (substitution (@rewrite_var__2 t72) (a -1.0) (b -1.0))) + prf0) + 1)) + (Trans + (= t71 (Cos (Var "x"))) + (Sym + (= t71 t82) + (Congr + (= t82 t71) + (Rule + (= t82 t82) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + t84 + t85) + prf0 + 1)) + (Rule + (= t82 (Cos (Var "x"))) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + t84 + t85))) + 1) + (Congr (= t4 t2) prf5 prf9 1) + 0) +(let t0 (Mul (Cos (Var "x")) (Var "x"))) +(let t1 (Integral t0 (Var "x"))) +(let t2 (Mul (Var "x") (Sin (Var "x")))) +(let t3 (Integral (Cos (Var "x")) (Var "x"))) +(let t4 (Mul (Var "x") t3)) +(let t5 (Diff (Var "x") (Var "x"))) +(let t6 (Mul t5 t3)) +(let t7 (Integral t6 (Var "x"))) +(let t8 (Mul (Const -1.0) t7)) +(let t9 (Add t4 t8)) +(let t10 (Sub t4 t7)) +(let t11 (Mul (Var "x") (Cos (Var "x")))) +(let t12 (a (Cos (Var "x")))) +(let t13 + (premises + (Congr + (= t1 (Integral t11 (Var "x"))) + (Fiat (= t1 t1)) + (Sym + (= t0 t11) + (Rule + (= t11 t0) + (name "(rewrite (Mul a b) (Mul b a))") + (premises (Fiat (= t0 t0))) + (substitution t12 (@rewrite_var__5 t0) (b (Var "x"))))) + 0))) +(let t14 (b (Cos (Var "x")))) +(let t15 + (substitution + (a (Var "x")) + (@rewrite_var__37 t1) + t14 + (x (Var "x")))) +(let t16 + (premises + (Sym + (= t1 t10) + (Rule + (= t10 t1) + (name + "(rewrite (Integral (Mul a b) x) (Sub (Mul a (Integral b x)) (Integral (Mul (Diff x a) (Integral b x)) x)))") + t13 + t15)))) +(let t17 (substitution (a t4) (b t7) (@rewrite_var__8 t1))) +(let t18 (Mul (Cos (Var "x")) (Const 1.0))) +(let t19 (Mul (Const -1.0) (Const -1.0))) +(let t20 (Mul (Cos (Var "x")) t19)) +(let t21 (Mul t19 (Cos (Var "x")))) +(let t22 (Mul (Const -1.0) (Cos (Var "x")))) +(let t23 (Integral t3 (Var "x"))) +(let t24 (Integral (Sin (Var "x")) (Var "x"))) +(let prf0 + (Rule + (= t7 t7) + (name + "(rewrite (Integral (Mul a b) x) (Sub (Mul a (Integral b x)) (Integral (Mul (Diff x a) (Integral b x)) x)))") + t13 + t15)) +(let t25 (Mul (Sin (Var "x")) (Const 1.0))) +(let t26 (Mul t3 t5)) +(let t27 + (premises + (Rule + (= t6 t6) + (name + "(rewrite (Integral (Mul a b) x) (Sub (Mul a (Integral b x)) (Integral (Mul (Diff x a) (Integral b x)) x)))") + t13 + t15))) +(let t28 (a t5)) +(let t29 (b t3)) +(let t30 + (substitution + t28 + (@rewrite_var__5 t6) + t29)) +(let prf1 + (Rule + (= t3 (Sin (Var "x"))) + (name + "(rewrite (Integral (Cos x) x) (Sin x))") + (premises + (Rule + (= t3 t3) + (name + "(rewrite (Integral (Mul a b) x) (Sub (Mul a (Integral b x)) (Integral (Mul (Diff x a) (Integral b x)) x)))") + t13 + t15)) + (substitution + (@rewrite_var__33 t3) + (x (Var "x"))))) +(let prf2 + (Congr + (= t23 t24) + (Rule + (= t23 t23) + (name + "(rewrite (Integral (Mul a b) x) (Sub (Mul a (Integral b x)) (Integral (Mul (Diff x a) (Integral b x)) x)))") + (premises prf0) + (substitution + t28 + (@rewrite_var__37 t7) + t29 + (x (Var "x")))) + prf1 + 0)) +(let t31 + (premises + (Congr + (= t8 (Mul (Const -1.0) t22)) + (Rule + (= t8 t8) + (name + "(rewrite (Sub a b) (Add a (Mul (Const -1.0) b)))") + t16 + t17) + (Trans + (= t7 t22) + (Trans + (= t7 t23) + (Congr + (= t7 t24) + prf0 + (Rule + (= t6 (Sin (Var "x"))) + (name "(rewrite (Mul a (Const 1.0)) a)") + (premises + (Trans + (= t6 t25) + (Sym + (= t6 t26) + (Rule + (= t26 t6) + (name "(rewrite (Mul a b) (Mul b a))") + t27 + t30)) + (Congr + (= t26 t25) + (Congr + (= t26 (Mul (Sin (Var "x")) t5)) + (Rule + (= t26 t26) + (name "(rewrite (Mul a b) (Mul b a))") + t27 + t30) + prf1 + 0) + (Rule + (= t5 (Const 1.0)) + (name + "(rewrite (Diff (Var x) (Var x)) (Const 1.0))") + (premises + (Rule + (= t5 t5) + (name + "(rewrite (Integral (Mul a b) x) (Sub (Mul a (Integral b x)) (Integral (Mul (Diff x a) (Integral b x)) x)))") + t13 + t15)) + (substitution + (@rewrite_var__23 t5) + (x "x"))) + 1))) + (substitution + (a (Sin (Var "x"))) + (@rewrite_var__12 t6))) + 0) + (Sym (= t24 t23) prf2)) + (Sym + (= t23 t22) + (Rule + (= t22 t23) + (name + "(rewrite (Integral (Sin x) x) (Mul (Const -1.0) (Cos x)))") + (premises prf2) + (substitution (x (Var "x")) (@rewrite_var__34 t23))))) + 1))) +(let t32 + (substitution + (@rewrite_var__7 t8) + (a (Const -1.0)) + (b (Const -1.0)) + (c (Cos (Var "x"))))) +(let t33 + (premises + (Sym + (= t8 t21) + (Rule + (= t21 t8) + (name "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t31 + t32)))) +(let t34 (substitution (a t19) (@rewrite_var__5 t8) t14)) +(let t35 (MathU (Cos (Var "x")))) +(Congr + (= t1 (Add t2 (Cos (Var "x")))) + (Congr + (= t1 (Add t4 (Cos (Var "x")))) + (Sym + (= t1 t9) + (Rule + (= t9 t1) + (name "(rewrite (Sub a b) (Add a (Mul (Const -1.0) b)))") + t16 + t17)) + (Trans + (= t8 (Cos (Var "x"))) + (Trans + (= t8 t18) + (Sym + (= t8 t20) + (Rule (= t20 t8) (name "(rewrite (Mul a b) (Mul b a))") t33 t34)) + (Congr + (= t20 t18) + (Rule (= t20 t20) (name "(rewrite (Mul a b) (Mul b a))") t33 t34) + (Rule + (= t19 (Const 1.0)) + (name "(rewrite (Mul (Const a) (Const b)) (Const (* a b)))") + (premises + (Rule + (= t19 t19) + (name "(rewrite (Mul a (Mul b c)) (Mul (Mul a b) c))") + t31 + t32)) + (substitution (@rewrite_var__2 t19) (a -1.0) (b -1.0))) + 1)) + (Rule + (= t18 (Cos (Var "x"))) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + (premises + (Rule + (= t35 t35) + (name + "(rule ((= e (Cos x))) + ((MathU e)) + )") + (premises (Fiat (= (Cos (Var "x")) (Cos (Var "x"))))) + (substitution (e (Cos (Var "x"))) (x (Var "x"))))) + (substitution t12))) + 1) + (Congr + (= t4 t2) + (Rule + (= t4 t4) + (name + "(rewrite (Integral (Mul a b) x) (Sub (Mul a (Integral b x)) (Integral (Mul (Diff x a) (Integral b x)) x)))") + t13 + t15) + prf1 + 1) + 0) +(let t0 (Integral (Ln (Var "x")) (Var "x"))) +(let t1 (Mul (Var "x") (Ln (Var "x")))) +(let t2 (Integral (Const 1.0) (Var "x"))) +(let t3 (Mul (Ln (Var "x")) t2)) +(let t4 (Diff (Var "x") (Ln (Var "x")))) +(let t5 (Mul t4 t2)) +(let t6 (Integral t5 (Var "x"))) +(let t7 (Sub t3 t6)) +(let t8 (Mul (Ln (Var "x")) (Const 1.0))) +(let prf0 (Fiat (= t0 t0))) +(let t9 (MathU (Ln (Var "x")))) +(let t10 (a (Ln (Var "x")))) +(let t11 + (premises + (Congr + (= t0 (Integral t8 (Var "x"))) + prf0 + (Sym + (= (Ln (Var "x")) t8) + (Rule + (= t8 (Ln (Var "x"))) + (name + "(rule ((MathU a)) + ((union a (Mul a (Const 1.0)))) + )") + (premises + (Rule + (= t9 t9) + (name + "(rule ((= e (Ln x))) + ((MathU e)) + )") + (premises (Fiat (= (Ln (Var "x")) (Ln (Var "x"))))) + (substitution (e (Ln (Var "x"))) (x (Var "x"))))) + (substitution t10))) + 0))) +(let t12 (substitution t10 (@rewrite_var__37 t0) (b (Const 1.0)) (x (Var "x")))) +(let t13 (Div (Const 1.0) (Var "x"))) +(let t14 (Mul (Var "x") t4)) +(let t15 (Mul t2 t4)) +(let t16 + (premises + (Rule + (= t5 t5) + (name + "(rewrite (Integral (Mul a b) x) (Sub (Mul a (Integral b x)) (Integral (Mul (Diff x a) (Integral b x)) x)))") + t11 + t12))) +(let t17 (b t2)) +(let t18 (substitution (a t4) (@rewrite_var__5 t5) t17)) +(let prf1 + (Rule + (= t2 (Var "x")) + (name "(rewrite (Integral (Const 1.0) x) x)") + (premises + (Rule + (= t2 t2) + (name + "(rewrite (Integral (Mul a b) x) (Sub (Mul a (Integral b x)) (Integral (Mul (Diff x a) (Integral b x)) x)))") + t11 + t12)) + (substitution (x (Var "x")) (@rewrite_var__31 t2)))) +(let t19 (MathU t0)) +(let prf2 + (Rule + (= (is-not-zero (Var "x")) (is-not-zero (Var "x"))) + (name + "(rule ((MathU x) + (!= x (Const 0.0))) + ((is-not-zero x)) + )") + (premises + (Rule + (= (MathU (Var "x")) (MathU (Var "x"))) + (name + "(rule ((= e (Var x))) + ((MathU e)) + )") + (premises (Fiat (= (Var "x") (Var "x")))) + (substitution (e (Var "x")) (x "x"))) + (Rule + (= (Const 0.0) (Const 0.0)) + (name + "(rule ((MathU a)) + ((union a (Add a (Const 0.0)))) + )") + (premises + (Rule + (= t19 t19) + (name + "(rule ((= e (Integral x y))) + ((MathU e)) + )") + (premises prf0) + (substitution + (y (Var "x")) + (e t0) + (x (Ln (Var "x")))))) + (substitution (a t0))) + (Fiat (= () ()))) + (substitution (x (Var "x")) (@v313 (Const 0.0))))) +(let t20 (Mul t2 (Ln (Var "x")))) +(let t21 + (premises + (Rule + (= t3 t3) + (name + "(rewrite (Integral (Mul a b) x) (Sub (Mul a (Integral b x)) (Integral (Mul (Diff x a) (Integral b x)) x)))") + t11 + t12))) +(let t22 (substitution t10 (@rewrite_var__5 t3) t17)) +(Congr + (= t0 (Sub t1 (Var "x"))) + (Congr + (= t0 (Sub t3 (Var "x"))) + (Sym + (= t0 t7) + (Rule + (= t7 t0) + (name + "(rewrite (Integral (Mul a b) x) (Sub (Mul a (Integral b x)) (Integral (Mul (Diff x a) (Integral b x)) x)))") + t11 + t12)) + (Trans + (= t6 (Var "x")) + (Congr + (= t6 t2) + (Rule + (= t6 t6) + (name + "(rewrite (Integral (Mul a b) x) (Sub (Mul a (Integral b x)) (Integral (Mul (Diff x a) (Integral b x)) x)))") + t11 + t12) + (Rule + (= t5 (Const 1.0)) + (name + "(rewrite (Mul x (Div (Const 1.0) x)) (Const 1.0) :when ((is-not-zero x)))") + (premises + (Congr + (= t5 (Mul (Var "x") t13)) + (Trans + (= t5 t14) + (Sym + (= t5 t15) + (Rule + (= t15 t5) + (name "(rewrite (Mul a b) (Mul b a))") + t16 + t18)) + (Congr + (= t15 t14) + (Rule + (= t15 t15) + (name "(rewrite (Mul a b) (Mul b a))") + t16 + t18) + prf1 + 0)) + (Sym + (= t4 t13) + (Rule + (= t13 t4) + (name + "(rewrite (Diff x (Ln x)) (Div (Const 1.0) x) :when ((is-not-zero x)))") + (premises + (Rule + (= t4 t4) + (name + "(rewrite (Integral (Mul a b) x) (Sub (Mul a (Integral b x)) (Integral (Mul (Diff x a) (Integral b x)) x)))") + t11 + t12) + prf2) + (substitution (@rewrite_var__29 t4) (x (Var "x"))))) + 1) + prf2) + (substitution (@rewrite_var__22 t5) (x (Var "x")))) + 0) + prf1) + 1) + (Trans + (= t3 t1) + (Sym + (= t3 t20) + (Rule (= t20 t3) (name "(rewrite (Mul a b) (Mul b a))") t21 t22)) + (Congr + (= t20 t1) + (Rule (= t20 t20) (name "(rewrite (Mul a b) (Mul b a))") t21 t22) + prf1 + 0)) + 0) diff --git a/egglog/tests/snapshots/files__proof_integration__resolution_desugar_proof_testing.snap b/egglog/tests/snapshots/files__proof_integration__resolution_desugar_proof_testing.snap new file mode 100644 index 0000000..5751db1 --- /dev/null +++ b/egglog/tests/snapshots/files__proof_integration__resolution_desugar_proof_testing.snap @@ -0,0 +1,142 @@ +--- +source: egglog/tests/files.rs +expression: proof_snapshot +--- +(Fiat (= () ())) +(let t0 (myor (negate (p 0)) (myor (FalseConst) (FalseConst)))) +(let t1 (myor (negate (p 0)) (FalseConst))) +(let t2 (a (negate (p 0)))) +(let prf0 + (Rule + (= t1 (negate (p 0))) + (name "(rewrite (myor a $False) a)") + (premises (Fiat (= t1 t1))) + (substitution t2 (@rewrite_var__5 t1)))) +(let prf1 (Sym (= (negate (p 0)) t1) prf0)) +(let t3 (myor (p 2) t1)) +(let t4 (myor (negate (p 2)) (myor (FalseConst) (FalseConst)))) +(let prop0 (= (TrueConst) t4)) +(let t5 (myor (TrueConst) (myor (FalseConst) (FalseConst)))) +(let t6 (myor (negate (p 2)) (FalseConst))) +(let t7 (myor (p 1) t6)) +(let t8 + (premises + (Congr + (= (TrueConst) (myor (FalseConst) t6)) + (Sym (= (TrueConst) t7) (Fiat (= t7 (TrueConst)))) + (Fiat (= (p 1) (FalseConst))) + 0))) +(let t9 + (substitution + (@rewrite_var__1 (TrueConst)) + (a (FalseConst)) + (b (negate (p 2))) + (c (FalseConst)))) +(let prf2 + (Rule + (= t6 (negate (p 2))) + (name "(rewrite (myor a $False) a)") + (premises (Fiat (= t6 t6))) + (substitution (a (negate (p 2))) (@rewrite_var__5 t6)))) +(let prf3 + (Rule + (= t6 (TrueConst)) + (name "(rewrite (myor $False a) a)") + t8 + (substitution (@rewrite_var__4 (TrueConst)) (a t6)))) +(Rule + (= (p 0) (FalseConst)) + (name + "(rule ((= (negate p) $True)) + ((union p $False)) + )") + (premises + (Trans + (= (negate (p 0)) (TrueConst)) + (Sym + (= (negate (p 0)) t0) + (Rule + (= t0 (negate (p 0))) + (name "(rewrite (myor (myor a b) c) (myor a (myor b c)))") + (premises + (Congr (= (negate (p 0)) (myor t1 (FalseConst))) prf1 prf1 0)) + (substitution + (c (FalseConst)) + t2 + (b (FalseConst)) + (@rewrite_var__ (negate (p 0)))))) + (Rule + (= t0 (TrueConst)) + (name + "(rule ((= $True (myor a as)) + (= $True (myor (negate a) bs))) + ((union (myor as bs) $True)) + )") + (premises + (Congr + (= (TrueConst) (myor (p 2) (negate (p 0)))) + (Sym (= (TrueConst) t3) (Fiat (= t3 (TrueConst)))) + prf0 + 1) + (Congr + prop0 + (Trans + (= (TrueConst) t5) + (Sym + prop0 + (Rule + (= t4 (TrueConst)) + (name "(rewrite (myor a (myor b c)) (myor b (myor a c)))") + t8 + t9)) + (Congr + (= t4 t5) + (Rule + (= t4 t4) + (name "(rewrite (myor a (myor b c)) (myor b (myor a c)))") + t8 + t9) + (Trans + (= (negate (p 2)) (TrueConst)) + (Sym (= (negate (p 2)) t6) prf2) + prf3) + 0)) + (Trans + (= (TrueConst) (negate (p 2))) + (Sym (= (TrueConst) t6) prf3) + prf2) + 0)) + (substitution + (bs (myor (FalseConst) (FalseConst))) + (a (p 2)) + (as (negate (p 0))))))) + (substitution (p (p 0)))) +(let t0 (myor (negate (p 2)) (FalseConst))) +(let t1 (myor (p 1) t0)) +(Rule + (= (p 2) (FalseConst)) + (name + "(rule ((= (negate p) $True)) + ((union p $False)) + )") + (premises + (Trans + (= (negate (p 2)) (TrueConst)) + (Sym + (= (negate (p 2)) t0) + (Rule + (= t0 (negate (p 2))) + (name "(rewrite (myor a $False) a)") + (premises (Fiat (= t0 t0))) + (substitution (a (negate (p 2))) (@rewrite_var__5 t0)))) + (Rule + (= t0 (TrueConst)) + (name "(rewrite (myor $False a) a)") + (premises + (Congr + (= (TrueConst) (myor (FalseConst) t0)) + (Sym (= (TrueConst) t1) (Fiat (= t1 (TrueConst)))) + (Fiat (= (p 1) (FalseConst))) + 0)) + (substitution (@rewrite_var__4 (TrueConst)) (a t0))))) + (substitution (p (p 2)))) diff --git a/egglog/tests/snapshots/files__proof_integration__resolution_proof_testing.snap b/egglog/tests/snapshots/files__proof_integration__resolution_proof_testing.snap new file mode 100644 index 0000000..5751db1 --- /dev/null +++ b/egglog/tests/snapshots/files__proof_integration__resolution_proof_testing.snap @@ -0,0 +1,142 @@ +--- +source: egglog/tests/files.rs +expression: proof_snapshot +--- +(Fiat (= () ())) +(let t0 (myor (negate (p 0)) (myor (FalseConst) (FalseConst)))) +(let t1 (myor (negate (p 0)) (FalseConst))) +(let t2 (a (negate (p 0)))) +(let prf0 + (Rule + (= t1 (negate (p 0))) + (name "(rewrite (myor a $False) a)") + (premises (Fiat (= t1 t1))) + (substitution t2 (@rewrite_var__5 t1)))) +(let prf1 (Sym (= (negate (p 0)) t1) prf0)) +(let t3 (myor (p 2) t1)) +(let t4 (myor (negate (p 2)) (myor (FalseConst) (FalseConst)))) +(let prop0 (= (TrueConst) t4)) +(let t5 (myor (TrueConst) (myor (FalseConst) (FalseConst)))) +(let t6 (myor (negate (p 2)) (FalseConst))) +(let t7 (myor (p 1) t6)) +(let t8 + (premises + (Congr + (= (TrueConst) (myor (FalseConst) t6)) + (Sym (= (TrueConst) t7) (Fiat (= t7 (TrueConst)))) + (Fiat (= (p 1) (FalseConst))) + 0))) +(let t9 + (substitution + (@rewrite_var__1 (TrueConst)) + (a (FalseConst)) + (b (negate (p 2))) + (c (FalseConst)))) +(let prf2 + (Rule + (= t6 (negate (p 2))) + (name "(rewrite (myor a $False) a)") + (premises (Fiat (= t6 t6))) + (substitution (a (negate (p 2))) (@rewrite_var__5 t6)))) +(let prf3 + (Rule + (= t6 (TrueConst)) + (name "(rewrite (myor $False a) a)") + t8 + (substitution (@rewrite_var__4 (TrueConst)) (a t6)))) +(Rule + (= (p 0) (FalseConst)) + (name + "(rule ((= (negate p) $True)) + ((union p $False)) + )") + (premises + (Trans + (= (negate (p 0)) (TrueConst)) + (Sym + (= (negate (p 0)) t0) + (Rule + (= t0 (negate (p 0))) + (name "(rewrite (myor (myor a b) c) (myor a (myor b c)))") + (premises + (Congr (= (negate (p 0)) (myor t1 (FalseConst))) prf1 prf1 0)) + (substitution + (c (FalseConst)) + t2 + (b (FalseConst)) + (@rewrite_var__ (negate (p 0)))))) + (Rule + (= t0 (TrueConst)) + (name + "(rule ((= $True (myor a as)) + (= $True (myor (negate a) bs))) + ((union (myor as bs) $True)) + )") + (premises + (Congr + (= (TrueConst) (myor (p 2) (negate (p 0)))) + (Sym (= (TrueConst) t3) (Fiat (= t3 (TrueConst)))) + prf0 + 1) + (Congr + prop0 + (Trans + (= (TrueConst) t5) + (Sym + prop0 + (Rule + (= t4 (TrueConst)) + (name "(rewrite (myor a (myor b c)) (myor b (myor a c)))") + t8 + t9)) + (Congr + (= t4 t5) + (Rule + (= t4 t4) + (name "(rewrite (myor a (myor b c)) (myor b (myor a c)))") + t8 + t9) + (Trans + (= (negate (p 2)) (TrueConst)) + (Sym (= (negate (p 2)) t6) prf2) + prf3) + 0)) + (Trans + (= (TrueConst) (negate (p 2))) + (Sym (= (TrueConst) t6) prf3) + prf2) + 0)) + (substitution + (bs (myor (FalseConst) (FalseConst))) + (a (p 2)) + (as (negate (p 0))))))) + (substitution (p (p 0)))) +(let t0 (myor (negate (p 2)) (FalseConst))) +(let t1 (myor (p 1) t0)) +(Rule + (= (p 2) (FalseConst)) + (name + "(rule ((= (negate p) $True)) + ((union p $False)) + )") + (premises + (Trans + (= (negate (p 2)) (TrueConst)) + (Sym + (= (negate (p 2)) t0) + (Rule + (= t0 (negate (p 2))) + (name "(rewrite (myor a $False) a)") + (premises (Fiat (= t0 t0))) + (substitution (a (negate (p 2))) (@rewrite_var__5 t0)))) + (Rule + (= t0 (TrueConst)) + (name "(rewrite (myor $False a) a)") + (premises + (Congr + (= (TrueConst) (myor (FalseConst) t0)) + (Sym (= (TrueConst) t1) (Fiat (= t1 (TrueConst)))) + (Fiat (= (p 1) (FalseConst))) + 0)) + (substitution (@rewrite_var__4 (TrueConst)) (a t0))))) + (substitution (p (p 2)))) diff --git a/egglog/tests/snapshots/files__proof_integration__rw_analysis_desugar_proof_testing.snap b/egglog/tests/snapshots/files__proof_integration__rw_analysis_desugar_proof_testing.snap new file mode 100644 index 0000000..2090296 --- /dev/null +++ b/egglog/tests/snapshots/files__proof_integration__rw_analysis_desugar_proof_testing.snap @@ -0,0 +1,408 @@ +--- +source: egglog/tests/files.rs +expression: proof_snapshot +--- +(let t0 (const-prop (L 14) (V "y") (I 10))) +(let t1 (RProg (L 13) (Ass (V "y") (Const (I 10))))) +(let t2 (Ass (V "y") (Add (V "x") (V "zero")))) +(let prf0 (Sym (= (Prog (L 13)) t2) (Fiat (= t2 (Prog (L 13)))))) +(let t3 (const-prop (L 13) (V "x") (I 10))) +(let t4 (If (V "b") (L 6) (L 13))) +(let t5 (RProg (L 5) t4)) +(let prop0 (= t5 t5)) +(let prf1 (Fiat (= t4 (Prog (L 5))))) +(let prf2 (Sym (= (Prog (L 5)) t4) prf1)) +(let t6 (const-prop (L 5) (V "b") (TopConst))) +(let t7 (Ass (V "x") (Const (I 10)))) +(let t8 (RProg (L 4) t7)) +(let prop1 (= t8 t8)) +(let prf3 (Fiat (= t7 (Prog (L 4))))) +(let prf4 (Sym (= (Prog (L 4)) t7) prf3)) +(let prf5 + (Congr + prop1 + (Congr + (= t8 (RProg (L 4) (Prog (L 4)))) + (Rule + prop1 + (name + "(rule ((= (Prog l) (Ass x (Const val)))) + ((RProg l (Ass x (Const val)))) + )") + (premises prf4) + (substitution + (val (I 10)) + (l (L 4)) + (x (V "x")))) + prf3 + 1) + prf4 + 1)) +(let t9 (const-prop (L 4) (V "b") (TopConst))) +(let t10 (Ass (V "zero") (Const (I 0)))) +(let t11 (RProg (L 3) t10)) +(let prop2 (= t11 t11)) +(let prf6 (Fiat (= t10 (Prog (L 3))))) +(let prf7 (Sym (= (Prog (L 3)) t10) prf6)) +(let prf8 + (Congr + prop2 + (Congr + (= t11 (RProg (L 3) (Prog (L 3)))) + (Rule + prop2 + (name + "(rule ((= (Prog l) (Ass x (Const val)))) + ((RProg l (Ass x (Const val)))) + )") + (premises prf7) + (substitution + (val (I 0)) + (l (L 3)) + (x (V "zero")))) + prf6 + 1) + prf7 + 1)) +(let t12 (const-prop (L 3) (V "b") (TopConst))) +(let t13 (Ass (V "one") (Const (I 1)))) +(let t14 (RProg (L 2) t13)) +(let prop3 (= t14 t14)) +(let prf9 (Fiat (= t13 (Prog (L 2))))) +(let prf10 (Sym (= (Prog (L 2)) t13) prf9)) +(let t15 (const-prop (L 2) (V "b") (TopConst))) +(let t16 (Ass (V "ten") (Const (I 10)))) +(let t17 (RProg (L 1) t16)) +(let prop4 (= t17 t17)) +(let prf11 (Fiat (= t16 (Prog (L 1))))) +(let prf12 (Sym (= (Prog (L 1)) t16) prf11)) +(let t18 + (const-prop + (L 1) + (V "b") + (TopConst))) +(let t19 + (Ass + (V "b") + (Const (TopConst)))) +(let t20 (RProg (L 0) t19)) +(let prop5 (= t20 t20)) +(let prf13 + (Fiat + (= t19 (Prog (L 0))))) +(let prf14 + (Sym + (= (Prog (L 0)) t19) + prf13)) +(let prf15 (Fiat (= (TopConst) (TopConst)))) +(let prf16 (Fiat (= () ()))) +(let t21 (e (Const (I 10)))) +(let prf17 + (Congr + prop0 + (Congr + (= t5 (RProg (L 5) (Prog (L 5)))) + (Rule + prop0 + (name + "(rule ((= (Prog l) (If b l1 l2)) + (= $Top (const-prop l b))) + ((RProg l (If b l1 l2))) + )") + (premises + prf2 + (Rule + (= t6 t6) + (name + "(rule ((RProg (L li) (Ass (V x) e)) + (= val (const-prop (L li) (V y))) + (!= x y)) + ((set (const-prop (L (+ li 1)) (V y)) val)) + )") + (premises + prf5 + (Rule + (= t9 t9) + (name + "(rule ((RProg (L li) (Ass (V x) e)) + (= val (const-prop (L li) (V y))) + (!= x y)) + ((set (const-prop (L (+ li 1)) (V y)) val)) + )") + (premises + prf8 + (Rule + (= t12 t12) + (name + "(rule ((RProg (L li) (Ass (V x) e)) + (= val (const-prop (L li) (V y))) + (!= x y)) + ((set (const-prop (L (+ li 1)) (V y)) val)) + )") + (premises + (Congr + prop3 + (Congr + (= t14 (RProg (L 2) (Prog (L 2)))) + (Rule + prop3 + (name + "(rule ((= (Prog l) (Ass x (Const val)))) + ((RProg l (Ass x (Const val)))) + )") + (premises prf10) + (substitution + (val (I 1)) + (l (L 2)) + (x (V "one")))) + prf9 + 1) + prf10 + 1) + (Rule + (= t15 t15) + (name + "(rule ((RProg (L li) (Ass (V x) e)) + (= val (const-prop (L li) (V y))) + (!= x y)) + ((set (const-prop (L (+ li 1)) (V y)) val)) + )") + (premises + (Congr + prop4 + (Congr + (= t17 (RProg (L 1) (Prog (L 1)))) + (Rule + prop4 + (name + "(rule ((= (Prog l) (Ass x (Const val)))) + ((RProg l (Ass x (Const val)))) + )") + (premises prf12) + (substitution + (val (I 10)) + (l (L 1)) + (x (V "ten")))) + prf11 + 1) + prf12 + 1) + (Rule + (= t18 t18) + (name + "(rule ((RProg (L li) (Ass x (Const k)))) + ((set (const-prop (L (+ li 1)) x) k)) + )") + (premises + (Congr + prop5 + (Congr + (= + t20 + (RProg (L 0) (Prog (L 0)))) + (Rule + prop5 + (name + "(rule ((= (Prog l) (Ass x (Const val)))) + ((RProg l (Ass x (Const val)))) + )") + (premises prf14) + (substitution + (val (TopConst)) + (l (L 0)) + (x (V "b")))) + prf13 + 1) + prf14 + 1)) + (substitution + (li 0) + (x (V "b")) + (k (TopConst)))) + prf15 + prf16) + (substitution + t21 + (y "b") + (li 1) + (@n4 (TopConst)) + (x "ten") + (val (TopConst)))) + prf15 + prf16) + (substitution + (e (Const (I 1))) + (y "b") + (li 2) + (@n4 (TopConst)) + (x "one") + (val (TopConst)))) + prf15 + prf16) + (substitution + (e (Const (I 0))) + (y "b") + (li 3) + (@n4 (TopConst)) + (x "zero") + (val (TopConst)))) + prf15 + prf16) + (substitution + t21 + (y "b") + (li 4) + (@n4 (TopConst)) + (x "x") + (val (TopConst)))) + prf15) + (substitution + (l1 (L 6)) + (l (L 5)) + (l2 (L 13)) + (@n21 (TopConst)) + (b (V "b")))) + prf1 + 1) + prf2 + 1)) +(let t22 (const-prop (L 5) (V "x") (I 10))) +(let prf18 (Fiat (= (I 10) (I 10)))) +(let prf19 + (Rule + (= t3 t3) + (name + "(rule ((RProg l (If b l1 l2)) + (= val (const-prop l x))) + ((set (const-prop l1 x) val) + (set (const-prop l2 x) val)) + )") + (premises + prf17 + (Rule + (= t22 t22) + (name + "(rule ((RProg (L li) (Ass x (Const k)))) + ((set (const-prop (L (+ li 1)) x) k)) + )") + (premises prf5) + (substitution (li 4) (x (V "x")) (k (I 10)))) + prf18) + (substitution + (l1 (L 6)) + (x (V "x")) + (l (L 5)) + (l2 (L 13)) + (val (I 10)) + (b (V "b")) + (@n18 (I 10))))) +(let t23 (const-prop (L 13) (V "zero") (I 0))) +(let t24 (const-prop (L 5) (V "zero") (I 0))) +(let t25 (const-prop (L 4) (V "zero") (I 0))) +(let prf20 (Fiat (= (I 0) (I 0)))) +(let prf21 + (Rule + (= t23 t23) + (name + "(rule ((RProg l (If b l1 l2)) + (= val (const-prop l x))) + ((set (const-prop l1 x) val) + (set (const-prop l2 x) val)) + )") + (premises + prf17 + (Rule + (= t24 t24) + (name + "(rule ((RProg (L li) (Ass (V x) e)) + (= val (const-prop (L li) (V y))) + (!= x y)) + ((set (const-prop (L (+ li 1)) (V y)) val)) + )") + (premises + prf5 + (Rule + (= t25 t25) + (name + "(rule ((RProg (L li) (Ass x (Const k)))) + ((set (const-prop (L (+ li 1)) x) k)) + )") + (premises prf8) + (substitution (li 3) (x (V "zero")) (k (I 0)))) + prf20 + prf16) + (substitution + t21 + (y "zero") + (li 4) + (@n4 (I 0)) + (x "x") + (val (I 0)))) + prf20) + (substitution + (l1 (L 6)) + (x (V "zero")) + (l (L 5)) + (l2 (L 13)) + (val (I 0)) + (b (V "b")) + (@n18 (I 0))))) +(let t26 (add-val (I 10) (I 0))) +(Rule + (= (@ExistsConstructor) (@ExistsConstructor)) + (name "@prove_exists_rule") + (premises + (Rule + (= t0 t0) + (name + "(rule ((RProg (L li) (Ass x (Const k)))) + ((set (const-prop (L (+ li 1)) x) k)) + )") + (premises + (Rule + (= t1 t1) + (name + "(rule ((= (Prog l) (Ass x (Add x1 x2))) + (= (I val) (add-val (const-prop l x1) (const-prop l x2)))) + ((RProg l (Ass x (Const (I val))))) + )") + (premises + prf0 + prf19 + prf21 + (Sym + (= (I 10) t26) + (Rule + (= t26 (I 10)) + (name "(rewrite (add-val (I x) (I y)) (I (+ x y)))") + (premises + (Rule + (= t26 t26) + (name + "(rule ((= (Prog l) (Ass x (Add x1 x2))) + (= v1 (const-prop l x1)) + (= v2 (const-prop l x2))) + ((add-val v1 v2)) + )") + (premises prf0 prf19 prf18 prf21 prf20) + (substitution + (@n5 (I 10)) + (v2 (I 0)) + (x1 (V "x")) + (x2 (V "zero")) + (l (L 13)) + (@n6 (I 0)) + (x (V "y")) + (v1 (I 10))))) + (substitution (@rewrite_var__14 t26) (x 10) (y 0))))) + (substitution + (x1 (V "x")) + (x2 (V "zero")) + (l (L 13)) + (@n9 (I 10)) + (@n10 (I 0)) + (val 10) + (x (V "y"))))) + (substitution (li 13) (x (V "y")) (k (I 10)))) + prf18) + (substitution (@n23 (I 10)))) diff --git a/egglog/tests/snapshots/files__proof_integration__rw_analysis_proof_testing.snap b/egglog/tests/snapshots/files__proof_integration__rw_analysis_proof_testing.snap new file mode 100644 index 0000000..2090296 --- /dev/null +++ b/egglog/tests/snapshots/files__proof_integration__rw_analysis_proof_testing.snap @@ -0,0 +1,408 @@ +--- +source: egglog/tests/files.rs +expression: proof_snapshot +--- +(let t0 (const-prop (L 14) (V "y") (I 10))) +(let t1 (RProg (L 13) (Ass (V "y") (Const (I 10))))) +(let t2 (Ass (V "y") (Add (V "x") (V "zero")))) +(let prf0 (Sym (= (Prog (L 13)) t2) (Fiat (= t2 (Prog (L 13)))))) +(let t3 (const-prop (L 13) (V "x") (I 10))) +(let t4 (If (V "b") (L 6) (L 13))) +(let t5 (RProg (L 5) t4)) +(let prop0 (= t5 t5)) +(let prf1 (Fiat (= t4 (Prog (L 5))))) +(let prf2 (Sym (= (Prog (L 5)) t4) prf1)) +(let t6 (const-prop (L 5) (V "b") (TopConst))) +(let t7 (Ass (V "x") (Const (I 10)))) +(let t8 (RProg (L 4) t7)) +(let prop1 (= t8 t8)) +(let prf3 (Fiat (= t7 (Prog (L 4))))) +(let prf4 (Sym (= (Prog (L 4)) t7) prf3)) +(let prf5 + (Congr + prop1 + (Congr + (= t8 (RProg (L 4) (Prog (L 4)))) + (Rule + prop1 + (name + "(rule ((= (Prog l) (Ass x (Const val)))) + ((RProg l (Ass x (Const val)))) + )") + (premises prf4) + (substitution + (val (I 10)) + (l (L 4)) + (x (V "x")))) + prf3 + 1) + prf4 + 1)) +(let t9 (const-prop (L 4) (V "b") (TopConst))) +(let t10 (Ass (V "zero") (Const (I 0)))) +(let t11 (RProg (L 3) t10)) +(let prop2 (= t11 t11)) +(let prf6 (Fiat (= t10 (Prog (L 3))))) +(let prf7 (Sym (= (Prog (L 3)) t10) prf6)) +(let prf8 + (Congr + prop2 + (Congr + (= t11 (RProg (L 3) (Prog (L 3)))) + (Rule + prop2 + (name + "(rule ((= (Prog l) (Ass x (Const val)))) + ((RProg l (Ass x (Const val)))) + )") + (premises prf7) + (substitution + (val (I 0)) + (l (L 3)) + (x (V "zero")))) + prf6 + 1) + prf7 + 1)) +(let t12 (const-prop (L 3) (V "b") (TopConst))) +(let t13 (Ass (V "one") (Const (I 1)))) +(let t14 (RProg (L 2) t13)) +(let prop3 (= t14 t14)) +(let prf9 (Fiat (= t13 (Prog (L 2))))) +(let prf10 (Sym (= (Prog (L 2)) t13) prf9)) +(let t15 (const-prop (L 2) (V "b") (TopConst))) +(let t16 (Ass (V "ten") (Const (I 10)))) +(let t17 (RProg (L 1) t16)) +(let prop4 (= t17 t17)) +(let prf11 (Fiat (= t16 (Prog (L 1))))) +(let prf12 (Sym (= (Prog (L 1)) t16) prf11)) +(let t18 + (const-prop + (L 1) + (V "b") + (TopConst))) +(let t19 + (Ass + (V "b") + (Const (TopConst)))) +(let t20 (RProg (L 0) t19)) +(let prop5 (= t20 t20)) +(let prf13 + (Fiat + (= t19 (Prog (L 0))))) +(let prf14 + (Sym + (= (Prog (L 0)) t19) + prf13)) +(let prf15 (Fiat (= (TopConst) (TopConst)))) +(let prf16 (Fiat (= () ()))) +(let t21 (e (Const (I 10)))) +(let prf17 + (Congr + prop0 + (Congr + (= t5 (RProg (L 5) (Prog (L 5)))) + (Rule + prop0 + (name + "(rule ((= (Prog l) (If b l1 l2)) + (= $Top (const-prop l b))) + ((RProg l (If b l1 l2))) + )") + (premises + prf2 + (Rule + (= t6 t6) + (name + "(rule ((RProg (L li) (Ass (V x) e)) + (= val (const-prop (L li) (V y))) + (!= x y)) + ((set (const-prop (L (+ li 1)) (V y)) val)) + )") + (premises + prf5 + (Rule + (= t9 t9) + (name + "(rule ((RProg (L li) (Ass (V x) e)) + (= val (const-prop (L li) (V y))) + (!= x y)) + ((set (const-prop (L (+ li 1)) (V y)) val)) + )") + (premises + prf8 + (Rule + (= t12 t12) + (name + "(rule ((RProg (L li) (Ass (V x) e)) + (= val (const-prop (L li) (V y))) + (!= x y)) + ((set (const-prop (L (+ li 1)) (V y)) val)) + )") + (premises + (Congr + prop3 + (Congr + (= t14 (RProg (L 2) (Prog (L 2)))) + (Rule + prop3 + (name + "(rule ((= (Prog l) (Ass x (Const val)))) + ((RProg l (Ass x (Const val)))) + )") + (premises prf10) + (substitution + (val (I 1)) + (l (L 2)) + (x (V "one")))) + prf9 + 1) + prf10 + 1) + (Rule + (= t15 t15) + (name + "(rule ((RProg (L li) (Ass (V x) e)) + (= val (const-prop (L li) (V y))) + (!= x y)) + ((set (const-prop (L (+ li 1)) (V y)) val)) + )") + (premises + (Congr + prop4 + (Congr + (= t17 (RProg (L 1) (Prog (L 1)))) + (Rule + prop4 + (name + "(rule ((= (Prog l) (Ass x (Const val)))) + ((RProg l (Ass x (Const val)))) + )") + (premises prf12) + (substitution + (val (I 10)) + (l (L 1)) + (x (V "ten")))) + prf11 + 1) + prf12 + 1) + (Rule + (= t18 t18) + (name + "(rule ((RProg (L li) (Ass x (Const k)))) + ((set (const-prop (L (+ li 1)) x) k)) + )") + (premises + (Congr + prop5 + (Congr + (= + t20 + (RProg (L 0) (Prog (L 0)))) + (Rule + prop5 + (name + "(rule ((= (Prog l) (Ass x (Const val)))) + ((RProg l (Ass x (Const val)))) + )") + (premises prf14) + (substitution + (val (TopConst)) + (l (L 0)) + (x (V "b")))) + prf13 + 1) + prf14 + 1)) + (substitution + (li 0) + (x (V "b")) + (k (TopConst)))) + prf15 + prf16) + (substitution + t21 + (y "b") + (li 1) + (@n4 (TopConst)) + (x "ten") + (val (TopConst)))) + prf15 + prf16) + (substitution + (e (Const (I 1))) + (y "b") + (li 2) + (@n4 (TopConst)) + (x "one") + (val (TopConst)))) + prf15 + prf16) + (substitution + (e (Const (I 0))) + (y "b") + (li 3) + (@n4 (TopConst)) + (x "zero") + (val (TopConst)))) + prf15 + prf16) + (substitution + t21 + (y "b") + (li 4) + (@n4 (TopConst)) + (x "x") + (val (TopConst)))) + prf15) + (substitution + (l1 (L 6)) + (l (L 5)) + (l2 (L 13)) + (@n21 (TopConst)) + (b (V "b")))) + prf1 + 1) + prf2 + 1)) +(let t22 (const-prop (L 5) (V "x") (I 10))) +(let prf18 (Fiat (= (I 10) (I 10)))) +(let prf19 + (Rule + (= t3 t3) + (name + "(rule ((RProg l (If b l1 l2)) + (= val (const-prop l x))) + ((set (const-prop l1 x) val) + (set (const-prop l2 x) val)) + )") + (premises + prf17 + (Rule + (= t22 t22) + (name + "(rule ((RProg (L li) (Ass x (Const k)))) + ((set (const-prop (L (+ li 1)) x) k)) + )") + (premises prf5) + (substitution (li 4) (x (V "x")) (k (I 10)))) + prf18) + (substitution + (l1 (L 6)) + (x (V "x")) + (l (L 5)) + (l2 (L 13)) + (val (I 10)) + (b (V "b")) + (@n18 (I 10))))) +(let t23 (const-prop (L 13) (V "zero") (I 0))) +(let t24 (const-prop (L 5) (V "zero") (I 0))) +(let t25 (const-prop (L 4) (V "zero") (I 0))) +(let prf20 (Fiat (= (I 0) (I 0)))) +(let prf21 + (Rule + (= t23 t23) + (name + "(rule ((RProg l (If b l1 l2)) + (= val (const-prop l x))) + ((set (const-prop l1 x) val) + (set (const-prop l2 x) val)) + )") + (premises + prf17 + (Rule + (= t24 t24) + (name + "(rule ((RProg (L li) (Ass (V x) e)) + (= val (const-prop (L li) (V y))) + (!= x y)) + ((set (const-prop (L (+ li 1)) (V y)) val)) + )") + (premises + prf5 + (Rule + (= t25 t25) + (name + "(rule ((RProg (L li) (Ass x (Const k)))) + ((set (const-prop (L (+ li 1)) x) k)) + )") + (premises prf8) + (substitution (li 3) (x (V "zero")) (k (I 0)))) + prf20 + prf16) + (substitution + t21 + (y "zero") + (li 4) + (@n4 (I 0)) + (x "x") + (val (I 0)))) + prf20) + (substitution + (l1 (L 6)) + (x (V "zero")) + (l (L 5)) + (l2 (L 13)) + (val (I 0)) + (b (V "b")) + (@n18 (I 0))))) +(let t26 (add-val (I 10) (I 0))) +(Rule + (= (@ExistsConstructor) (@ExistsConstructor)) + (name "@prove_exists_rule") + (premises + (Rule + (= t0 t0) + (name + "(rule ((RProg (L li) (Ass x (Const k)))) + ((set (const-prop (L (+ li 1)) x) k)) + )") + (premises + (Rule + (= t1 t1) + (name + "(rule ((= (Prog l) (Ass x (Add x1 x2))) + (= (I val) (add-val (const-prop l x1) (const-prop l x2)))) + ((RProg l (Ass x (Const (I val))))) + )") + (premises + prf0 + prf19 + prf21 + (Sym + (= (I 10) t26) + (Rule + (= t26 (I 10)) + (name "(rewrite (add-val (I x) (I y)) (I (+ x y)))") + (premises + (Rule + (= t26 t26) + (name + "(rule ((= (Prog l) (Ass x (Add x1 x2))) + (= v1 (const-prop l x1)) + (= v2 (const-prop l x2))) + ((add-val v1 v2)) + )") + (premises prf0 prf19 prf18 prf21 prf20) + (substitution + (@n5 (I 10)) + (v2 (I 0)) + (x1 (V "x")) + (x2 (V "zero")) + (l (L 13)) + (@n6 (I 0)) + (x (V "y")) + (v1 (I 10))))) + (substitution (@rewrite_var__14 t26) (x 10) (y 0))))) + (substitution + (x1 (V "x")) + (x2 (V "zero")) + (l (L 13)) + (@n9 (I 10)) + (@n10 (I 0)) + (val 10) + (x (V "y"))))) + (substitution (li 13) (x (V "y")) (k (I 10)))) + prf18) + (substitution (@n23 (I 10)))) diff --git a/egglog/tests/snapshots/files__proof_manual_disabled_files.snap b/egglog/tests/snapshots/files__proof_manual_disabled_files.snap new file mode 100644 index 0000000..cfee75a --- /dev/null +++ b/egglog/tests/snapshots/files__proof_manual_disabled_files.snap @@ -0,0 +1,7 @@ +--- +source: egglog/tests/files.rs +expression: "snapshot.join(\"\\n\")" +--- +eggcc-2mm.egg: uses :no-merge declarations such as DUMMYCTX; proof encoding requires a merge function +subsume-relation.egg: proof-testing rewrites a check on a subsumed relation row into a prove query that no longer matches +subsume.egg: proof-testing rewrites a check on a subsumed expression into a prove query that no longer matches diff --git a/egglog/tests/snapshots/files__proof_unsupported_files.snap b/egglog/tests/snapshots/files__proof_unsupported_files.snap index 190f045..13d42f9 100644 --- a/egglog/tests/snapshots/files__proof_unsupported_files.snap +++ b/egglog/tests/snapshots/files__proof_unsupported_files.snap @@ -12,7 +12,6 @@ container-fail.egg container-rebuild.egg cyk.egg cykjson.egg -datatypes.egg delete.egg eggcc-2mm.egg eggcc-extraction.egg @@ -38,18 +37,15 @@ math.egg merge_read.egg multiset.egg naive-action-lookup.egg -nested-container-dirty-propagation.egg pair.egg prims.egg print-function.egg python_array_optimize.egg rat-pow-eval.egg -repro-665-set-union.egg repro-738-fn-sort.egg repro-desugar-143.egg repro-herbie-vanilla.egg repro-new-backend-python-vec.egg -repro-querybug3.egg repro-unsound.egg repro-vec-unequal.egg set.egg @@ -59,7 +55,6 @@ string_quotes.egg taylor51.egg towers-of-hanoi.egg tricky-type-checking.egg -type-constraints-tests.egg typed_primitive_unstable_app.egg typeinfer.egg uf-extraction.egg diff --git a/egglog/tests/snapshots/files__shared_snapshot_container_proofs.snap b/egglog/tests/snapshots/files__shared_snapshot_container_proofs.snap new file mode 100644 index 0000000..9a3d792 --- /dev/null +++ b/egglog/tests/snapshots/files__shared_snapshot_container_proofs.snap @@ -0,0 +1,24 @@ +--- +source: tests/files.rs +assertion_line: 88 +expression: snapshot_content_across_treatments +--- +((HasElem 2) + (HasMS 1) + (HasMap 1) + (HasPair 1) + (HasSet 1) + (HasVec 1) + (MSLen 1) + (MapGet 1) + (MapLen 1) + (OutWrap 1) + (PFirst 1) + (QSame 2) + (QVecGet 2) + (QVecLen 1) + (S 1) + (VGet 1) + (VLen 1) + (WrapVec 1) + (Z 1)) diff --git a/egglog/tests/snapshots/files__shared_snapshot_container_set_collapse.snap b/egglog/tests/snapshots/files__shared_snapshot_container_set_collapse.snap new file mode 100644 index 0000000..78bf588 --- /dev/null +++ b/egglog/tests/snapshots/files__shared_snapshot_container_set_collapse.snap @@ -0,0 +1,41 @@ +--- +source: tests/files.rs +assertion_line: 88 +expression: snapshot_content_across_treatments +--- +(let prf0 (Fiat (= (B) (A)))) +(let t0 (Holds (set-of (A) (B)))) +(let prf1 + (Congr + (= t0 (Holds (set-of (A)))) + (Fiat (= t0 t0)) + (ContainerNormalize + (= (set-of (A) (B)) (set-of (A))) + (Congr + (= (set-of (A) (B)) (set-of (A) (A))) + (Fiat (= (set-of (A) (B)) (set-of (A) (B)))) + prf0 + 1)) + 0)) +(Rule + (= (@ExistsConstructor) (@ExistsConstructor)) + (name "@prove_exists_rule") + (premises + (Fiat (= (A) (A))) + prf0 + (Eval) + prf0 + (Eval) + (Trans + (= (Holds (set-of (A))) (Holds (set-of (A)))) + (Sym (= (Holds (set-of (A))) t0) prf1) + prf1)) + (substitution + (@v34 (A)) + (@v35 (set-of (A))) + (@v36 (A)) + (@v37 (set-of (A))) + (@v33 (A)))) +((A 1) + (B 1) + (Holds 1)) diff --git a/egglog/tests/snapshots/files__shared_snapshot_rule_head_fast_path.snap b/egglog/tests/snapshots/files__shared_snapshot_rule_head_fast_path.snap index d03c042..4a5666b 100644 --- a/egglog/tests/snapshots/files__shared_snapshot_rule_head_fast_path.snap +++ b/egglog/tests/snapshots/files__shared_snapshot_rule_head_fast_path.snap @@ -1,8 +1,14 @@ --- -source: tests/files.rs -assertion_line: 88 +source: egglog/tests/files.rs expression: snapshot_content_across_treatments --- +(Sym + (= (A) (B)) + (Rule + (= (B) (A)) + (name "direct-union-with-heavy-tail") + (premises (Fiat (= (Trigger) (Trigger)))) + (substitution))) ((A 1) (B 1) (Pair 29) diff --git a/test_bench.py b/test_bench.py index ecc67de..de7ee01 100644 --- a/test_bench.py +++ b/test_bench.py @@ -241,6 +241,39 @@ def test_parse_treatments_rejects_duplicates() -> None: bench.parse_treatments("off,term,off") +def test_validate_spec_rejects_executable_prove_benchmark_file(tmp_path: Path) -> None: + prove_file = tmp_path / "prove.egg" + prove_file.write_text( + "; comments may mention (prove ...)\n(datatype Expr)\n(prove (Fact))\n", + encoding="utf-8", + ) + spec = bench.BenchmarkSpec( + files=bench.resolve_files([str(prove_file)], tmp_path), + treatments=("off", "term", "proofs"), + rounds=1, + timeout_sec=120, + ) + + with pytest.raises(ValueError, match="explicit prove command"): + bench.validate_spec(spec) + + +def test_validate_spec_allows_prove_mentions_in_comments(tmp_path: Path) -> None: + check_file = tmp_path / "check.egg" + check_file.write_text( + "; comments may mention (prove ...)\n(datatype Expr)\n(check (Fact))\n", + encoding="utf-8", + ) + spec = bench.BenchmarkSpec( + files=bench.resolve_files([str(check_file)], tmp_path), + treatments=("off", "term", "proofs"), + rounds=1, + timeout_sec=120, + ) + + bench.validate_spec(spec) + + def test_estimate_model_is_exact_only_and_updates_from_successful_processes() -> None: rows = make_rows( make_record(0, started_at="2026-07-04T12:00:00Z", wall_sec=2.0),