Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions abstract_syntax/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,19 @@ def loc_prefix(loc: Meta | None) -> str:
'Post-typecheck AST sanity check failed: pre-uniquify `Var` '
'nodes still present.\n' + '\n'.join(msgs))

def _statement_scope(stmt: Statement, seen: dict[str, int]) -> str:
"""The scope segment of a top-level statement: its name (or, if it
has none, its keyword, e.g. ``assert``), then how many earlier
statements had the same, so ``theorem foo`` is ``3foo_`` and a second
``foo`` is ``3foo1_``. The length prefix keeps segments, and the
scopes made by nesting them (an import's module inside the import),
distinct from each other."""
name = getattr(stmt, 'name', None)
key = name if isinstance(name, str) else type(stmt).__name__.lower()
k = seen.get(key, 0)
seen[key] = k + 1
return str(len(key)) + key + (str(k) if k else '') + '_'

def uniquify_deduce(ast: Sequence[Statement], ctx: UniquifyContext) -> list[Statement]:
"""Uniquify ``ast`` against ``ctx``'s counter, returning the
post-uniquify AST.
Expand All @@ -306,13 +319,14 @@ def uniquify_deduce(ast: Sequence[Statement], ctx: UniquifyContext) -> list[Stat
prelude names. Tests typically pass a fresh context for
reproducibility.

Each top-level statement gets its own scope segment (``"sN_"``
appended to the caller's scope, ``name_id`` reset to ``0``) so
edits confined to statement *N* don't perturb the bound-name
suffixes in statement *M > N*. That edit-invariance is what
Phase-3 Step 14's dependency-aware cache invalidation relies on
-- without it, the structural hash of every downstream statement
drifts on every edit and the cache is useless.
Each top-level statement gets its own scope segment (see
``_statement_scope``, appended to the caller's scope, ``name_id``
reset to ``0``), named after the statement rather than its position,
so neither an edit inside one statement nor inserting or deleting
one perturbs the names in the others. That is what the
per-statement caches (``checker_cache``) rely on -- without it, the
structural hash of every downstream statement drifts and the caches
miss (#1303).
"""
env: dict[str, object] = {}
env['≠'] = ['≠']
Expand All @@ -322,8 +336,9 @@ def uniquify_deduce(ast: Sequence[Statement], ctx: UniquifyContext) -> list[Stat
outer_scope = ctx.scope
outer_name_id = ctx.name_id
result: list[Statement] = []
for i, stmt in enumerate(ast):
ctx.scope = outer_scope + 's' + str(i) + '_'
seen: dict[str, int] = {}
for stmt in ast:
ctx.scope = outer_scope + _statement_scope(stmt, seen)
ctx.name_id = 0
result.append(stmt.uniquify(env, ctx))
# Restore the caller's scope/counter -- the per-statement reset is
Expand Down
41 changes: 22 additions & 19 deletions checker_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,28 @@ def _collect_defined_names(stmt: Statement) -> set[str]:
return names


def _is_global_barrier(stmt: Statement) -> bool:
"""Statements with global side-effects on later checking.
# Statements whose effect on checking other statements goes only
# through the names they define. Every other kind is a barrier: views
# and models are found by type, associativity by operator and type,
# imports bring in whole modules, and so on.
_NAME_ONLY_STATEMENTS = (
Assert, Define, GenRecFun, Postulate, PostulateFun, PostulateType,
Predicate, Print, RecFun, Theorem, TypeAlias, Union, ViewRecFun,
)

``Import`` brings a module's exports into the environment;
``Auto`` registers a rewrite rule consulted by every later
proof. Conservatively treat both as a barrier: every later
statement implicitly depends on them, so editing or removing
one invalidates the cache for everything after. So are concepts
and models (#1264): a where formula names its concepts by string,
and a model is found by its concept and type, never by name."""
return isinstance(stmt, (Import, Auto, ConceptDecl, ModelDecl))

def _is_global_barrier(stmt: Statement) -> bool:
"""Statements with global side-effects on later checking: every
statement except those whose effect goes only through the names they
define (``_NAME_ONLY_STATEMENTS``). ``Import`` brings in a module's
exports, ``Auto`` registers a rewrite rule consulted by every later
proof, ``inductive`` an induction principle, concepts and models are
found by concept and type (#1264), views by type, and so on. Every
later statement implicitly depends on them, so editing or removing
one invalidates the cache for everything after. (Since #1303 removing
a statement no longer renames the ones after it, so this is what
invalidates them.)"""
return not isinstance(stmt, _NAME_ONLY_STATEMENTS)


# ---------------------------------------------------------------------------
Expand All @@ -280,14 +291,6 @@ def _is_global_barrier(stmt: Statement) -> bool:
_TypeCheckEntry = tuple[int, tuple[int, int], Statement]
_type_check_cache: dict[str, dict[tuple[int, int], _TypeCheckEntry]] = {}

# Statements whose effect on type checking other statements goes only
# through the names they define. Every other kind is a barrier: views
# and models are found by type, associativity by operator and type,
# imports bring in whole modules, and so on.
_NAME_ONLY_STATEMENTS = (
Assert, Define, GenRecFun, Postulate, PostulateFun, PostulateType,
Predicate, Print, RecFun, Theorem, TypeAlias, Union, ViewRecFun,
)

# The statements whose type check is cached: the ones that do real
# work in ``type_check_stmt`` and have no side effect there.
Expand All @@ -308,7 +311,7 @@ def type_check_fingerprints(stmts: list[Statement],
for n in _collect_defined_names(s):
defined_to_idx.setdefault(n, i)
barriers = hash(tuple(h for s, h in zip(stmts, hashes)
if not isinstance(s, _NAME_ONLY_STATEMENTS)))
if _is_global_barrier(s)))
deps_fps: list[int] = []
full_fps: list[int] = [] # a statement's hash folded with its deps
for i, s in enumerate(stmts):
Expand Down
2 changes: 1 addition & 1 deletion docs/lsp-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Originally framed as optional ("only if 3s/check turns out to be too slow") but

- [x] **Step 14: Dependency-aware invalidation.** Walk each statement's post-uniquify AST to collect referenced names; invalidate dependents on edit.
- *Acceptance:* edit theorem `T1`; assert `T2` (which uses `T1`) is invalidated and rechecked.
- *Implementation:* `_collect_referenced_names` walks the post-uniquify AST gathering every `VarRef` / `PVar` name; `_collect_defined_names` returns the names a top-level statement introduces (its own name plus union constructors / predicate rules / synthesised induction lemmas). `check_deduce`'s third loop maintains a `defined_to_idx` map and replaces Step 13's `chain_hash` with `deps_fingerprint = hash(tuple(stmt_hashes_so_far[j] for j in sorted(dep_indices)))` — only the prior statements *this* one references contribute. `Import` and `Auto` are treated as global barriers (every later statement implicitly depends on them) since they have effects observable everywhere downstream. `Auto` additionally propagates its referenced names into every later statement's dependency set, so editing an `auto`'d theorem invalidates downstream proofs that rely on the implicit rewrite without textually mentioning it. Required a foundational fix in `uniquify_deduce`: each top-level statement now gets its own `s<N>_` scope segment with `name_id` reset, so an edit confined to statement *N* no longer shifts the bound-name suffixes of statement *M > N* — without that, every downstream statement's stmt_hash drifts on every edit and the cache is useless. Acceptance test in `test/lsp/test_check_proofs_cache.py::test_editing_T1_invalidates_T2_that_uses_it`; complement test pins the negative direction (unrelated downstream stays a hit), plus an `auto`-aware test for the implicit-dep case. Known limitation tracked in [#368](https://github.com/jsiek/deduce/issues/368): `proof_checker.name_id` is still process-monotonic and can perturb stmt hashes for modules that exercise predicate desugaring / induction translation — fold it into a context object or snapshot it via the LSP state machinery.
- *Implementation:* `_collect_referenced_names` walks the post-uniquify AST gathering every `VarRef` / `PVar` name; `_collect_defined_names` returns the names a top-level statement introduces (its own name plus union constructors / predicate rules / synthesised induction lemmas). `check_deduce`'s third loop maintains a `defined_to_idx` map and replaces Step 13's `chain_hash` with `deps_fingerprint = hash(tuple(stmt_hashes_so_far[j] for j in sorted(dep_indices)))` — only the prior statements *this* one references contribute. `Import` and `Auto` are treated as global barriers (every later statement implicitly depends on them) since they have effects observable everywhere downstream. `Auto` additionally propagates its referenced names into every later statement's dependency set, so editing an `auto`'d theorem invalidates downstream proofs that rely on the implicit rewrite without textually mentioning it. Required a foundational fix in `uniquify_deduce`: each top-level statement now gets its own `s<N>_` scope segment with `name_id` reset, so an edit confined to statement *N* no longer shifts the bound-name suffixes of statement *M > N* (since #1303 the segment is named after the statement, `<len><name><count>_`, not its index *N*, so inserting or deleting a statement doesn't rename the others either; with that, every statement that is not a plain named definition became a barrier, since removing one no longer happens to invalidate everything after it) — without that, every downstream statement's stmt_hash drifts on every edit and the cache is useless. Acceptance test in `test/lsp/test_check_proofs_cache.py::test_editing_T1_invalidates_T2_that_uses_it`; complement test pins the negative direction (unrelated downstream stays a hit), plus an `auto`-aware test for the implicit-dep case. Known limitation tracked in [#368](https://github.com/jsiek/deduce/issues/368): `proof_checker.name_id` is still process-monotonic and can perturb stmt hashes for modules that exercise predicate desugaring / induction translation — fold it into a context object or snapshot it via the LSP state machinery.

## Phase 4 — Structured proof-editing operations (Agda-like)

Expand Down
16 changes: 8 additions & 8 deletions test/compile/lower/array.cir
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
union MyNat.s0_0 {zero.s0_1/0, suc.s0_2/1}
union List.s1_0 {empty.s1_2/0, node.s1_3/2}
global ns.s2_0 = node.s1_3(zero.s0_1, node.s1_3(suc.s0_2(zero.s0_1), node.s1_3(suc.s0_2(suc.s0_2(zero.s0_1)), empty.s1_2)))
global A.s3_0 = array(ns.s2_0)
print A.s3_0
print A.s3_0[zero.s0_1]
print A.s3_0[suc.s0_2(zero.s0_1)]
print A.s3_0[suc.s0_2(suc.s0_2(zero.s0_1))]
union MyNat.5MyNat_0 {zero.5MyNat_1/0, suc.5MyNat_2/1}
union List.4List_0 {empty.4List_2/0, node.4List_3/2}
global ns.2ns_0 = node.4List_3(zero.5MyNat_1, node.4List_3(suc.5MyNat_2(zero.5MyNat_1), node.4List_3(suc.5MyNat_2(suc.5MyNat_2(zero.5MyNat_1)), empty.4List_2)))
global A.1A_0 = array(ns.2ns_0)
print A.1A_0
print A.1A_0[zero.5MyNat_1]
print A.1A_0[suc.5MyNat_2(zero.5MyNat_1)]
print A.1A_0[suc.5MyNat_2(suc.5MyNat_2(zero.5MyNat_1))]
16 changes: 8 additions & 8 deletions test/compile/lower/array.ir
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
union MyNat.s0_0 {zero.s0_1/0, suc.s0_2/1}
union List.s1_0 {empty.s1_2/0, node.s1_3/2}
global ns.s2_0 = node.s1_3(zero.s0_1, node.s1_3(suc.s0_2(zero.s0_1), node.s1_3(suc.s0_2(suc.s0_2(zero.s0_1)), empty.s1_2)))
global A.s3_0 = array(ns.s2_0)
print A.s3_0
print A.s3_0[zero.s0_1]
print A.s3_0[suc.s0_2(zero.s0_1)]
print A.s3_0[suc.s0_2(suc.s0_2(zero.s0_1))]
union MyNat.5MyNat_0 {zero.5MyNat_1/0, suc.5MyNat_2/1}
union List.4List_0 {empty.4List_2/0, node.4List_3/2}
global ns.2ns_0 = node.4List_3(zero.5MyNat_1, node.4List_3(suc.5MyNat_2(zero.5MyNat_1), node.4List_3(suc.5MyNat_2(suc.5MyNat_2(zero.5MyNat_1)), empty.4List_2)))
global A.1A_0 = array(ns.2ns_0)
print A.1A_0
print A.1A_0[zero.5MyNat_1]
print A.1A_0[suc.5MyNat_2(zero.5MyNat_1)]
print A.1A_0[suc.5MyNat_2(suc.5MyNat_2(zero.5MyNat_1))]
16 changes: 8 additions & 8 deletions test/compile/lower/array.pir
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
union MyNat.s0_0 {zero.s0_1/0, suc.s0_2/1}
union List.s1_0 {empty.s1_2/0, node.s1_3/2}
global ns.s2_0 = node.s1_3(zero.s0_1, node.s1_3(suc.s0_2(zero.s0_1), node.s1_3(suc.s0_2(suc.s0_2(zero.s0_1)), empty.s1_2)))
global A.s3_0 = array(ns.s2_0)
print A.s3_0
print A.s3_0[zero.s0_1]
print A.s3_0[suc.s0_2(zero.s0_1)]
print A.s3_0[suc.s0_2(suc.s0_2(zero.s0_1))]
union MyNat.5MyNat_0 {zero.5MyNat_1/0, suc.5MyNat_2/1}
union List.4List_0 {empty.4List_2/0, node.4List_3/2}
global ns.2ns_0 = node.4List_3(zero.5MyNat_1, node.4List_3(suc.5MyNat_2(zero.5MyNat_1), node.4List_3(suc.5MyNat_2(suc.5MyNat_2(zero.5MyNat_1)), empty.4List_2)))
global A.1A_0 = array(ns.2ns_0)
print A.1A_0
print A.1A_0[zero.5MyNat_1]
print A.1A_0[suc.5MyNat_2(zero.5MyNat_1)]
print A.1A_0[suc.5MyNat_2(suc.5MyNat_2(zero.5MyNat_1))]
14 changes: 7 additions & 7 deletions test/compile/lower/basic.cir
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
union MyNat.s0_0 {zero.s0_1/0, suc.s0_2/1}
fn add.s1_0($scr0, m.s1_1) = match $scr0 { | zero.s0_1 -> m.s1_1 | suc.s0_2(n.s1_2) -> suc.s0_2(add.s1_0(n.s1_2, m.s1_1)) }
global two.s2_0 = suc.s0_2(suc.s0_2(zero.s0_1))
fn add_two.s3_1(x.s3_0) = add.s1_0(two.s2_0, x.s3_0)
fn pick.s4_3(b.s4_0, x.s4_1, y.s4_2) = if b.s4_0 then x.s4_1 else y.s4_2
print add_two.s3_1(suc.s0_2(zero.s0_1))
print pick.s4_3(true, two.s2_0, zero.s0_1)
union MyNat.5MyNat_0 {zero.5MyNat_1/0, suc.5MyNat_2/1}
fn add.3add_0($scr0, m.3add_1) = match $scr0 { | zero.5MyNat_1 -> m.3add_1 | suc.5MyNat_2(n.3add_2) -> suc.5MyNat_2(add.3add_0(n.3add_2, m.3add_1)) }
global two.3two_0 = suc.5MyNat_2(suc.5MyNat_2(zero.5MyNat_1))
fn add_two.7add_two_1(x.7add_two_0) = add.3add_0(two.3two_0, x.7add_two_0)
fn pick.4pick_3(b.4pick_0, x.4pick_1, y.4pick_2) = if b.4pick_0 then x.4pick_1 else y.4pick_2
print add_two.7add_two_1(suc.5MyNat_2(zero.5MyNat_1))
print pick.4pick_3(true, two.3two_0, zero.5MyNat_1)
14 changes: 7 additions & 7 deletions test/compile/lower/basic.ir
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
union MyNat.s0_0 {zero.s0_1/0, suc.s0_2/1}
fn add.s1_0($scr0, m.s1_1) = match $scr0 { | zero.s0_1 -> m.s1_1 | suc.s0_2(n.s1_2) -> suc.s0_2(add.s1_0(n.s1_2, m.s1_1)) }
global two.s2_0 = suc.s0_2(suc.s0_2(zero.s0_1))
fn add_two.s3_1(x.s3_0) = add.s1_0(two.s2_0, x.s3_0)
fn pick.s4_3(b.s4_0, x.s4_1, y.s4_2) = if b.s4_0 then x.s4_1 else y.s4_2
print add_two.s3_1(suc.s0_2(zero.s0_1))
print pick.s4_3(true, two.s2_0, zero.s0_1)
union MyNat.5MyNat_0 {zero.5MyNat_1/0, suc.5MyNat_2/1}
fn add.3add_0($scr0, m.3add_1) = match $scr0 { | zero.5MyNat_1 -> m.3add_1 | suc.5MyNat_2(n.3add_2) -> suc.5MyNat_2(add.3add_0(n.3add_2, m.3add_1)) }
global two.3two_0 = suc.5MyNat_2(suc.5MyNat_2(zero.5MyNat_1))
fn add_two.7add_two_1(x.7add_two_0) = add.3add_0(two.3two_0, x.7add_two_0)
fn pick.4pick_3(b.4pick_0, x.4pick_1, y.4pick_2) = if b.4pick_0 then x.4pick_1 else y.4pick_2
print add_two.7add_two_1(suc.5MyNat_2(zero.5MyNat_1))
print pick.4pick_3(true, two.3two_0, zero.5MyNat_1)
14 changes: 7 additions & 7 deletions test/compile/lower/basic.pir
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
union MyNat.s0_0 {zero.s0_1/0, suc.s0_2/1}
fn add.s1_0($scr0, m.s1_1) = match $scr0 { | zero.s0_1 -> m.s1_1 | suc.s0_2(n.s1_2) -> suc.s0_2(add.s1_0(n.s1_2, m.s1_1)) }
global two.s2_0 = suc.s0_2(suc.s0_2(zero.s0_1))
fn add_two.s3_1(x.s3_0) = add.s1_0(two.s2_0, x.s3_0)
fn pick.s4_3(b.s4_0, x.s4_1, y.s4_2) = if b.s4_0 then x.s4_1 else y.s4_2
print add_two.s3_1(suc.s0_2(zero.s0_1))
print pick.s4_3(true, two.s2_0, zero.s0_1)
union MyNat.5MyNat_0 {zero.5MyNat_1/0, suc.5MyNat_2/1}
fn add.3add_0($scr0, m.3add_1) = match $scr0 { | zero.5MyNat_1 -> m.3add_1 | suc.5MyNat_2(n.3add_2) -> suc.5MyNat_2(add.3add_0(n.3add_2, m.3add_1)) }
global two.3two_0 = suc.5MyNat_2(suc.5MyNat_2(zero.5MyNat_1))
fn add_two.7add_two_1(x.7add_two_0) = add.3add_0(two.3two_0, x.7add_two_0)
fn pick.4pick_3(b.4pick_0, x.4pick_1, y.4pick_2) = if b.4pick_0 then x.4pick_1 else y.4pick_2
print add_two.7add_two_1(suc.5MyNat_2(zero.5MyNat_1))
print pick.4pick_3(true, two.3two_0, zero.5MyNat_1)
10 changes: 5 additions & 5 deletions test/compile/lower/closure.cir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
union MyNat.s0_0 {zero.s0_1/0, suc.s0_2/1}
fn add.s1_0($scr0, m.s1_1) = match $scr0 { | zero.s0_1 -> m.s1_1 | suc.s0_2(n.s1_2) -> suc.s0_2(add.s1_0(n.s1_2, m.s1_1)) }
fn adder.s2_2(x.s2_0) = closure[closure$lam1](x.s2_0)
print adder.s2_2(suc.s0_2(zero.s0_1))(suc.s0_2(suc.s0_2(zero.s0_1)))
fn closure$lam1[x.s2_0](y.s2_1) = add.s1_0(x.s2_0, y.s2_1)
union MyNat.5MyNat_0 {zero.5MyNat_1/0, suc.5MyNat_2/1}
fn add.3add_0($scr0, m.3add_1) = match $scr0 { | zero.5MyNat_1 -> m.3add_1 | suc.5MyNat_2(n.3add_2) -> suc.5MyNat_2(add.3add_0(n.3add_2, m.3add_1)) }
fn adder.5adder_2(x.5adder_0) = closure[closure$lam1](x.5adder_0)
print adder.5adder_2(suc.5MyNat_2(zero.5MyNat_1))(suc.5MyNat_2(suc.5MyNat_2(zero.5MyNat_1)))
fn closure$lam1[x.5adder_0](y.5adder_1) = add.3add_0(x.5adder_0, y.5adder_1)
8 changes: 4 additions & 4 deletions test/compile/lower/closure.ir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
union MyNat.s0_0 {zero.s0_1/0, suc.s0_2/1}
fn add.s1_0($scr0, m.s1_1) = match $scr0 { | zero.s0_1 -> m.s1_1 | suc.s0_2(n.s1_2) -> suc.s0_2(add.s1_0(n.s1_2, m.s1_1)) }
fn adder.s2_2(x.s2_0) = λ(y.s2_1). add.s1_0(x.s2_0, y.s2_1)
print adder.s2_2(suc.s0_2(zero.s0_1))(suc.s0_2(suc.s0_2(zero.s0_1)))
union MyNat.5MyNat_0 {zero.5MyNat_1/0, suc.5MyNat_2/1}
fn add.3add_0($scr0, m.3add_1) = match $scr0 { | zero.5MyNat_1 -> m.3add_1 | suc.5MyNat_2(n.3add_2) -> suc.5MyNat_2(add.3add_0(n.3add_2, m.3add_1)) }
fn adder.5adder_2(x.5adder_0) = λ(y.5adder_1). add.3add_0(x.5adder_0, y.5adder_1)
print adder.5adder_2(suc.5MyNat_2(zero.5MyNat_1))(suc.5MyNat_2(suc.5MyNat_2(zero.5MyNat_1)))
10 changes: 5 additions & 5 deletions test/compile/lower/closure.pir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
union MyNat.s0_0 {zero.s0_1/0, suc.s0_2/1}
fn add.s1_0($scr0, m.s1_1) = match $scr0 { | zero.s0_1 -> m.s1_1 | suc.s0_2(n.s1_2) -> suc.s0_2(add.s1_0(n.s1_2, m.s1_1)) }
fn adder.s2_2(x.s2_0) = closure[closure$lam1](x.s2_0)
print adder.s2_2(suc.s0_2(zero.s0_1))(suc.s0_2(suc.s0_2(zero.s0_1)))
fn closure$lam1[x.s2_0](y.s2_1) = add.s1_0(x.s2_0, y.s2_1)
union MyNat.5MyNat_0 {zero.5MyNat_1/0, suc.5MyNat_2/1}
fn add.3add_0($scr0, m.3add_1) = match $scr0 { | zero.5MyNat_1 -> m.3add_1 | suc.5MyNat_2(n.3add_2) -> suc.5MyNat_2(add.3add_0(n.3add_2, m.3add_1)) }
fn adder.5adder_2(x.5adder_0) = closure[closure$lam1](x.5adder_0)
print adder.5adder_2(suc.5MyNat_2(zero.5MyNat_1))(suc.5MyNat_2(suc.5MyNat_2(zero.5MyNat_1)))
fn closure$lam1[x.5adder_0](y.5adder_1) = add.3add_0(x.5adder_0, y.5adder_1)
12 changes: 6 additions & 6 deletions test/compile/lower/generic.cir
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
union Box.s0_0 {box.s0_2/1}
fn unbox.s1_3(b.s1_1) = match b.s1_1 { | box.s0_2(x.s1_2) -> x.s1_2 }
fn id.s2_3(x.s2_2) = x.s2_2
union MyNat.s3_0 {zero.s3_1/0, suc.s3_2/1}
print id.s2_3(suc.s3_2(zero.s3_1))
print unbox.s1_3(box.s0_2(suc.s3_2(suc.s3_2(zero.s3_1))))
union Box.3Box_0 {box.3Box_2/1}
fn unbox.5unbox_3(b.5unbox_1) = match b.5unbox_1 { | box.3Box_2(x.5unbox_2) -> x.5unbox_2 }
fn id.2id_3(x.2id_2) = x.2id_2
union MyNat.5MyNat_0 {zero.5MyNat_1/0, suc.5MyNat_2/1}
print id.2id_3(suc.5MyNat_2(zero.5MyNat_1))
print unbox.5unbox_3(box.3Box_2(suc.5MyNat_2(suc.5MyNat_2(zero.5MyNat_1))))
12 changes: 6 additions & 6 deletions test/compile/lower/generic.ir
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
union Box.s0_0 {box.s0_2/1}
fn unbox.s1_3(b.s1_1) = match b.s1_1 { | box.s0_2(x.s1_2) -> x.s1_2 }
fn id.s2_3(x.s2_2) = x.s2_2
union MyNat.s3_0 {zero.s3_1/0, suc.s3_2/1}
print id.s2_3(suc.s3_2(zero.s3_1))
print unbox.s1_3(box.s0_2(suc.s3_2(suc.s3_2(zero.s3_1))))
union Box.3Box_0 {box.3Box_2/1}
fn unbox.5unbox_3(b.5unbox_1) = match b.5unbox_1 { | box.3Box_2(x.5unbox_2) -> x.5unbox_2 }
fn id.2id_3(x.2id_2) = x.2id_2
union MyNat.5MyNat_0 {zero.5MyNat_1/0, suc.5MyNat_2/1}
print id.2id_3(suc.5MyNat_2(zero.5MyNat_1))
print unbox.5unbox_3(box.3Box_2(suc.5MyNat_2(suc.5MyNat_2(zero.5MyNat_1))))
12 changes: 6 additions & 6 deletions test/compile/lower/generic.pir
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
union Box.s0_0 {box.s0_2/1}
fn unbox.s1_3(b.s1_1) = match b.s1_1 { | box.s0_2(x.s1_2) -> x.s1_2 }
fn id.s2_3(x.s2_2) = x.s2_2
union MyNat.s3_0 {zero.s3_1/0, suc.s3_2/1}
print id.s2_3(suc.s3_2(zero.s3_1))
print unbox.s1_3(box.s0_2(suc.s3_2(suc.s3_2(zero.s3_1))))
union Box.3Box_0 {box.3Box_2/1}
fn unbox.5unbox_3(b.5unbox_1) = match b.5unbox_1 { | box.3Box_2(x.5unbox_2) -> x.5unbox_2 }
fn id.2id_3(x.2id_2) = x.2id_2
union MyNat.5MyNat_0 {zero.5MyNat_1/0, suc.5MyNat_2/1}
print id.2id_3(suc.5MyNat_2(zero.5MyNat_1))
print unbox.5unbox_3(box.3Box_2(suc.5MyNat_2(suc.5MyNat_2(zero.5MyNat_1))))
Loading
Loading