This repository has been archived by the owner on May 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
36 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.aya.base.core; | ||
|
||
import org.aya.base.generic.LocalVar; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public record AppTerm(@NotNull Term fun, @NotNull Term arg) implements Term { | ||
@Override public @NotNull Term bindAt(@NotNull LocalVar var, int depth) { | ||
return new AppTerm(fun.bindAt(var, depth), arg.bindAt(var, depth)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.aya.base.core; | ||
|
||
import org.aya.base.generic.LocalVar; | ||
import org.aya.util.error.SourcePos; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class BindTest { | ||
@Test public void simpleBind() { | ||
// λx. λy. x y | ||
var x = new LocalVar("x", SourcePos.NONE); | ||
var y = new LocalVar("y", SourcePos.NONE); | ||
var body = new AppTerm(new FreeTerm(x), new FreeTerm(y)); | ||
var lamYXY = new LamTerm(body.bind(y)); | ||
var lamXYXY = new LamTerm(lamYXY.bind(x)); | ||
// λ. λ. 1 0 | ||
var expect = new LamTerm(new LamTerm(new AppTerm(new LocalTerm(1), new LocalTerm(0)))); | ||
assertEquals(expect, lamXYXY); | ||
} | ||
} |