This commit is contained in:
Felipe g 2022-09-17 10:16:20 -03:00
parent c55d3eea8b
commit 1e8b0024e3
25 changed files with 2462 additions and 5380 deletions

3
.gitignore vendored
View File

@ -1,2 +1 @@
/target
/tmp
target

951
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,11 @@
[package]
name = "kind2"
version = "0.2.76"
edition = "2021"
description = "A pure functional functional language that uses the HVM."
repository = "https://github.com/Kindelia/Kind2"
license = "MIT"
keywords = ["functional", "language", "type-theory", "proof-assistant"]
[workspace]
members = [
"compiler/kind2",
"compiler/log",
"compiler/book",
#"compiler/driver",
"compiler/parser",
#"compiler/adjuster",
]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
hvm = "0.1.81"
#hvm = { path = "../hvm" }
highlight_error = "0.1.1"
clap = { version = "3.1.8", features = ["derive"] }
rand = "0.8.5"
[profile.release.package]

View File

@ -1,78 +0,0 @@
Kind2
=====
**Kind2** is a **functional programming language** and **proof assistant**.
It is a complete rewrite of [Kind1](https://github.com/kindelia/kind-legacy), based on
[HVM](https://github.com/kindelia/hvm), a **lazy**, **non-garbage-collected** and **massively parallel** virtual
machine. In [our benchmarks](https://github.com/kindelia/functional-benchmarks), its type-checker outperforms every
alternative proof assistant by a far margin, and its programs can offer exponential speedups over Haskell's GHC. Kind2
unleashes the [inherent parallelism of the Lambda
Calculus](https://github.com/VictorTaelin/Symmetric-Interaction-Calculus) to become the ultimate programming language of
the next century.
**Welcome to the inevitable parallel, functional future of computers!**
Examples
--------
Pure functions are defined via equations, as in [Haskell](https://www.haskell.org/):
```javascript
// Applies a function to every element of a list
map <a> <b> (list: List a) (f: a -> b) : List b
map a b Nil f = Nil
map a b (Cons head tail) f = Cons (f x) (map tail f)
```
Side-effective programs are written via monadic monads, resembling [Rust](https://www.rust-lang.org/) and [TypeScript](https://www.typescriptlang.org/):
```javascript
// Prints the double of every numbet up to a limit
Main : IO (Result () String) {
ask limit = IO.prompt "Enter limit:"
for x in (List.range limit) {
IO.print "{} * 2 = {}" x (Nat.double x)
}
return Ok ()
}
```
Theorems can be proved inductivelly, as in [Agda](https://wiki.portal.chalmers.se/agda/pmwiki.php) and [Idris](https://www.idris-lang.org/):
```javascript
// Black Friday Theorem. Proof that, for every Nat n: n * 2 / 2 == n.
black_friday_theorem (n: Nat) : Equal Nat (Nat.half (Nat.double n)) n
black_friday_theorem Nat.zero = Equal.refl
black_friday_theorem (Nat.succ n) = Equal.apply (x => Nat.succ x) (black_friday_theorem n)
```
For more examples, check the [Wikind](https://github.com/kindelia/wikind).
Usage
-----
First, install [Rust](https://www.rust-lang.org/tools/install) first, then enter:
```
cargo install kind2
```
Then, use any of the commands below:
Command | Usage | Note
---------- | ------------------------- | --------------------------------------------------------------
Check | `kind2 check file.kind2` | Checks all definitions.
Eval | `kind2 eval file.kind2` | Runs using the type-checker's evaluator.
Run | `kind2 run file.kind2` | Runs using HVM's evaluator, on Rust-mode.
To-HVM | `kind2 to-hvm file.kind2` | Generates a [.hvm](https://github.com/kindelia/hvm) file. Can then be compiled to C.
To-KDL | `kind2 to-kdl file.kind2` | Generates a [.kdl](https://github.com/kindelia/kindelia) file. Can then be deployed to [Kindelia](https://github.com/kindelia/kindelia).
Executables can be generated via HVM:
```
kind2 to-hvm file.kind2
hvm compile file.hvm
clang -O2 file.c -o file
./file
```

View File

@ -1,22 +0,0 @@
#!/bin/sh
set -e
CURRENT=$(realpath .)
KIND2=$(realpath $CURRENT/target/release/kind2)
CHECKER=$(realpath ../)
#echo "Building Kind2 without the new checker.hvm"
#cargo build --release
echo "Building Kind2 type checker"
# Probably we should just use git clone in Wikind?
cd ../Wikind
#$KIND2 check Kind/TypeChecker.kind2
$KIND2 to-hvm Kind/TypeChecker.kind2 > ../Kind2/src/checker.hvm
cargo install --path $CURRENT
#cd $CURRENT
#cargo build --release

8
compiler/book/Cargo.toml Normal file
View File

@ -0,0 +1,8 @@
[package]
name = "kind2_book"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

120
compiler/book/src/lib.rs Normal file
View File

@ -0,0 +1,120 @@
// The location of things inside the source code
pub mod span;
// Description of all the terms inside the language
pub mod term;
// Types of names.
pub mod name;
use crate::term::Term;
use crate::span::Span;
use crate::name::Qualified;
use std::collections::HashMap;
use std::fmt::{Display, Error, Formatter};
// A book is a collection of entries.
#[derive(Clone, Debug)]
pub struct Book {
pub names: Vec<String>,
pub entrs: HashMap<Qualified, Box<Entry>>,
pub holes: u64,
}
// A entry describes a function that has
// rules and a type.
#[derive(Clone, Debug)]
pub struct Entry {
pub name: Qualified,
pub orig: Span,
pub kdln: Option<String>,
pub args: Vec<Box<Argument>>,
pub tipo: Box<Term>,
pub rules: Vec<Box<Rule>>
}
#[derive(Clone, Debug)]
pub struct Rule {
pub orig: Span,
pub name: Qualified,
pub pats: Vec<Box<Term>>,
pub body: Box<Term>,
}
#[derive(Clone, Debug)]
pub struct Argument {
pub hide: bool,
pub eras: bool,
pub name: String,
pub tipo: Box<Term>,
}
impl Entry {
pub fn count_implicits(&self) -> (usize, usize) {
let mut hiddens = 0;
let mut eraseds = 0;
for arg in &self.args {
if arg.hide {
hiddens = hiddens + 1;
}
if arg.eras {
eraseds = eraseds + 1;
}
}
(hiddens, eraseds)
}
}
impl Display for Rule {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
write!(f, "{}", self.name)?;
for pat in &self.pats {
write!(f, " {}", pat)?;
}
write!(f, " = {}", self.body)
}
}
impl Display for Argument {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
let (open, close) = match (self.eras, self.hide) {
(false, false) => ("(", ")"),
(false, true ) => ("+<", ">"),
(true , false) => ("-(", ")"),
(true , true ) => ("<", ">"),
};
write!(f, "{}{}: {}{}", open, self.name, &self.tipo, close)
}
}
impl Display for Entry {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
if let Some(kdln) = &self.kdln {
write!(f, "{} #{}", self.name, kdln)?
} else {
write!(f, "{}", self.name.clone())?
};
for arg in &self.args {
write!(f, " {}", arg)?;
}
write!(f, " : {}", &self.tipo)?;
for rule in &self.rules {
write!(f, "\n{}", rule)?
}
Ok(())
}
}
impl Display for Book {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
for name in &self.names {
write!(f, "{}\n", self.entrs.get(&Qualified::from_str(name)).unwrap())?;
}
Ok(())
}
}

105
compiler/book/src/name.rs Normal file
View File

@ -0,0 +1,105 @@
use std::fmt::{Display, Error, Formatter};
#[derive(Clone, Debug)]
pub struct EncodedName(u64);
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Ident(pub String);
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Qualified {
pub path: Ident,
pub name: Ident,
}
impl EncodedName {
pub fn u64_to_name(&self) -> String {
let mut name = String::new();
let mut num = self.0;
while num > 0 {
let chr = (num % 64) as u8;
let chr =
match chr {
0 => '.',
1 ..= 10 => (chr - 1 + b'0') as char,
11 ..= 36 => (chr - 11 + b'A') as char,
37 ..= 62 => (chr - 37 + b'a') as char,
63 => '_',
64 .. => panic!("impossible character value")
};
name.push(chr);
num = num / 64;
}
name.chars().rev().collect()
}
pub fn encode(name: &str) -> EncodedName {
fn char_to_u64(chr: char) -> u64 {
match chr {
'.' => 0,
'0'..='9' => 1 + chr as u64 - '0' as u64,
'A'..='Z' => 11 + chr as u64 - 'A' as u64,
'a'..='z' => 37 + chr as u64 - 'a' as u64,
'_' => 63,
_ => panic!("Invalid name character."),
}
}
let mut num: u64 = 0;
for (i, chr) in name.chars().enumerate() {
if i < 10 {
num = (num << 6) + char_to_u64(chr);
}
}
return EncodedName(num);
}
}
impl Qualified {
#[inline]
pub fn new(path: String, name: String) -> Qualified {
Qualified { path: Ident(path), name: Ident(name) }
}
#[inline]
pub fn new_raw(path: &str, name: &str) -> Qualified {
Qualified { path: Ident(path.to_string()), name: Ident(name.to_string()) }
}
#[inline]
pub fn from_str(str: &str) -> Qualified {
let mut path = str
.split(".")
.map(|x| x.to_string())
.collect::<Vec<String>>();
let name = path.pop().unwrap_or("".to_string());
Qualified { path: Ident(path.join(".")), name: Ident(name) }
}
pub fn to_string(&self) -> String {
format!("{}.{}", self.path, self.name)
}
pub fn encode(&self) -> EncodedName {
EncodedName::encode(&self.to_string())
}
}
impl Ident {
pub fn encode(&self) -> EncodedName {
EncodedName::encode(&self.0)
}
}
impl Display for Qualified {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
write!(f, "{}.{}", self.path, self.name)
}
}
impl Display for Ident {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
write!(f, "{}", self.0)
}
}

49
compiler/book/src/span.rs Normal file
View File

@ -0,0 +1,49 @@
// Module to describe exact location of things inside
// a file.
#[derive(Clone, PartialEq, Eq, Copy, Debug)]
pub struct ByteOffset(pub u32);
#[derive(Clone, PartialEq, Eq, Copy, Debug)]
pub struct FileOffset(pub u32);
#[derive(Clone, PartialEq, Eq, Copy, Debug)]
pub struct SpanData {
pub start: ByteOffset,
pub end: ByteOffset,
pub file: FileOffset,
}
#[derive(Clone, PartialEq, Eq, Copy, Debug)]
pub enum Span {
Generated,
Localized(SpanData),
}
impl Span {
#[inline]
pub fn new(start: ByteOffset, end: ByteOffset, file: FileOffset) -> Span {
Span::Localized(SpanData { start, end, file })
}
#[inline]
pub fn new_off(start: ByteOffset, end: ByteOffset) -> Span {
Span::Localized(SpanData { start, end, file: FileOffset(0) })
}
#[inline]
pub fn generated() -> Span {
Span::Generated
}
pub fn encode(&self) -> u64 {
match self {
Span::Generated => 0,
Span::Localized(data) => {
((data.file.0 as u64) << 48)
| ((data.start.0 as u64) & 0xFFFFFF)
| (((data.end.0 as u64) & 0xFFFFFF) << 24)
}
}
}
}

155
compiler/book/src/term.rs Normal file
View File

@ -0,0 +1,155 @@
// Module that describes terms and operators
// of the language
use crate::name::{Ident, Qualified};
use crate::span::Span;
use std::ascii;
use std::fmt::{Display, Error, Formatter};
#[derive(Copy, Clone, Debug)]
pub enum Operator {
Add,
Sub,
Mul,
Div,
Mod,
And,
Or,
Xor,
Shl,
Shr,
Ltn,
Lte,
Eql,
Gte,
Gtn,
Neq,
}
#[derive(Clone, Debug)]
pub enum Term {
Typ { orig: Span },
Var { orig: Span, name: Ident },
All { orig: Span, name: Ident, tipo: Box<Term>, body: Box<Term> },
Lam { orig: Span, name: Ident, body: Box<Term> },
App { orig: Span, func: Box<Term>, argm: Box<Term> },
Let { orig: Span, name: Ident, expr: Box<Term>, body: Box<Term> },
Ann { orig: Span, expr: Box<Term>, tipo: Box<Term> },
Sub { orig: Span, name: Ident, indx: u64, redx: u64, expr: Box<Term> },
Ctr { orig: Span, name: Qualified, args: Vec<Box<Term>> },
Fun { orig: Span, name: Qualified, args: Vec<Box<Term>> },
Hlp { orig: Span },
U60 { orig: Span },
Num { orig: Span, numb: u64 },
Op2 { orig: Span, oper: Operator, val0: Box<Term>, val1: Box<Term> },
Hol { orig: Span, numb: u64 },
Mat { orig: Span, tipo: Qualified, name: Ident, expr: Box<Term>, cses: Vec<(Ident,Box<Term>)>, moti: Box<Term> },
}
impl Term {
pub fn interpret_as_string(&self) -> Option<String> {
let mut text = String::new();
let mut term = self;
let string_nil = Qualified::from_str("String.nil");
let string_cons = Qualified::from_str("String.cons");
loop {
if let Term::Ctr { name, args, .. } = term {
if *name == string_cons && args.len() == 2 {
if let Term::Num { numb, .. } = *args[0] {
if ascii::escape_default(numb as u8).count() > 1 {
return None;
} else {
text.push(char::from_u32(numb as u32).unwrap_or('\0'));
term = &*args[1];
continue;
}
} else {
return None;
}
} else if *name == string_nil && args.len() == 0 {
return Some(text);
}
}
return None;
}
}
}
impl Display for Operator {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
use Operator::*;
match self {
Add => write!(f, "*"),
Sub => write!(f, "-"),
Mul => write!(f, "*"),
Div => write!(f, "/"),
Mod => write!(f, "%"),
And => write!(f, "&"),
Or => write!(f, "|"),
Xor => write!(f, "^"),
Shl => write!(f, "<<"),
Shr => write!(f, ">>"),
Ltn => write!(f, "<"),
Lte => write!(f, "<="),
Eql => write!(f, "=="),
Gte => write!(f, ">="),
Gtn => write!(f, ">"),
Neq => write!(f, "!="),
}
}
}
impl Display for Term {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
if let Some(str) = self.interpret_as_string() {
write!(f, "\"{}\"", str)
} else {
use Term::*;
match self {
Typ { orig: _ } =>
write!(f, "Type"),
Hlp { orig: _ } =>
write!(f, "?"),
U60 { orig: _ } =>
write!(f, "U60"),
Hol { orig: _, .. } =>
write!(f, "_"),
Var { orig: _, name } =>
write!(f, "{}", name),
Num { orig: _, numb } =>
write!(f, "{}", numb),
Lam { orig: _, name, body } =>
write!(f, "({} => {})", name, body),
Ann { orig: _, expr, tipo } =>
write!(f, "({} :: {})", expr, tipo),
Op2 { orig: _, oper, val0, val1 } =>
write!(f, "({} {} {})", oper, val0, val1),
All { orig: _, name, tipo, body } =>
write!(f, "(({}: {}) {})", name, tipo, body),
Let { orig: _, name, expr, body } =>
write!(f, "(let {} = {}; {})", name, expr, body),
Sub { orig: _, name, indx: _, redx, expr } =>
write!(f, "({} ## {}/{})", expr, name, redx),
Ctr { orig: _, name, args } =>
write!(f, "({}{})", name, args.iter().map(|x| format!(" {}", x)).collect::<String>()),
Fun { orig: _, name, args } =>
write!(f, "({}{})", name, args.iter().map(|x| format!(" {}", x)).collect::<String>()),
App { func, argm, .. } => {
let mut args = vec![argm];
let mut expr = func;
while let App { func, argm, .. } = &**expr {
args.push(argm);
expr = func;
}
args.reverse();
write!(f, "({} {})", expr, args.iter().map(|x| format!("{}", x)).collect::<Vec<String>>().join(" "))
}
Mat { .. } => panic!("Internal Error: Cannot display a Term::Mat because it's removed after adjust.")
}
}
}
}

10
compiler/kind2/Cargo.toml Normal file
View File

@ -0,0 +1,10 @@
[package]
name = "kind2"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tracing = "0.1.36"
kind2_log = { path = "../log" }

3
compiler/kind2/README.md Normal file
View File

@ -0,0 +1,3 @@
# Kind2
The entire compiler executable.

View File

@ -0,0 +1,5 @@
use kind2_log::init_logger;
fn main() {
init_logger("").unwrap();
}

10
compiler/log/Cargo.toml Normal file
View File

@ -0,0 +1,10 @@
[package]
name = "kind2_log"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tracing = "0.1.36"
tracing-subscriber = { version = "0.3.15", features = ["env-filter"] }

3
compiler/log/README.md Normal file
View File

@ -0,0 +1,3 @@
# kind2_log
Tiny crate to help while debugging the compiler.

9
compiler/log/src/lib.rs Normal file
View File

@ -0,0 +1,9 @@
use tracing::subscriber::SetGlobalDefaultError;
pub fn init_logger(logger: &str) -> Result<(), SetGlobalDefaultError> {
let subscriber = tracing_subscriber::FmtSubscriber::builder()
.with_env_filter(logger)
.finish();
tracing::subscriber::set_global_default(subscriber)
}

View File

@ -0,0 +1,10 @@
[package]
name = "kind2_parser"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
kind2_book = { path = "../book" }
hvm = "0.1.81"

182
compiler/parser/src/lib.rs Normal file
View File

@ -0,0 +1,182 @@
use hvm::parser;
use std::collections::HashMap;
use kind2_book::name::{Ident, Qualified};
use kind2_book::span::{ByteOffset, Span};
use kind2_book::term::Term;
use kind2_book::{Argument, Book, Entry, Rule};
pub mod term;
use crate::term::*;
pub fn parse_rule(
state: parser::State,
name: String,
init: ByteOffset,
) -> parser::Answer<Box<Rule>> {
let (state, pats) = parser::until(parser::text_parser("="), Box::new(parse_term), state)?;
let (state, last) = get_last_index(state)?;
let orig = Span::new_off(init, last);
let (state, body) = parse_apps(state)?;
return Ok((
state,
Box::new(Rule {
orig,
name: Qualified::from_str(&name),
pats,
body,
}),
));
}
pub fn parse_entry(state: parser::State) -> parser::Answer<Box<Entry>> {
let (state, name) = parser::name1(state)?;
let (state, kdl) = parser::text("#", state)?;
let (state, kdln) = if kdl {
let (state, name) = parser::name1(state)?;
(state, Some(name))
} else {
(state, None)
};
let (state, args) = parser::until(
Box::new(|state| {
let (state, end_0) = parser::dry(Box::new(|state| parser::text(":", state)), state)?;
let (state, end_1) = parser::dry(Box::new(|state| parser::text("{", state)), state)?;
return Ok((state, end_0 || end_1));
}),
Box::new(parse_argument),
state,
)?;
let (state, next) = parser::peek_char(state)?;
let (state, tipo) = if next == ':' {
let (state, _) = parser::consume(":", state)?;
parse_apps(state)?
} else {
(
state,
Box::new(Term::Hol {
orig: Span::Generated,
numb: u64::MAX,
}),
) // TODO: set orig
};
let (state, head) = parser::peek_char(state)?;
if head == '{' {
let (state, _) = parser::consume("{", state)?;
let (state, body) = parse_apps(state)?;
let (state, _) = parser::consume("}", state)?;
let mut pats = vec![];
for arg in &args {
pats.push(Box::new(Term::Var {
orig: Span::Generated,
name: Ident(arg.name.clone()),
})); // TODO: set orig
}
let rules = vec![Box::new(Rule {
orig: Span::Generated,
name: Qualified::from_str(&name.clone()),
pats,
body,
})];
return Ok((
state,
Box::new(Entry {
name: Qualified::from_str(&name),
kdln,
args,
tipo,
rules,
orig: Span::Generated,
}),
));
} else {
let mut rules = Vec::new();
let rule_prefix = &format!("{} ", name);
let mut state = state;
loop {
let (loop_state, init) = get_init_index(state)?;
let (loop_state, cont) = parser::text(&rule_prefix, loop_state)?;
if cont {
let (loop_state, rule) = parse_rule(loop_state, name.clone(), init)?;
rules.push(rule);
state = loop_state;
} else {
state = loop_state;
break;
}
}
let entry = Box::new(Entry {
name: Qualified::from_str(&name),
kdln,
args,
tipo,
rules,
orig: Span::Generated,
});
return Ok((state, entry));
}
}
pub fn parse_argument(state: parser::State) -> parser::Answer<Box<Argument>> {
let (state, eras) = parser::text("-", state)?;
let (state, keep) = parser::text("+", state)?;
let (state, next) = parser::peek_char(state)?;
let (open, close) = if next == '(' { ("(", ")") } else { ("<", ">") };
let (state, _) = parser::consume(open, state)?;
let (state, name) = parser::name1(state)?;
let (state, anno) = parser::text(":", state)?;
let (state, tipo) = if anno {
parse_apps(state)?
} else {
(
state,
Box::new(Term::Typ {
orig: Span::Generated,
}),
)
};
let (state, _) = parser::consume(close, state)?;
let hide = open == "<";
let eras = if hide { !keep } else { eras };
return Ok((
state,
Box::new(Argument {
hide,
eras,
name,
tipo,
}),
));
}
pub fn parse_book(state: parser::State) -> parser::Answer<Box<Book>> {
let (state, entry_vec) = parser::until(Box::new(parser::done), Box::new(parse_entry), state)?;
let mut names = Vec::new();
let mut entrs = HashMap::new();
for entry in entry_vec {
if !entrs.contains_key(&entry.name) {
names.push(entry.name.to_string().clone());
entrs.insert(entry.name.clone(), entry);
} else {
println!(
"\x1b[33mwarning\x1b[0m: ignored redefinition of '{}'.",
entry.name
);
}
}
return Ok((
state,
Box::new(Book {
holes: 0,
names,
entrs,
}),
));
}
pub fn read_book(code: &str) -> Result<Box<Book>, String> {
parser::read(Box::new(parse_book), code)
}

919
compiler/parser/src/term.rs Normal file
View File

@ -0,0 +1,919 @@
use hvm::parser;
use kind2_book::name::{Ident, Qualified};
use kind2_book::span::{ByteOffset, Span};
use kind2_book::term::{Operator, Term};
pub fn is_ctr_head(head: char) -> bool {
('A'..='Z').contains(&head)
}
pub fn get_init_index(state: parser::State) -> parser::Answer<ByteOffset> {
let (state, _) = parser::skip(state)?;
Ok((state, ByteOffset(state.index as u32)))
}
pub fn get_last_index(state: parser::State) -> parser::Answer<ByteOffset> {
Ok((state, ByteOffset(state.index as u32)))
}
pub fn parse_var(state: parser::State) -> parser::Answer<Option<Box<Term>>> {
parser::guard(
Box::new(|state| Ok((state, true))),
Box::new(|state| {
let (state, init) = get_init_index(state)?;
let (state, name) = parser::name1(state)?;
let (state, last) = get_last_index(state)?;
let orig = Span::new_off(init, last);
if let Ok(numb) = name.parse::<u64>() {
Ok((state, Box::new(Term::Num { orig, numb })))
} else {
Ok((
state,
Box::new(Term::Var {
orig,
name: Ident(name),
}),
))
}
}),
state,
)
}
pub fn parse_hol(state: parser::State) -> parser::Answer<Option<Box<Term>>> {
parser::guard(
parser::text_parser("_"),
Box::new(|state| {
let (state, init) = get_init_index(state)?;
let (state, _) = parser::consume("_", state)?;
let (state, last) = get_last_index(state)?;
let orig = Span::new_off(init, last);
Ok((state, Box::new(Term::Hol { orig, numb: 0 })))
}),
state,
)
}
pub fn parse_hlp(state: parser::State) -> parser::Answer<Option<Box<Term>>> {
return parser::guard(
parser::text_parser("?"),
Box::new(|state| {
let (state, init) = get_init_index(state)?;
let (state, _) = parser::consume("?", state)?;
let (state, _) = parser::name_here(state)?;
let (state, last) = get_last_index(state)?;
let orig = Span::new_off(init, last);
Ok((state, Box::new(Term::Hlp { orig })))
}),
state,
);
}
pub fn parse_str(state: parser::State) -> parser::Answer<Option<Box<Term>>> {
parser::guard(
Box::new(|state| {
let (state, head) = parser::get_char(state)?;
Ok((state, head == '"' || head == '`'))
}),
Box::new(|state| {
let (state, init) = get_init_index(state)?;
let delim = parser::head(state).unwrap_or('\0');
let state = parser::tail(state);
let mut chars: Vec<char> = Vec::new();
let mut state = state;
loop {
if let Some(next) = parser::head(state) {
if next == delim || next == '\0' {
state = parser::tail(state);
break;
} else {
chars.push(next);
state = parser::tail(state);
}
}
}
let (state, last) = get_last_index(state)?;
let orig = Span::new_off(init, last);
let empty = Term::Ctr {
orig,
name: Qualified::new_raw("String", "nil"),
args: Vec::new(),
};
let list = Box::new(chars.iter().rfold(empty, |t, h| Term::Ctr {
orig,
name: Qualified::new_raw("String", "cons"),
args: vec![
Box::new(Term::Num {
orig,
numb: *h as u64,
}),
Box::new(t),
],
}));
Ok((state, list))
}),
state,
)
}
pub fn parse_grp(state: parser::State) -> parser::Answer<Option<Box<Term>>> {
parser::guard(
parser::text_parser("("),
Box::new(|state| {
let (state, _) = parser::consume("(", state)?;
let (state, term) = parse_apps(state)?;
let (state, _) = parser::consume(")", state)?;
Ok((state, term))
}),
state,
)
}
pub fn parse_apps(state: parser::State) -> parser::Answer<Box<Term>> {
let (state, init) = get_init_index(state)?;
let (mut state, mut term) = parse_term(state)?;
loop {
let loop_state = state;
let (loop_state, _) = parser::skip_while(loop_state, Box::new(|x| *x == ' '))?;
let head = parser::head(loop_state).unwrap_or(' ');
let is_term_initializer // NOTE: this must cover all characters that can start a term
= ('a'..='z').contains(&head)
|| ('A'..='Z').contains(&head)
|| ('0'..='9').contains(&head)
|| ['(','[','"','\'','@','?','_','#'].contains(&head);
if is_term_initializer {
let (loop_state, argm) = parse_term(loop_state)?;
let (loop_state, last) = get_last_index(loop_state)?;
let orig = Span::new_off(init, last);
term = Box::new(Term::App {
orig,
func: term,
argm,
});
state = loop_state;
} else {
state = loop_state;
break;
}
}
return Ok((state, term));
}
pub fn parse_ann(
state: parser::State,
) -> parser::Answer<Option<Box<dyn Fn(ByteOffset, Box<Term>) -> Box<Term>>>> {
return parser::guard(
parser::text_parser("::"),
Box::new(|state| {
let (state, _) = parser::consume("::", state)?;
let (state, tipo) = parse_apps(state)?;
let (state, last) = get_last_index(state)?;
Ok((
state,
Box::new(move |init, expr| {
let orig = Span::new_off(init, last);
let expr = expr.clone();
let tipo = tipo.clone();
Box::new(Term::Ann { orig, expr, tipo })
}),
))
}),
state,
);
}
pub fn parse_term_prefix(state: parser::State) -> parser::Answer<Box<Term>> {
// NOTE: all characters that can start a term must be listed on `parse_term_applys()`
parser::grammar(
"Term",
&[
Box::new(parse_all), // `(name:`
Box::new(parse_ctr), // `(Name`
Box::new(parse_op2), // `(+`
Box::new(parse_grp), // `(`
Box::new(parse_sig), // `[name:`
Box::new(parse_new), // `$`
Box::new(parse_lst), // `[`
Box::new(parse_str), // `"`
Box::new(parse_chr), // `'`
Box::new(parse_lam), // `@`
Box::new(parse_let), // `let `
Box::new(parse_if), // `if `
Box::new(parse_mat), // `match `
Box::new(parse_do), // `do `
Box::new(parse_hlp), // `?`
Box::new(parse_hol), // `_`
Box::new(parse_var), // x
Box::new(|state| Ok((state, None))),
],
state,
)
}
pub fn parse_term_suffix(
state: parser::State,
) -> parser::Answer<Box<dyn Fn(ByteOffset, Box<Term>) -> Box<Term>>> {
parser::grammar(
"Term",
&[
Box::new(parse_arr), // `->`
Box::new(parse_sub), // `# `
Box::new(parse_ann), // `::`
Box::new(|state| Ok((state, Some(Box::new(|_, term| term))))),
],
state,
)
}
pub fn parse_arr(
state: parser::State,
) -> parser::Answer<Option<Box<dyn Fn(ByteOffset, Box<Term>) -> Box<Term>>>> {
return parser::guard(
parser::text_parser("->"),
Box::new(|state| {
let (state, _) = parser::consume("->", state)?;
let (state, body) = parse_apps(state)?;
let (state, last) = get_last_index(state)?;
Ok((
state,
Box::new(move |init, tipo| {
let orig = Span::new_off(init, last);
let name = "_".to_string();
let body = body.clone();
Box::new(Term::All {
orig,
name: Ident(name),
tipo,
body,
})
}),
))
}),
state,
);
}
pub fn parse_sub(
state: parser::State,
) -> parser::Answer<Option<Box<dyn Fn(ByteOffset, Box<Term>) -> Box<Term>>>> {
return parser::guard(
parser::text_parser("##"),
Box::new(|state| {
let (state, _) = parser::consume("##", state)?;
let (state, name) = parser::name1(state)?;
let (state, _) = parser::consume("/", state)?;
let (state, redx) = parser::name1(state)?;
if let Ok(redx) = redx.parse::<u64>() {
let (state, last) = get_last_index(state)?;
Ok((
state,
Box::new(move |init, expr| {
let orig = Span::new_off(init, last);
let name = name.clone();
let indx = 0;
let expr = expr.clone();
Box::new(Term::Sub {
orig,
name: Ident(name),
indx,
redx,
expr,
})
}),
))
} else {
parser::expected("number", name.len(), state)
}
}),
state,
);
}
pub fn parse_let_st(
state: parser::State,
) -> parser::Answer<Option<Box<dyn Fn(&str) -> Box<Term>>>> {
return parser::guard(
parser::text_parser("let "),
Box::new(|state| {
let (state, init) = get_init_index(state)?;
let (state, _) = parser::consume("let ", state)?;
let (state, name) = parser::name1(state)?;
let (state, _) = parser::consume("=", state)?;
let (state, expr) = parse_apps(state)?;
let (state, _) = parser::text(";", state)?;
let (state, body) = parse_term_st(state)?;
let (state, last) = get_last_index(state)?;
let orig = Span::new_off(init, last);
Ok((
state,
Box::new(move |monad| {
Box::new(Term::Let {
orig,
name: Ident(name.clone()),
expr: expr.clone(),
body: body(monad),
})
}),
))
}),
state,
);
}
pub fn parse_return_st(
state: parser::State,
) -> parser::Answer<Option<Box<dyn Fn(&str) -> Box<Term>>>> {
return parser::guard(
parser::text_parser("return "),
Box::new(move |state| {
let (state, init) = get_init_index(state)?;
let (state, _) = parser::consume("return ", state)?;
let (state, term) = parse_apps(state)?;
let (state, last) = get_last_index(state)?;
let orig = Span::new_off(init, last);
return Ok((
state,
Box::new(move |monad| {
Box::new(Term::Ctr {
orig: orig,
name: Qualified::new_raw(monad, "pure"),
args: vec![term.clone()],
})
}),
));
}),
state,
);
}
pub fn parse_ask_named_st(
state: parser::State,
) -> parser::Answer<Option<Box<dyn Fn(&str) -> Box<Term>>>> {
return parser::guard(
Box::new(|state| {
let (state, all0) = parser::text("ask ", state)?;
let (state, name) = parser::name(state)?;
let (state, all1) = parser::text("=", state)?;
Ok((state, all0 && name.len() > 0 && all1))
}),
Box::new(move |state| {
let (state, init) = get_init_index(state)?;
let (state, _) = parser::consume("ask", state)?;
let (state, name) = parser::name(state)?;
let (state, _) = parser::consume("=", state)?;
let (state, acti) = parse_apps(state)?;
let (state, body) = parse_term_st(state)?;
let (state, last) = get_last_index(state)?;
let orig = Span::new_off(init, last);
return Ok((
state,
Box::new(move |monad| {
Box::new(Term::Ctr {
orig: orig,
name: Qualified::new_raw(monad, "bind"),
args: vec![
acti.clone(),
Box::new(Term::Lam {
orig,
name: Ident(name.clone()),
body: body(monad),
}),
],
})
}),
));
}),
state,
);
}
pub fn parse_ask_anon_st(
state: parser::State,
) -> parser::Answer<Option<Box<dyn Fn(&str) -> Box<Term>>>> {
return parser::guard(
parser::text_parser("ask "),
Box::new(move |state| {
let (state, init) = get_init_index(state)?;
let (state, _) = parser::consume("ask", state)?;
let (state, acti) = parse_apps(state)?;
let (state, body) = parse_term_st(state)?;
let (state, last) = get_last_index(state)?;
let name = "_".to_string();
let orig = Span::new_off(init, last);
return Ok((
state,
Box::new(move |monad| {
Box::new(Term::Ctr {
orig: orig,
name: Qualified::new_raw(monad, "bind"),
args: vec![
acti.clone(),
Box::new(Term::Lam {
orig,
name: Ident(name.clone()),
body: body(monad),
}),
],
})
}),
));
}),
state,
);
}
pub fn parse_term_st(state: parser::State) -> parser::Answer<Box<dyn Fn(&str) -> Box<Term>>> {
parser::grammar(
"Statement",
&[
Box::new(parse_return_st),
Box::new(parse_ask_named_st),
Box::new(parse_ask_anon_st),
Box::new(parse_let_st),
Box::new(|state| {
let (state, term) = parse_term(state)?;
Ok((state, Some(Box::new(move |_| term.clone()))))
}),
],
state,
)
}
pub fn parse_term(state: parser::State) -> parser::Answer<Box<Term>> {
let (state, init) = get_init_index(state)?;
let (state, prefix) = parse_term_prefix(state)?;
let (state, suffix) = parse_term_suffix(state)?;
return Ok((state, suffix(init, prefix)));
}
pub fn parse_do(state: parser::State) -> parser::Answer<Option<Box<Term>>> {
parser::guard(
parser::text_parser("do "),
Box::new(|state| {
let (state, _) = parser::text("do", state)?;
let (state, name) = parser::name1(state)?;
let (state, _) = parser::text("{", state)?;
let (state, term) = parse_term_st(state)?;
let (state, _) = parser::text("}", state)?;
Ok((state, term(&name)))
}),
state,
)
}
pub fn parse_mat(state: parser::State) -> parser::Answer<Option<Box<Term>>> {
return parser::guard(
parser::text_parser("match "),
Box::new(|state| {
let (state, init) = get_init_index(state)?;
let (state, _) = parser::consume("match ", state)?;
let (state, tipo) = parser::name1(state)?;
let (state, nm_i) = get_init_index(state)?;
let (state, name) = parser::name1(state)?;
let (state, next) = parser::peek_char(state)?;
let (state, expr) = if next == '=' {
let (state, _) = parser::consume("=", state)?;
let (state, expr) = parse_apps(state)?;
(state, expr)
} else {
let (state, nm_j) = get_last_index(state)?;
(
state,
Box::new(Term::Var {
orig: Span::new_off(nm_i, nm_j),
name: Ident(name.clone()),
}),
)
};
let (state, _) = parser::consume("{", state)?;
let (state, cses) = parser::until(
parser::text_parser("}"),
Box::new(|state| {
let (state, name) = parser::name1(state)?;
let (state, _) = parser::consume("=>", state)?;
let (state, body) = parse_apps(state)?;
let (state, _) = parser::text(";", state)?;
return Ok((state, (Ident(name), body)));
}),
state,
)?;
let (state, next) = peek_char_local(state)?;
let (state, moti) = if next == ':' {
let (state, _) = parser::consume(":", state)?;
let (state, moti) = parse_apps(state)?;
(state, moti)
} else {
(
state,
Box::new(Term::Hol {
orig: Span::generated(),
numb: 0,
}),
)
};
let (state, last) = get_last_index(state)?;
let orig = Span::new_off(init, last);
return Ok((
state,
Box::new(Term::Mat {
orig,
tipo: Qualified::from_str(&tipo),
name: Ident(name),
expr,
cses,
moti,
}),
));
}),
state,
);
}
pub fn peek_char_local(state: parser::State) -> parser::Answer<char> {
let (state, _) = parser::skip_while(state, Box::new(|x| *x == ' '))?;
if let Some(got) = parser::head(state) {
return Ok((state, got));
} else {
return Ok((state, '\0'));
}
}
pub fn parse_all(state: parser::State) -> parser::Answer<Option<Box<Term>>> {
parser::guard(
Box::new(|state| {
let (state, all0) = parser::text("(", state)?;
let (state, name) = parser::name(state)?;
let (state, all1) = parser::text(":", state)?;
Ok((state, all0 && all1 && name.len() > 0))
//Ok((state, all0 && all1 && name.len() > 0 && is_var_head(name.chars().nth(0).unwrap_or(' '))))
}),
Box::new(|state| {
let (state, init) = get_init_index(state)?;
let (state, _) = parser::consume("(", state)?;
let (state, name) = parser::name1(state)?;
let (state, _) = parser::consume(":", state)?;
let (state, tipo) = parse_apps(state)?;
let (state, _) = parser::consume(")", state)?;
let (state, isfn) = parser::text("=>", state)?;
if isfn {
let (state, body) = parse_apps(state)?;
let (state, last) = get_last_index(state)?;
let orig = Span::new_off(init, last);
Ok((
state,
Box::new(Term::Ann {
orig,
expr: Box::new(Term::Lam {
orig,
name: Ident(name.clone()),
body,
}),
tipo: Box::new(Term::All {
orig,
name: Ident(name.clone()),
tipo,
body: Box::new(Term::Hol { orig, numb: 0 }),
}),
}),
))
} else {
let (state, _) = parser::text("->", state)?;
let (state, body) = parse_apps(state)?;
let (state, last) = get_last_index(state)?;
let orig = Span::new_off(init, last);
Ok((
state,
Box::new(Term::All {
orig,
name: Ident(name),
tipo,
body,
}),
))
}
}),
state,
)
}
pub fn parse_if(state: parser::State) -> parser::Answer<Option<Box<Term>>> {
return parser::guard(
parser::text_parser("if "),
Box::new(|state| {
let (state, init) = get_init_index(state)?;
let (state, _) = parser::consume("if ", state)?;
let (state, cond) = parse_apps(state)?;
let (state, _) = parser::consume("{", state)?;
let (state, if_t) = parse_apps(state)?;
let (state, _) = parser::text("}", state)?;
let (state, _) = parser::text("else", state)?;
let (state, _) = parser::consume("{", state)?;
let (state, if_f) = parse_apps(state)?;
let (state, _) = parser::text("}", state)?;
let (state, last) = get_last_index(state)?;
let orig = Span::new_off(init, last);
let moti = Box::new(Term::Hol { orig, numb: 0 });
Ok((
state,
Box::new(Term::Ctr {
orig,
name: Qualified::new_raw("Bool", "if"),
args: vec![moti, cond, if_t, if_f],
}),
))
}),
state,
);
}
pub fn parse_let(state: parser::State) -> parser::Answer<Option<Box<Term>>> {
return parser::guard(
parser::text_parser("let "),
Box::new(|state| {
let (state, init) = get_init_index(state)?;
let (state, _) = parser::consume("let ", state)?;
let (state, name) = parser::name1(state)?;
let (state, _) = parser::consume("=", state)?;
let (state, expr) = parse_apps(state)?;
let (state, _) = parser::text(";", state)?;
let (state, body) = parse_apps(state)?;
let (state, last) = get_last_index(state)?;
let orig = Span::new_off(init, last);
Ok((
state,
Box::new(Term::Let {
orig,
name: Ident(name),
expr,
body,
}),
))
}),
state,
);
}
pub fn parse_lam(state: parser::State) -> parser::Answer<Option<Box<Term>>> {
parser::guard(
Box::new(|state| {
let (state, name) = parser::name(state)?;
let (state, arro) = parser::text("=>", state)?;
Ok((state, name.len() > 0 && arro))
//Ok((state, all0 && all1 && name.len() > 0 && is_var_head(name.chars().nth(0).unwrap_or(' '))))
}),
Box::new(move |state| {
let (state, init) = get_init_index(state)?;
let (state, name) = parser::name1(state)?;
let (state, _) = parser::consume("=>", state)?;
let (state, body) = parse_apps(state)?;
let (state, last) = get_last_index(state)?;
let orig = Span::new_off(init, last);
Ok((
state,
Box::new(Term::Lam {
orig,
name: Ident(name),
body,
}),
))
}),
state,
)
}
pub fn parse_lst(state: parser::State) -> parser::Answer<Option<Box<Term>>> {
parser::guard(
Box::new(|state| {
let (state, head) = parser::get_char(state)?;
Ok((state, head == '['))
}),
Box::new(|state| {
let (state, init) = get_init_index(state)?;
let (state, _head) = parser::text("[", state)?;
let state = state;
let (state, elems) = parser::until(
Box::new(|x| parser::text("]", x)),
Box::new(|x| {
let (state, term) = parse_term(x)?;
let (state, _) = parser::maybe(Box::new(|x| parser::text(",", x)), state)?;
Ok((state, term))
}),
state,
)?;
let (state, last) = get_last_index(state)?;
let orig = Span::new_off(init, last);
let empty = Term::Ctr {
orig,
name: Qualified::new_raw("List", "nil"),
args: Vec::new(),
};
let list = Box::new(elems.iter().rfold(empty, |t, h| Term::Ctr {
orig,
name: Qualified::new_raw("List", "cons"),
args: vec![h.clone(), Box::new(t)],
}));
Ok((state, list))
}),
state,
)
}
pub fn parse_new(state: parser::State) -> parser::Answer<Option<Box<Term>>> {
parser::guard(
parser::text_parser("$"),
Box::new(move |state| {
let (state, init) = get_init_index(state)?;
let (state, _) = parser::consume("$", state)?;
let (state, val0) = parse_term(state)?;
let (state, val1) = parse_term(state)?;
let (state, last) = get_last_index(state)?;
let orig = Span::new_off(init, last);
Ok((
state,
Box::new(Term::Ctr {
orig,
name: Qualified::new_raw("Sigma", "new"),
args: vec![
Box::new(Term::Hol { orig, numb: 0 }),
Box::new(Term::Hol { orig, numb: 0 }),
val0,
val1,
],
}),
))
}),
state,
)
}
pub fn parse_ctr(state: parser::State) -> parser::Answer<Option<Box<Term>>> {
parser::guard(
Box::new(|state| {
let (state, open) = parser::text("(", state)?;
let (state, head) = parser::get_char(state)?;
//let (state, next) = parser::peek_char(state)?;
Ok((state, open && is_ctr_head(head)))
}),
Box::new(|state| {
let (state, init) = get_init_index(state)?;
let (state, open) = parser::text("(", state)?;
let (state, name) = parser::name1(state)?;
let (state, args) = if open {
parser::until(parser::text_parser(")"), Box::new(parse_term), state)?
} else {
(state, Vec::new())
};
let (state, last) = get_last_index(state)?;
let orig = Span::new_off(init, last);
Ok((
state,
Box::new(Term::Ctr {
orig,
name: Qualified::from_str(&name),
args,
}),
))
}),
state,
)
}
pub fn parse_chr(state: parser::State) -> parser::Answer<Option<Box<Term>>> {
parser::guard(
Box::new(|state| {
let (state, head) = parser::get_char(state)?;
Ok((state, head == '\''))
}),
Box::new(|state| {
let (state, init) = get_init_index(state)?;
let (state, _) = parser::text("'", state)?;
let (state, last) = get_last_index(state)?;
let orig = Span::new_off(init, last);
if let Some(c) = parser::head(state) {
let state = parser::tail(state);
let (state, _) = parser::text("'", state)?;
Ok((
state,
Box::new(Term::Num {
orig,
numb: c as u64,
}),
))
} else {
parser::expected("character", 1, state)
}
}),
state,
)
}
pub fn parse_op2(state: parser::State) -> parser::Answer<Option<Box<Term>>> {
fn is_op_char(chr: char) -> bool {
matches!(
chr,
'+' | '-' | '*' | '/' | '%' | '&' | '|' | '^' | '<' | '>' | '=' | '!'
)
}
fn parse_oper(state: parser::State) -> parser::Answer<Operator> {
fn op<'a>(symbol: &'static str, oper: Operator) -> parser::Parser<'a, Option<Operator>> {
Box::new(move |state| {
let (state, done) = parser::text(symbol, state)?;
Ok((state, if done { Some(oper) } else { None }))
})
}
parser::grammar(
"Oper",
&[
op("+", Operator::Add),
op("-", Operator::Sub),
op("*", Operator::Mul),
op("/", Operator::Div),
op("%", Operator::Mod),
op("&", Operator::And),
op("|", Operator::Or),
op("^", Operator::Xor),
op("<<", Operator::Shl),
op(">>", Operator::Shr),
op("<=", Operator::Lte),
op("<", Operator::Ltn),
op("==", Operator::Eql),
op(">=", Operator::Gte),
op(">", Operator::Gtn),
op("!=", Operator::Neq),
],
state,
)
}
parser::guard(
Box::new(|state| {
let (state, open) = parser::text("(", state)?;
let (state, head) = parser::get_char(state)?;
Ok((state, open && is_op_char(head)))
}),
Box::new(|state| {
let (state, init) = get_init_index(state)?;
let (state, _) = parser::consume("(", state)?;
let (state, oper) = parse_oper(state)?;
let (state, val0) = parse_term(state)?;
let (state, val1) = parse_term(state)?;
let (state, _) = parser::consume(")", state)?;
let (state, last) = get_last_index(state)?;
let orig = Span::new_off(init, last);
Ok((
state,
Box::new(Term::Op2 {
orig,
oper,
val0,
val1,
}),
))
}),
state,
)
}
pub fn parse_sig(state: parser::State) -> parser::Answer<Option<Box<Term>>> {
parser::guard(
Box::new(|state| {
let (state, all0) = parser::text("[", state)?;
let (state, name) = parser::name(state)?;
let (state, all1) = parser::text(":", state)?;
Ok((state, all0 && all1 && name.len() > 0))
//Ok((state, all0 && all1 && name.len() > 0 && is_var_head(name.chars().nth(0).unwrap_or(' '))))
}),
Box::new(|state| {
let (state, init) = get_init_index(state)?;
let (state, _) = parser::consume("[", state)?;
let (state, name) = parser::name1(state)?;
let (state, _) = parser::consume(":", state)?;
let (state, tipo) = parse_apps(state)?;
let (state, _) = parser::consume("]", state)?;
let (state, _) = parser::text("->", state)?;
let (state, body) = parse_apps(state)?;
let (state, last) = get_last_index(state)?;
let orig = Span::new_off(init, last);
Ok((
state,
Box::new(Term::Ctr {
orig,
name: Qualified::new_raw("", "Sigma"),
args: vec![
tipo,
Box::new(Term::Lam {
orig,
name: Ident(name),
body,
}),
],
}),
))
}),
state,
)
}

View File

@ -1,183 +0,0 @@
// U60
// ---
U60.to_nat (x: U60) : Nat
U60.to_nat #0 = Nat.zero
U60.to_nat n = (Nat.succ (U60.to_nat (- n #1)))
// Empty
// -----
Empty : Type
// Unit
// ----
Unit : Type
Unit.new : Unit
// Bool
// ----
Bool : Type
Bool.true : Bool
Bool.false : Bool
Bool.not (a: Bool) : Bool
Bool.not Bool.true = Bool.false
Bool.not Bool.false = Bool.true
Bool.and (a: Bool) (b: Bool) : Bool
Bool.and Bool.true Bool.true = Bool.true
Bool.and Bool.true Bool.false = Bool.false
Bool.and Bool.false Bool.true = Bool.false
Bool.and Bool.false Bool.false = Bool.false
Bool.if <r: Type> (b: Bool) (if_t: r) (if_f: r) : r
Bool.if r Bool.true if_t if_f = if_t
Bool.if r Bool.false if_t if_f = if_f
Bool.not_not_theorem (a: Bool) : (Equal Bool a (Bool.not (Bool.not a)))
Bool.not_not_theorem Bool.true = (Equal.refl Bool Bool.true)
Bool.not_not_theorem Bool.false = (Equal.refl Bool Bool.false)
Bool.true_not_false (e: (Equal Bool Bool.true Bool.false)) : Empty
Bool.true_not_false e = (Equal.rewrite e @x (Bool.if Type x Unit Empty) Unit.new)
// Nat
// ---
Nat : Type
Nat.zero : Nat
Nat.succ (pred: Nat) : Nat
Nat.double (x: Nat) : Nat
Nat.double (Nat.succ x) = (Nat.succ (Nat.succ (Nat.double x)))
Nat.double (Nat.zero) = (Nat.zero)
Nat.add (a: Nat) (b: Nat) : Nat
Nat.add (Nat.succ a) b = (Nat.succ (Nat.add a b))
Nat.add Nat.zero b = b
Nat.comm.a (a: Nat) : (Equal Nat a (Nat.add a Nat.zero))
Nat.comm.a Nat.zero = Equal.refl
Nat.comm.a (Nat.succ a) = (Equal.apply @x(Nat.succ x) (Nat.comm.a a))
Nat.comm.b (a: Nat) (b: Nat): (Equal Nat (Nat.add a (Nat.succ b)) (Nat.succ (Nat.add a b)))
Nat.comm.b Nat.zero b = Equal.refl
Nat.comm.b (Nat.succ a) b = (Equal.apply @x(Nat.succ x) (Nat.comm.b a b))
Nat.comm (a: Nat) (b: Nat) : (Equal Nat (Nat.add a b) (Nat.add b a))
Nat.comm Nat.zero b = (Nat.comm.a b)
Nat.comm (Nat.succ a) b =
let e0 = (Equal.apply @x(Nat.succ x) (Nat.comm a b))
let e1 = (Equal.mirror (Nat.comm.b b a))
(Equal.chain e0 e1)
Nat.to_u60 (n: Nat) : U60
Nat.to_u60 Nat.zero = #0
Nat.to_u60 (Nat.succ n) = (+ #1 (Nat.to_u60 n))
Nat.mul (a: Nat) (b: Nat) : Nat
Nat.mul (Nat.succ a) b = (Nat.add (Nat.mul a b) b) // (a + 1) * b = a*b + b
Nat.mul Nat.zero b = Nat.zero // 0b = 0
Nat.mul.comm.a (x: Nat): (Equal (Nat.mul x Nat.zero) Nat.zero)
Nat.mul.comm.a Nat.zero = Equal.refl
Nat.mul.comm.a (Nat.succ x) =
let e0 = (Nat.mul.comm.a x)
let e1 = (Equal.apply @y(Nat.add y Nat.zero) e0)
e1
// List
// ----
List (a: Type) : Type
List.nil <a> : (List a)
List.cons <a> (x: a) (xs: (List a)) : (List a)
List.negate (xs: (List Bool)) : (List Bool)
List.negate (List.cons Bool x xs) = (List.cons Bool (Bool.not x) (List.negate xs))
List.negate (List.nil Bool) = (List.nil Bool)
List.tail <a> (xs: (List a)) : (List a)
List.tail a (List.cons t x xs) = xs
List.map <a> <b> (x: (List a)) (f: (x: a) b) : (List b)
List.map a b (List.nil t) f = List.nil
List.map a b (List.cons t x xs) f = (List.cons (f x) (List.map xs f))
List.concat <a> (xs: (List a)) (ys: (List a)) : (List a)
List.concat a (List.cons u x xs) ys = (List.cons u x (List.concat a xs ys))
List.concat a (List.nil u) ys = ys
List.flatten <a> (xs: (List (List a))) : (List a)
List.flatten a (List.cons u x xs) = (List.concat x (List.flatten xs))
List.flatten a (List.nil u) = List.nil
List.bind <a: Type> <b: Type> (xs: (List a)) (f: a -> (List b)) : (List b)
List.bind a b xs f = (List.flatten b (List.map xs f))
List.pure <t: Type> (x: t) : (List t)
List.pure t x = (List.cons t x (List.nil t))
List.range.go (lim: Nat) (res: (List Nat)) : (List Nat)
List.range.go Nat.zero res = res
List.range.go (Nat.succ n) res = (List.range.go n (List.cons n res))
List.sum (xs: (List Nat)) : Nat
List.sum (List.nil t) = Nat.zero
List.sum (List.cons t x xs) = (Nat.add x (List.sum xs))
// Equal
// -----
Equal <t> (a: t) (b: t) : Type
Equal.refl <t> <a: t> : (Equal t a a)
Equal.mirror <t> <a: t> <b: t> (e: (Equal t a b)) : (Equal t b a)
Equal.mirror t a b (Equal.refl u k) = (Equal.refl u k)
Equal.apply <t> <u> <a: t> <b: t> (f: t -> t) (e: (Equal t a b)) : (Equal t (f a) (f b))
Equal.apply t u a b f (Equal.refl v k) = (Equal.refl v (f k))
Equal.rewrite <t> <a: t> <b: t> (e: (Equal t a b)) (p: t -> Type) (x: (p a)) : (p b)
Equal.rewrite t a b (Equal.refl u k) p x = x :: (p k)
Equal.chain <t> <a: t> <b: t> <c: t> (e0: (Equal t a b)) (e1: (Equal t b c)) : (Equal t a c)
Equal.chain t a b c e0 (Equal.refl u x) = e0 :: (Equal t a x)
// Monad
// -----
Monad (f: Type -> Type) : Type
Monad.new (f: Type -> Type)
(pure: (a: Type) (x: a) (f a))
(bind: (a: Type) (b: Type) (x: (f a)) (y: a -> (f b)) (f b))
: (Monad f)
// Variadic
// --------
Variadic (r: Type) (n: Nat) : Type
Variadic r Nat.zero = r
Variadic r (Nat.succ n) = r -> (Variadic r n)
// Examples
// --------
SNat : Type
SNat = (p: Type) ((SNat) -> p) -> p -> p
SZ : SNat
SZ = @p @s @z z
//SS : SNat -> SNat
//SS = @n @p @s @z (s n)

View File

@ -1,938 +0,0 @@
// Main : (String)
(Main) = let imports = (List.cons (Dynamic.new @a @b (Kind.Term.set_origin a b)) (List.cons (Dynamic.new (Kind.API.check_all)) (List.cons (Dynamic.new (Kind.API.eval_main)) (List.nil)))); (Kind.API.check_all)
// Kind.API.eval_main : (String)
(Kind.API.eval_main) = (Kind.Printer.text (List.cons (Kind.Term.show (Kind.Term.FN0 (Main.) 0)) (List.cons (String.new_line) (List.cons (String.new_line) (List.nil)))))
// Kind.Printer.text (ls: (List (String))) : (String)
(Kind.Printer.text (List.nil)) = ""
(Kind.Printer.text (List.cons x xs)) = (String.concat x (Kind.Printer.text xs))
// String.concat (xs: (String)) (ys: (String)) : (String)
(String.concat (String.cons x xs) ys) = (String.cons x (String.concat xs ys))
(String.concat "" ys) = ys
// Kind.Term.show.forall (orig: U60) (name: U60) (type: (Kind.Term)) (body: (_: (Kind.Term)) (Kind.Term)) : (String)
(Kind.Term.show.forall orig name type body) = (U60.if (== name 63) (Kind.Printer.text (List.cons "(" (List.cons (Kind.Term.show type) (List.cons " -> " (List.cons (Kind.Term.show (body (Kind.Term.var orig name 0))) (List.cons ")" (List.nil))))))) (Kind.Printer.text (List.cons "((" (List.cons (Kind.Name.show name) (List.cons ": " (List.cons (Kind.Term.show type) (List.cons ") -> " (List.cons (Kind.Term.show (body (Kind.Term.var orig name 0))) (List.cons ")" (List.nil))))))))))
// Kind.Term.show (term: (Kind.Term)) : (String)
(Kind.Term.show term) = let sugars = (List.cons (Kind.Term.show.sugar.string term) (List.cons (Kind.Term.show.sugar.list term) (List.cons (Kind.Term.show.sugar.sigma term) (List.nil)))); (Maybe.try sugars (Kind.Term.show.go term))
// Kind.Term.show.go (term: (Kind.Term)) : (String)
(Kind.Term.show.go (Kind.Term.typ orig)) = "Type"
(Kind.Term.show.go (Kind.Term.var orig name index)) = (Kind.Printer.text (List.cons (Kind.Name.show name) (List.nil)))
(Kind.Term.show.go (Kind.Term.hol orig numb)) = (Kind.Printer.text (List.cons "_" (List.nil)))
(Kind.Term.show.go (Kind.Term.all orig name type body)) = (Kind.Term.show.forall orig name type body)
(Kind.Term.show.go (Kind.Term.lam orig name body)) = (Kind.Printer.text (List.cons "(" (List.cons (Kind.Name.show name) (List.cons " => " (List.cons (Kind.Term.show (body (Kind.Term.var orig name 0))) (List.cons ")" (List.nil)))))))
(Kind.Term.show.go (Kind.Term.let orig name exp body)) = (Kind.Printer.text (List.cons "let " (List.cons (Kind.Name.show name) (List.cons " = " (List.cons (Kind.Term.show exp) (List.cons "; " (List.cons (Kind.Term.show (body (Kind.Term.var orig name 0))) (List.nil))))))))
(Kind.Term.show.go (Kind.Term.ann orig expr type)) = (Kind.Printer.text (List.cons "{" (List.cons (Kind.Term.show expr) (List.cons " :: " (List.cons (Kind.Term.show type) (List.cons "}" (List.nil)))))))
(Kind.Term.show.go (Kind.Term.sub orig name indx redx expr)) = (Kind.Printer.text (List.cons (Kind.Term.show expr) (List.cons " ## " (List.cons (Kind.Name.show name) (List.cons "/" (List.cons (Show.to_string (U60.show redx)) (List.nil)))))))
(Kind.Term.show.go (Kind.Term.app orig func argm)) = (Kind.Printer.text (List.cons "(" (List.cons (Kind.Term.show func) (List.cons " " (List.cons (Kind.Term.show argm) (List.cons ")" (List.nil)))))))
(Kind.Term.show.go (Kind.Term.ct0 ctid orig)) = (NameOf ctid)
(Kind.Term.show.go (Kind.Term.ct1 ctid orig x0)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf ctid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons ")" (List.nil)))))))
(Kind.Term.show.go (Kind.Term.ct2 ctid orig x0 x1)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf ctid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons ")" (List.nil)))))))))
(Kind.Term.show.go (Kind.Term.ct3 ctid orig x0 x1 x2)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf ctid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons ")" (List.nil)))))))))))
(Kind.Term.show.go (Kind.Term.ct4 ctid orig x0 x1 x2 x3)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf ctid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons " " (List.cons (Kind.Term.show x3) (List.cons ")" (List.nil)))))))))))))
(Kind.Term.show.go (Kind.Term.ct5 ctid orig x0 x1 x2 x3 x4)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf ctid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons " " (List.cons (Kind.Term.show x3) (List.cons " " (List.cons (Kind.Term.show x4) (List.cons ")" (List.nil)))))))))))))))
(Kind.Term.show.go (Kind.Term.ct6 ctid orig x0 x1 x2 x3 x4 x5)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf ctid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons " " (List.cons (Kind.Term.show x3) (List.cons " " (List.cons (Kind.Term.show x4) (List.cons " " (List.cons (Kind.Term.show x5) (List.cons ")" (List.nil)))))))))))))))))
(Kind.Term.show.go (Kind.Term.ct7 ctid orig x0 x1 x2 x3 x4 x5 x6)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf ctid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons " " (List.cons (Kind.Term.show x3) (List.cons " " (List.cons (Kind.Term.show x4) (List.cons " " (List.cons (Kind.Term.show x5) (List.cons " " (List.cons (Kind.Term.show x6) (List.cons ")" (List.nil)))))))))))))))))))
(Kind.Term.show.go (Kind.Term.ct8 ctid orig x0 x1 x2 x3 x4 x5 x6 x7)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf ctid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons " " (List.cons (Kind.Term.show x3) (List.cons " " (List.cons (Kind.Term.show x4) (List.cons " " (List.cons (Kind.Term.show x5) (List.cons " " (List.cons (Kind.Term.show x6) (List.cons " " (List.cons (Kind.Term.show x7) (List.cons ")" (List.nil)))))))))))))))))))))
(Kind.Term.show.go (Kind.Term.ct9 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf ctid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons " " (List.cons (Kind.Term.show x3) (List.cons " " (List.cons (Kind.Term.show x4) (List.cons " " (List.cons (Kind.Term.show x5) (List.cons " " (List.cons (Kind.Term.show x6) (List.cons " " (List.cons (Kind.Term.show x7) (List.cons " " (List.cons (Kind.Term.show x8) (List.cons ")" (List.nil)))))))))))))))))))))))
(Kind.Term.show.go (Kind.Term.ct10 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf ctid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons " " (List.cons (Kind.Term.show x3) (List.cons " " (List.cons (Kind.Term.show x4) (List.cons " " (List.cons (Kind.Term.show x5) (List.cons " " (List.cons (Kind.Term.show x6) (List.cons " " (List.cons (Kind.Term.show x7) (List.cons " " (List.cons (Kind.Term.show x8) (List.cons " " (List.cons (Kind.Term.show x9) (List.cons ")" (List.nil)))))))))))))))))))))))))
(Kind.Term.show.go (Kind.Term.ct11 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf ctid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons " " (List.cons (Kind.Term.show x3) (List.cons " " (List.cons (Kind.Term.show x4) (List.cons " " (List.cons (Kind.Term.show x5) (List.cons " " (List.cons (Kind.Term.show x6) (List.cons " " (List.cons (Kind.Term.show x7) (List.cons " " (List.cons (Kind.Term.show x8) (List.cons " " (List.cons (Kind.Term.show x9) (List.cons " " (List.cons (Kind.Term.show x10) (List.cons ")" (List.nil)))))))))))))))))))))))))))
(Kind.Term.show.go (Kind.Term.ct12 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf ctid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons " " (List.cons (Kind.Term.show x3) (List.cons " " (List.cons (Kind.Term.show x4) (List.cons " " (List.cons (Kind.Term.show x5) (List.cons " " (List.cons (Kind.Term.show x6) (List.cons " " (List.cons (Kind.Term.show x7) (List.cons " " (List.cons (Kind.Term.show x8) (List.cons " " (List.cons (Kind.Term.show x9) (List.cons " " (List.cons (Kind.Term.show x10) (List.cons " " (List.cons (Kind.Term.show x11) (List.cons ")" (List.nil)))))))))))))))))))))))))))))
(Kind.Term.show.go (Kind.Term.ct13 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf ctid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons " " (List.cons (Kind.Term.show x3) (List.cons " " (List.cons (Kind.Term.show x4) (List.cons " " (List.cons (Kind.Term.show x5) (List.cons " " (List.cons (Kind.Term.show x6) (List.cons " " (List.cons (Kind.Term.show x7) (List.cons " " (List.cons (Kind.Term.show x8) (List.cons " " (List.cons (Kind.Term.show x9) (List.cons " " (List.cons (Kind.Term.show x10) (List.cons " " (List.cons (Kind.Term.show x11) (List.cons " " (List.cons (Kind.Term.show x12) (List.cons ")" (List.nil)))))))))))))))))))))))))))))))
(Kind.Term.show.go (Kind.Term.ct14 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf ctid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons " " (List.cons (Kind.Term.show x3) (List.cons " " (List.cons (Kind.Term.show x4) (List.cons " " (List.cons (Kind.Term.show x5) (List.cons " " (List.cons (Kind.Term.show x6) (List.cons " " (List.cons (Kind.Term.show x7) (List.cons " " (List.cons (Kind.Term.show x8) (List.cons " " (List.cons (Kind.Term.show x9) (List.cons " " (List.cons (Kind.Term.show x10) (List.cons " " (List.cons (Kind.Term.show x11) (List.cons " " (List.cons (Kind.Term.show x12) (List.cons " " (List.cons (Kind.Term.show x13) (List.cons ")" (List.nil)))))))))))))))))))))))))))))))))
(Kind.Term.show.go (Kind.Term.ct15 ctid orig x0)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf ctid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons ")" (List.nil)))))))
(Kind.Term.show.go (Kind.Term.ct16 ctid orig x0)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf ctid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons ")" (List.nil)))))))
(Kind.Term.show.go (Kind.Term.fn0 fnid orig)) = (NameOf fnid)
(Kind.Term.show.go (Kind.Term.fn1 fnid orig x0)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf fnid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons ")" (List.nil)))))))
(Kind.Term.show.go (Kind.Term.fn2 fnid orig x0 x1)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf fnid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons ")" (List.nil)))))))))
(Kind.Term.show.go (Kind.Term.fn3 fnid orig x0 x1 x2)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf fnid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons ")" (List.nil)))))))))))
(Kind.Term.show.go (Kind.Term.fn4 fnid orig x0 x1 x2 x3)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf fnid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons " " (List.cons (Kind.Term.show x3) (List.cons ")" (List.nil)))))))))))))
(Kind.Term.show.go (Kind.Term.fn5 fnid orig x0 x1 x2 x3 x4)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf fnid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons " " (List.cons (Kind.Term.show x3) (List.cons " " (List.cons (Kind.Term.show x4) (List.cons ")" (List.nil)))))))))))))))
(Kind.Term.show.go (Kind.Term.fn6 fnid orig x0 x1 x2 x3 x4 x5)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf fnid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons " " (List.cons (Kind.Term.show x3) (List.cons " " (List.cons (Kind.Term.show x4) (List.cons " " (List.cons (Kind.Term.show x5) (List.cons ")" (List.nil)))))))))))))))))
(Kind.Term.show.go (Kind.Term.fn7 fnid orig x0 x1 x2 x3 x4 x5 x6)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf fnid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons " " (List.cons (Kind.Term.show x3) (List.cons " " (List.cons (Kind.Term.show x4) (List.cons " " (List.cons (Kind.Term.show x5) (List.cons " " (List.cons (Kind.Term.show x6) (List.cons ")" (List.nil)))))))))))))))))))
(Kind.Term.show.go (Kind.Term.fn8 fnid orig x0 x1 x2 x3 x4 x5 x6 x7)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf fnid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons " " (List.cons (Kind.Term.show x3) (List.cons " " (List.cons (Kind.Term.show x4) (List.cons " " (List.cons (Kind.Term.show x5) (List.cons " " (List.cons (Kind.Term.show x6) (List.cons " " (List.cons (Kind.Term.show x7) (List.cons ")" (List.nil)))))))))))))))))))))
(Kind.Term.show.go (Kind.Term.fn9 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf fnid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons " " (List.cons (Kind.Term.show x3) (List.cons " " (List.cons (Kind.Term.show x4) (List.cons " " (List.cons (Kind.Term.show x5) (List.cons " " (List.cons (Kind.Term.show x6) (List.cons " " (List.cons (Kind.Term.show x7) (List.cons " " (List.cons (Kind.Term.show x8) (List.cons ")" (List.nil)))))))))))))))))))))))
(Kind.Term.show.go (Kind.Term.fn10 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf fnid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons " " (List.cons (Kind.Term.show x3) (List.cons " " (List.cons (Kind.Term.show x4) (List.cons " " (List.cons (Kind.Term.show x5) (List.cons " " (List.cons (Kind.Term.show x6) (List.cons " " (List.cons (Kind.Term.show x7) (List.cons " " (List.cons (Kind.Term.show x8) (List.cons " " (List.cons (Kind.Term.show x9) (List.cons ")" (List.nil)))))))))))))))))))))))))
(Kind.Term.show.go (Kind.Term.fn11 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf fnid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons " " (List.cons (Kind.Term.show x3) (List.cons " " (List.cons (Kind.Term.show x4) (List.cons " " (List.cons (Kind.Term.show x5) (List.cons " " (List.cons (Kind.Term.show x6) (List.cons " " (List.cons (Kind.Term.show x7) (List.cons " " (List.cons (Kind.Term.show x8) (List.cons " " (List.cons (Kind.Term.show x9) (List.cons " " (List.cons (Kind.Term.show x10) (List.cons ")" (List.nil)))))))))))))))))))))))))))
(Kind.Term.show.go (Kind.Term.fn12 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf fnid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons " " (List.cons (Kind.Term.show x3) (List.cons " " (List.cons (Kind.Term.show x4) (List.cons " " (List.cons (Kind.Term.show x5) (List.cons " " (List.cons (Kind.Term.show x6) (List.cons " " (List.cons (Kind.Term.show x7) (List.cons " " (List.cons (Kind.Term.show x8) (List.cons " " (List.cons (Kind.Term.show x9) (List.cons " " (List.cons (Kind.Term.show x10) (List.cons " " (List.cons (Kind.Term.show x11) (List.cons ")" (List.nil)))))))))))))))))))))))))))))
(Kind.Term.show.go (Kind.Term.fn13 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf fnid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons " " (List.cons (Kind.Term.show x3) (List.cons " " (List.cons (Kind.Term.show x4) (List.cons " " (List.cons (Kind.Term.show x5) (List.cons " " (List.cons (Kind.Term.show x6) (List.cons " " (List.cons (Kind.Term.show x7) (List.cons " " (List.cons (Kind.Term.show x8) (List.cons " " (List.cons (Kind.Term.show x9) (List.cons " " (List.cons (Kind.Term.show x10) (List.cons " " (List.cons (Kind.Term.show x11) (List.cons " " (List.cons (Kind.Term.show x12) (List.cons ")" (List.nil)))))))))))))))))))))))))))))))
(Kind.Term.show.go (Kind.Term.fn14 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf fnid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons " " (List.cons (Kind.Term.show x3) (List.cons " " (List.cons (Kind.Term.show x4) (List.cons " " (List.cons (Kind.Term.show x5) (List.cons " " (List.cons (Kind.Term.show x6) (List.cons " " (List.cons (Kind.Term.show x7) (List.cons " " (List.cons (Kind.Term.show x8) (List.cons " " (List.cons (Kind.Term.show x9) (List.cons " " (List.cons (Kind.Term.show x10) (List.cons " " (List.cons (Kind.Term.show x11) (List.cons " " (List.cons (Kind.Term.show x12) (List.cons " " (List.cons (Kind.Term.show x13) (List.cons ")" (List.nil)))))))))))))))))))))))))))))))))
(Kind.Term.show.go (Kind.Term.fn15 fnid orig x0)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf fnid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons ")" (List.nil)))))))
(Kind.Term.show.go (Kind.Term.fn16 fnid orig x0)) = (Kind.Printer.text (List.cons "(" (List.cons (NameOf fnid) (List.cons " " (List.cons (Kind.Term.show x0) (List.cons ")" (List.nil)))))))
(Kind.Term.show.go (Kind.Term.args15 x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14)) = (Kind.Printer.text (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons " " (List.cons (Kind.Term.show x3) (List.cons " " (List.cons (Kind.Term.show x4) (List.cons " " (List.cons (Kind.Term.show x5) (List.cons " " (List.cons (Kind.Term.show x6) (List.cons " " (List.cons (Kind.Term.show x7) (List.cons " " (List.cons (Kind.Term.show x8) (List.cons " " (List.cons (Kind.Term.show x9) (List.cons " " (List.cons (Kind.Term.show x10) (List.cons " " (List.cons (Kind.Term.show x11) (List.cons " " (List.cons (Kind.Term.show x12) (List.cons " " (List.cons (Kind.Term.show x13) (List.cons " " (List.cons (Kind.Term.show x14) (List.nil)))))))))))))))))))))))))))))))
(Kind.Term.show.go (Kind.Term.args16 x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15)) = (Kind.Printer.text (List.cons (Kind.Term.show x0) (List.cons " " (List.cons (Kind.Term.show x1) (List.cons " " (List.cons (Kind.Term.show x2) (List.cons " " (List.cons (Kind.Term.show x3) (List.cons " " (List.cons (Kind.Term.show x4) (List.cons " " (List.cons (Kind.Term.show x5) (List.cons " " (List.cons (Kind.Term.show x6) (List.cons " " (List.cons (Kind.Term.show x7) (List.cons " " (List.cons (Kind.Term.show x8) (List.cons " " (List.cons (Kind.Term.show x9) (List.cons " " (List.cons (Kind.Term.show x10) (List.cons " " (List.cons (Kind.Term.show x11) (List.cons " " (List.cons (Kind.Term.show x12) (List.cons " " (List.cons (Kind.Term.show x13) (List.cons " " (List.cons (Kind.Term.show x14) (List.cons " " (List.cons (Kind.Term.show x15) (List.nil)))))))))))))))))))))))))))))))))
(Kind.Term.show.go (Kind.Term.hlp orig)) = "?"
(Kind.Term.show.go (Kind.Term.u60 orig)) = "U60"
(Kind.Term.show.go (Kind.Term.num orig numb)) = (Show.to_string (U60.show numb))
(Kind.Term.show.go (Kind.Term.op2 orig operator left right)) = (Kind.Printer.text (List.cons "(" (List.cons (Kind.Operator.show operator) (List.cons " " (List.cons (Kind.Term.show left) (List.cons " " (List.cons (Kind.Term.show right) (List.cons ")" (List.nil)))))))))
// Kind.Term.show.sugar.string.go (term: (Kind.Term)) : (Maybe (String))
(Kind.Term.show.sugar.string.go (Kind.Term.ct0 (String.nil.) orig)) = (Maybe.some "")
(Kind.Term.show.sugar.string.go (Kind.Term.ct2 (String.cons.) orig (Kind.Term.num orig1 x0) x1)) = (Maybe.bind (Kind.Term.show.sugar.string.go x1) @tail (Maybe.pure (String.cons x0 tail)))
(Kind.Term.show.sugar.string.go other) = (Maybe.none)
// Kind.Term.show.sugar.string (term: (Kind.Term)) : (Maybe (String))
(Kind.Term.show.sugar.string term) = (Maybe.bind (Kind.Term.show.sugar.string.go term) @res let quot = (String.cons 39 ""); (Maybe.pure (Kind.Printer.text (List.cons quot (List.cons res (List.cons quot (List.nil)))))))
// Maybe.bind -(a: Type) -(b: Type) (ma: (Maybe a)) (mb: (_: a) (Maybe b)) : (Maybe b)
(Maybe.bind (Maybe.none) mb) = (Maybe.none)
(Maybe.bind (Maybe.some val) mb) = (mb val)
// Maybe.pure -(a: Type) (x: a) : (Maybe a)
(Maybe.pure x) = (Maybe.some x)
// Show.to_string (show: (Show)) : (String)
(Show.to_string show) = (show "")
// Show : Type
(Show) = 0
// U60.show (n: U60) : (Show)
(U60.show 0) = @str (String.cons 48 str)
(U60.show n) = @str let next = (String.cons (+ 48 (% n 10)) str); let func = (U60.if (< n 10) @h h @h ((U60.show (/ n 10)) h)); (func next)
// U60.if -(r: Type) (n: U60) (t: r) (f: r) : r
(U60.if 0 t f) = f
(U60.if x t f) = t
// Maybe.try -(a: Type) (ls: (List (Maybe a))) (alt: a) : a
(Maybe.try (List.nil) alt) = alt
(Maybe.try (List.cons maybe xs) alt) = (Maybe.match maybe (Maybe.try xs alt) @maybe.value maybe.value)
// Maybe.match -(t: Type) (x: (Maybe t)) -(p: (x: (Maybe t)) Type) (none: (p (Maybe.none t))) (some: (value: t) (p (Maybe.some t value))) : (p x)
(Maybe.match (Maybe.none) none some) = none
(Maybe.match (Maybe.some value_) none some) = (some value_)
// Kind.Term.show.sugar.list.go (term: (Kind.Term)) : (Maybe (List (String)))
(Kind.Term.show.sugar.list.go (Kind.Term.ct0 (List.nil.) orig)) = (Maybe.some (List.nil))
(Kind.Term.show.sugar.list.go (Kind.Term.ct2 (List.cons.) orig x0 x1)) = (Maybe.bind (Kind.Term.show.sugar.list.go x1) @tail (Maybe.pure (List.cons (Kind.Term.show x0) tail)))
(Kind.Term.show.sugar.list.go other) = (Maybe.none)
// Kind.Term.show.sugar.list (term: (Kind.Term)) : (Maybe (String))
(Kind.Term.show.sugar.list term) = (Maybe.bind (Kind.Term.show.sugar.list.go term) @res (Maybe.pure (Kind.Printer.text (List.cons "[" (List.cons (String.join " " res) (List.cons "]" (List.nil)))))))
// String.join (sep: (String)) (list: (List (String))) : (String)
(String.join sep list) = (String.intercalate sep list)
// String.intercalate (sep: (String)) (xs: (List (String))) : (String)
(String.intercalate sep xs) = (String.flatten (List.intersperse sep xs))
// String.flatten (xs: (List (String))) : (String)
(String.flatten (List.nil)) = ""
(String.flatten (List.cons head tail)) = (String.concat head (String.flatten tail))
// List.intersperse -(a: Type) (sep: a) (xs: (List a)) : (List a)
(List.intersperse sep (List.nil)) = (List.nil)
(List.intersperse sep (List.cons xh (List.nil))) = (List.pure xh)
(List.intersperse sep (List.cons xh xt)) = (List.cons xh (List.cons sep (List.intersperse sep xt)))
// List.pure -(t: Type) (x: t) : (List t)
(List.pure x) = (List.cons x (List.nil))
// Kind.Term.show.sugar.sigma (term: (Kind.Term)) : (Maybe (String))
(Kind.Term.show.sugar.sigma (Kind.Term.ct2 (Sigma.) orig typ (Kind.Term.lam orig_ name body))) = (Maybe.some (Kind.Printer.text (List.cons "([" (List.cons (Kind.Name.show name) (List.cons ": " (List.cons (Kind.Term.show typ) (List.cons "] -> " (List.cons (Kind.Term.show (body (Kind.Term.var orig_ name 0))) (List.cons ")" (List.nil))))))))))
(Kind.Term.show.sugar.sigma term) = (Maybe.none)
// Kind.Name.show.go (name: U60) (chrs: (String)) : (String)
(Kind.Name.show.go name chrs) = (U60.if (== name 0) chrs let val = (% name 64); let chr = (U60.if (== val 0) 46 (U60.if (& (<= 1 val) (<= val 10)) (+ (- val 1) 48) (U60.if (& (<= 11 val) (<= val 36)) (+ (- val 11) 65) (U60.if (& (<= 37 val) (<= val 62)) (+ (- val 37) 97) (U60.if (== val 63) 95 63))))); (Kind.Name.show.go (/ name 64) (String.cons chr chrs)))
// Kind.Name.show (name: U60) : (String)
(Kind.Name.show name) = (Kind.Name.show.go name "")
// Kind.Operator.show (op: (Kind.Operator)) : (String)
(Kind.Operator.show (Kind.Operator.add)) = "+"
(Kind.Operator.show (Kind.Operator.sub)) = "-"
(Kind.Operator.show (Kind.Operator.mul)) = "*"
(Kind.Operator.show (Kind.Operator.div)) = "/"
(Kind.Operator.show (Kind.Operator.mod)) = "%"
(Kind.Operator.show (Kind.Operator.and)) = "&"
(Kind.Operator.show (Kind.Operator.or)) = "|"
(Kind.Operator.show (Kind.Operator.xor)) = "^"
(Kind.Operator.show (Kind.Operator.shl)) = "<<"
(Kind.Operator.show (Kind.Operator.shr)) = ">>"
(Kind.Operator.show (Kind.Operator.ltn)) = "<"
(Kind.Operator.show (Kind.Operator.lte)) = "<="
(Kind.Operator.show (Kind.Operator.eql)) = "=="
(Kind.Operator.show (Kind.Operator.gte)) = ">="
(Kind.Operator.show (Kind.Operator.gtn)) = ">"
(Kind.Operator.show (Kind.Operator.neq)) = "!="
// String.new_line : (String)
(String.new_line) = (String.pure (Char.newline))
// String.pure (x: (Char)) : (String)
(String.pure x) = (String.cons x "")
// Char : Type
(Char) = 0
// Char.newline : (Char)
(Char.newline) = 10
// Kind.Term.set_origin (new_origin: U60) (term: (Kind.Term)) : (Kind.Term)
(Kind.Term.set_origin new_origin (Kind.Term.typ old_orig)) = (Kind.Term.typ new_origin)
(Kind.Term.set_origin new_origin (Kind.Term.var old_orig name idx)) = (Kind.Term.var new_origin name idx)
(Kind.Term.set_origin new_origin (Kind.Term.hol old_orig numb)) = (Kind.Term.hol new_origin numb)
(Kind.Term.set_origin new_origin (Kind.Term.all old_orig name typ body)) = (Kind.Term.all new_origin name typ body)
(Kind.Term.set_origin new_origin (Kind.Term.lam old_orig name body)) = (Kind.Term.lam new_origin name body)
(Kind.Term.set_origin new_origin (Kind.Term.let old_orig name expr body)) = (Kind.Term.let new_origin name expr body)
(Kind.Term.set_origin new_origin (Kind.Term.ann old_orig expr typ)) = (Kind.Term.ann new_origin expr typ)
(Kind.Term.set_origin new_origin (Kind.Term.sub old_orig name indx redx expr)) = (Kind.Term.sub new_origin name indx redx expr)
(Kind.Term.set_origin new_origin (Kind.Term.app old_orig func arg)) = (Kind.Term.app new_origin func arg)
(Kind.Term.set_origin new_origin (Kind.Term.hlp old_orig)) = (Kind.Term.hlp new_origin)
(Kind.Term.set_origin new_origin (Kind.Term.u60 old_orig)) = (Kind.Term.u60 new_origin)
(Kind.Term.set_origin new_origin (Kind.Term.num old_orig num)) = (Kind.Term.num new_origin num)
(Kind.Term.set_origin new_origin (Kind.Term.op2 old_orig op left right)) = (Kind.Term.op2 new_origin op left right)
(Kind.Term.set_origin new_origin (Kind.Term.ct0 ctid old_orig)) = (Kind.Term.ct0 ctid new_origin)
(Kind.Term.set_origin new_origin (Kind.Term.ct1 ctid old_orig x0)) = (Kind.Term.ct1 ctid new_origin x0)
(Kind.Term.set_origin new_origin (Kind.Term.ct2 ctid old_orig x0 x1)) = (Kind.Term.ct2 ctid new_origin x0 x1)
(Kind.Term.set_origin new_origin (Kind.Term.ct3 ctid old_orig x0 x1 x2)) = (Kind.Term.ct3 ctid new_origin x0 x1 x2)
(Kind.Term.set_origin new_origin (Kind.Term.ct4 ctid old_orig x0 x1 x2 x3)) = (Kind.Term.ct4 ctid new_origin x0 x1 x2 x3)
(Kind.Term.set_origin new_origin (Kind.Term.ct5 ctid old_orig x0 x1 x2 x3 x4)) = (Kind.Term.ct5 ctid new_origin x0 x1 x2 x3 x4)
(Kind.Term.set_origin new_origin (Kind.Term.ct6 ctid old_orig x0 x1 x2 x3 x4 x5)) = (Kind.Term.ct6 ctid new_origin x0 x1 x2 x3 x4 x5)
(Kind.Term.set_origin new_origin (Kind.Term.ct7 ctid old_orig x0 x1 x2 x3 x4 x5 x6)) = (Kind.Term.ct7 ctid new_origin x0 x1 x2 x3 x4 x5 x6)
(Kind.Term.set_origin new_origin (Kind.Term.ct8 ctid old_orig x0 x1 x2 x3 x4 x5 x6 x7)) = (Kind.Term.ct8 ctid new_origin x0 x1 x2 x3 x4 x5 x6 x7)
(Kind.Term.set_origin new_origin (Kind.Term.ct9 ctid old_orig x0 x1 x2 x3 x4 x5 x6 x7 x8)) = (Kind.Term.ct9 ctid new_origin x0 x1 x2 x3 x4 x5 x6 x7 x8)
(Kind.Term.set_origin new_origin (Kind.Term.ct10 ctid old_orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9)) = (Kind.Term.ct10 ctid new_origin x0 x1 x2 x3 x4 x5 x6 x7 x8 x9)
(Kind.Term.set_origin new_origin (Kind.Term.ct11 ctid old_orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10)) = (Kind.Term.ct11 ctid new_origin x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10)
(Kind.Term.set_origin new_origin (Kind.Term.ct12 ctid old_orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11)) = (Kind.Term.ct12 ctid new_origin x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11)
(Kind.Term.set_origin new_origin (Kind.Term.ct13 ctid old_orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12)) = (Kind.Term.ct13 ctid new_origin x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12)
(Kind.Term.set_origin new_origin (Kind.Term.ct14 ctid old_orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13)) = (Kind.Term.ct14 ctid new_origin x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13)
(Kind.Term.set_origin new_origin (Kind.Term.ct15 ctid old_orig args)) = (Kind.Term.ct15 ctid new_origin args)
(Kind.Term.set_origin new_origin (Kind.Term.ct16 ctid old_orig args)) = (Kind.Term.ct16 ctid new_origin args)
(Kind.Term.set_origin new_origin (Kind.Term.fn0 fnid old_orig)) = (Kind.Term.fn0 fnid new_origin)
(Kind.Term.set_origin new_origin (Kind.Term.fn1 fnid old_orig x0)) = (Kind.Term.fn1 fnid new_origin x0)
(Kind.Term.set_origin new_origin (Kind.Term.fn2 fnid old_orig x0 x1)) = (Kind.Term.fn2 fnid new_origin x0 x1)
(Kind.Term.set_origin new_origin (Kind.Term.fn3 fnid old_orig x0 x1 x2)) = (Kind.Term.fn3 fnid new_origin x0 x1 x2)
(Kind.Term.set_origin new_origin (Kind.Term.fn4 fnid old_orig x0 x1 x2 x3)) = (Kind.Term.fn4 fnid new_origin x0 x1 x2 x3)
(Kind.Term.set_origin new_origin (Kind.Term.fn5 fnid old_orig x0 x1 x2 x3 x4)) = (Kind.Term.fn5 fnid new_origin x0 x1 x2 x3 x4)
(Kind.Term.set_origin new_origin (Kind.Term.fn6 fnid old_orig x0 x1 x2 x3 x4 x5)) = (Kind.Term.fn6 fnid new_origin x0 x1 x2 x3 x4 x5)
(Kind.Term.set_origin new_origin (Kind.Term.fn7 fnid old_orig x0 x1 x2 x3 x4 x5 x6)) = (Kind.Term.fn7 fnid new_origin x0 x1 x2 x3 x4 x5 x6)
(Kind.Term.set_origin new_origin (Kind.Term.fn8 fnid old_orig x0 x1 x2 x3 x4 x5 x6 x7)) = (Kind.Term.fn8 fnid new_origin x0 x1 x2 x3 x4 x5 x6 x7)
(Kind.Term.set_origin new_origin (Kind.Term.fn9 fnid old_orig x0 x1 x2 x3 x4 x5 x6 x7 x8)) = (Kind.Term.fn9 fnid new_origin x0 x1 x2 x3 x4 x5 x6 x7 x8)
(Kind.Term.set_origin new_origin (Kind.Term.fn10 fnid old_orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9)) = (Kind.Term.fn10 fnid new_origin x0 x1 x2 x3 x4 x5 x6 x7 x8 x9)
(Kind.Term.set_origin new_origin (Kind.Term.fn11 fnid old_orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10)) = (Kind.Term.fn11 fnid new_origin x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10)
(Kind.Term.set_origin new_origin (Kind.Term.fn12 fnid old_orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11)) = (Kind.Term.fn12 fnid new_origin x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11)
(Kind.Term.set_origin new_origin (Kind.Term.fn13 fnid old_orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12)) = (Kind.Term.fn13 fnid new_origin x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12)
(Kind.Term.set_origin new_origin (Kind.Term.fn14 fnid old_orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13)) = (Kind.Term.fn14 fnid new_origin x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13)
(Kind.Term.set_origin new_origin (Kind.Term.fn15 ctid old_orig args)) = (Kind.Term.fn15 ctid new_origin args)
(Kind.Term.set_origin new_origin (Kind.Term.fn16 ctid old_orig args)) = (Kind.Term.fn16 ctid new_origin args)
// Kind.API.check_all : (String)
(Kind.API.check_all) = let output = (Kind.API.output (List.reverse (Kind.API.check_functions (Functions)))); (Bool.if (String.is_nil output) (Kind.Printer.text (List.cons "All terms check." (List.cons (String.new_line) (List.cons (String.new_line) (List.nil))))) output)
// Kind.API.check_functions (fnid: (List U60)) : (List (Pair U60 (List (Kind.Result (Unit)))))
(Kind.API.check_functions (List.nil)) = (List.nil)
(Kind.API.check_functions (List.cons f fs)) = let head = (Pair.new f (Kind.API.check_function f)); let tail = (Kind.API.check_functions fs); (List.cons head tail)
// Kind.API.check_function (fnid: U60) : (List (Kind.Result (Unit)))
(Kind.API.check_function fnid) = let rules = (RuleOf fnid); let type = (TypeOf fnid); let type_check = (Kind.Checker.run (Kind.Checker.unify (Kind.Checker.check type (Kind.Term.typ 0))) (Bool.true)); let rule_check = (Kind.API.check_function.rules rules (Kind.Term.eval type)); (List.cons type_check rule_check)
// Kind.API.check_function.rules (rules: (List (Kind.Rule))) (type: (Kind.Term)) : (List (Kind.Result (Unit)))
(Kind.API.check_function.rules (List.nil) type) = (List.nil)
(Kind.API.check_function.rules (List.cons rule rules) type) = let head = (Kind.Checker.run (Kind.Checker.unify (Kind.Checker.rule rule type)) (Bool.false)); let tail = (Kind.API.check_function.rules rules type); (List.cons head tail)
// Kind.Term.eval (term: (Kind.Term)) : (Kind.Term)
(Kind.Term.eval (Kind.Term.typ orig)) = (Kind.Term.typ orig)
(Kind.Term.eval (Kind.Term.var orig name index)) = (Kind.Term.var orig name index)
(Kind.Term.eval (Kind.Term.hol orig numb)) = (Kind.Term.hol orig numb)
(Kind.Term.eval (Kind.Term.all orig name typ body)) = (Kind.Term.all orig name (Kind.Term.eval typ) @x (Kind.Term.eval (body x)))
(Kind.Term.eval (Kind.Term.lam orig name body)) = (Kind.Term.lam orig name @x (Kind.Term.eval (body x)))
(Kind.Term.eval (Kind.Term.let orig name expr body)) = (Kind.Term.eval_let orig name (Kind.Term.eval expr) @x (Kind.Term.eval (body x)))
(Kind.Term.eval (Kind.Term.ann orig expr typ)) = (Kind.Term.eval_ann orig (Kind.Term.eval expr) (Kind.Term.eval typ))
(Kind.Term.eval (Kind.Term.sub orig name indx redx expr)) = (Kind.Term.eval_sub orig name indx redx (Kind.Term.eval expr))
(Kind.Term.eval (Kind.Term.app orig expr typ)) = (Kind.Term.eval_app orig (Kind.Term.eval expr) (Kind.Term.eval typ))
(Kind.Term.eval (Kind.Term.hlp orig)) = (Kind.Term.hlp orig)
(Kind.Term.eval (Kind.Term.u60 orig)) = (Kind.Term.u60 orig)
(Kind.Term.eval (Kind.Term.num orig num)) = (Kind.Term.num orig num)
(Kind.Term.eval (Kind.Term.op2 orig op left right)) = (Kind.Term.eval_op orig op (Kind.Term.eval left) (Kind.Term.eval right))
(Kind.Term.eval (Kind.Term.ct0 ctid orig)) = (Kind.Term.ct0 ctid orig)
(Kind.Term.eval (Kind.Term.ct1 ctid orig x0)) = (Kind.Term.ct1 ctid orig (Kind.Term.eval x0))
(Kind.Term.eval (Kind.Term.ct2 ctid orig x0 x1)) = (Kind.Term.ct2 ctid orig (Kind.Term.eval x0) (Kind.Term.eval x1))
(Kind.Term.eval (Kind.Term.ct3 ctid orig x0 x1 x2)) = (Kind.Term.ct3 ctid orig (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2))
(Kind.Term.eval (Kind.Term.ct4 ctid orig x0 x1 x2 x3)) = (Kind.Term.ct4 ctid orig (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2) (Kind.Term.eval x3))
(Kind.Term.eval (Kind.Term.ct5 ctid orig x0 x1 x2 x3 x4)) = (Kind.Term.ct5 ctid orig (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2) (Kind.Term.eval x3) (Kind.Term.eval x4))
(Kind.Term.eval (Kind.Term.ct6 ctid orig x0 x1 x2 x3 x4 x5)) = (Kind.Term.ct6 ctid orig (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2) (Kind.Term.eval x3) (Kind.Term.eval x4) (Kind.Term.eval x5))
(Kind.Term.eval (Kind.Term.ct7 ctid orig x0 x1 x2 x3 x4 x5 x6)) = (Kind.Term.ct7 ctid orig (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2) (Kind.Term.eval x3) (Kind.Term.eval x4) (Kind.Term.eval x5) (Kind.Term.eval x6))
(Kind.Term.eval (Kind.Term.ct8 ctid orig x0 x1 x2 x3 x4 x5 x6 x7)) = (Kind.Term.ct8 ctid orig (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2) (Kind.Term.eval x3) (Kind.Term.eval x4) (Kind.Term.eval x5) (Kind.Term.eval x6) (Kind.Term.eval x7))
(Kind.Term.eval (Kind.Term.ct9 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8)) = (Kind.Term.ct9 ctid orig (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2) (Kind.Term.eval x3) (Kind.Term.eval x4) (Kind.Term.eval x5) (Kind.Term.eval x6) (Kind.Term.eval x7) (Kind.Term.eval x8))
(Kind.Term.eval (Kind.Term.ct10 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9)) = (Kind.Term.ct10 ctid orig (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2) (Kind.Term.eval x3) (Kind.Term.eval x4) (Kind.Term.eval x5) (Kind.Term.eval x6) (Kind.Term.eval x7) (Kind.Term.eval x8) (Kind.Term.eval x9))
(Kind.Term.eval (Kind.Term.ct11 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10)) = (Kind.Term.ct11 ctid orig (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2) (Kind.Term.eval x3) (Kind.Term.eval x4) (Kind.Term.eval x5) (Kind.Term.eval x6) (Kind.Term.eval x7) (Kind.Term.eval x8) (Kind.Term.eval x9) (Kind.Term.eval x10))
(Kind.Term.eval (Kind.Term.ct12 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11)) = (Kind.Term.ct12 ctid orig (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2) (Kind.Term.eval x3) (Kind.Term.eval x4) (Kind.Term.eval x5) (Kind.Term.eval x6) (Kind.Term.eval x7) (Kind.Term.eval x8) (Kind.Term.eval x9) (Kind.Term.eval x10) (Kind.Term.eval x11))
(Kind.Term.eval (Kind.Term.ct13 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12)) = (Kind.Term.ct13 ctid orig (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2) (Kind.Term.eval x3) (Kind.Term.eval x4) (Kind.Term.eval x5) (Kind.Term.eval x6) (Kind.Term.eval x7) (Kind.Term.eval x8) (Kind.Term.eval x9) (Kind.Term.eval x10) (Kind.Term.eval x11) (Kind.Term.eval x12))
(Kind.Term.eval (Kind.Term.ct14 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13)) = (Kind.Term.ct14 ctid orig (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2) (Kind.Term.eval x3) (Kind.Term.eval x4) (Kind.Term.eval x5) (Kind.Term.eval x6) (Kind.Term.eval x7) (Kind.Term.eval x8) (Kind.Term.eval x9) (Kind.Term.eval x10) (Kind.Term.eval x11) (Kind.Term.eval x12) (Kind.Term.eval x13))
(Kind.Term.eval (Kind.Term.ct15 fnid orig x0)) = (Kind.Term.ct15 fnid orig (Kind.Term.eval x0))
(Kind.Term.eval (Kind.Term.ct16 fnid orig x0)) = (Kind.Term.ct16 fnid orig (Kind.Term.eval x0))
(Kind.Term.eval (Kind.Term.fn0 fnid orig)) = (Kind.Term.FN0 fnid orig)
(Kind.Term.eval (Kind.Term.fn1 fnid orig x0)) = (Kind.Term.FN1 fnid orig (Kind.Term.eval x0))
(Kind.Term.eval (Kind.Term.fn2 fnid orig x0 x1)) = (Kind.Term.FN2 fnid orig (Kind.Term.eval x0) (Kind.Term.eval x1))
(Kind.Term.eval (Kind.Term.fn3 fnid orig x0 x1 x2)) = (Kind.Term.FN3 fnid orig (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2))
(Kind.Term.eval (Kind.Term.fn4 fnid orig x0 x1 x2 x3)) = (Kind.Term.FN4 fnid orig (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2) (Kind.Term.eval x3))
(Kind.Term.eval (Kind.Term.fn5 fnid orig x0 x1 x2 x3 x4)) = (Kind.Term.FN5 fnid orig (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2) (Kind.Term.eval x3) (Kind.Term.eval x4))
(Kind.Term.eval (Kind.Term.fn6 fnid orig x0 x1 x2 x3 x4 x5)) = (Kind.Term.FN6 fnid orig (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2) (Kind.Term.eval x3) (Kind.Term.eval x4) (Kind.Term.eval x5))
(Kind.Term.eval (Kind.Term.fn7 fnid orig x0 x1 x2 x3 x4 x5 x6)) = (Kind.Term.FN7 fnid orig (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2) (Kind.Term.eval x3) (Kind.Term.eval x4) (Kind.Term.eval x5) (Kind.Term.eval x6))
(Kind.Term.eval (Kind.Term.fn8 fnid orig x0 x1 x2 x3 x4 x5 x6 x7)) = (Kind.Term.FN8 fnid orig (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2) (Kind.Term.eval x3) (Kind.Term.eval x4) (Kind.Term.eval x5) (Kind.Term.eval x6) (Kind.Term.eval x7))
(Kind.Term.eval (Kind.Term.fn9 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8)) = (Kind.Term.FN9 fnid orig (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2) (Kind.Term.eval x3) (Kind.Term.eval x4) (Kind.Term.eval x5) (Kind.Term.eval x6) (Kind.Term.eval x7) (Kind.Term.eval x8))
(Kind.Term.eval (Kind.Term.fn10 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9)) = (Kind.Term.FN10 fnid orig (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2) (Kind.Term.eval x3) (Kind.Term.eval x4) (Kind.Term.eval x5) (Kind.Term.eval x6) (Kind.Term.eval x7) (Kind.Term.eval x8) (Kind.Term.eval x9))
(Kind.Term.eval (Kind.Term.fn11 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10)) = (Kind.Term.FN11 fnid orig (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2) (Kind.Term.eval x3) (Kind.Term.eval x4) (Kind.Term.eval x5) (Kind.Term.eval x6) (Kind.Term.eval x7) (Kind.Term.eval x8) (Kind.Term.eval x9) (Kind.Term.eval x10))
(Kind.Term.eval (Kind.Term.fn12 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11)) = (Kind.Term.FN12 fnid orig (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2) (Kind.Term.eval x3) (Kind.Term.eval x4) (Kind.Term.eval x5) (Kind.Term.eval x6) (Kind.Term.eval x7) (Kind.Term.eval x8) (Kind.Term.eval x9) (Kind.Term.eval x10) (Kind.Term.eval x11))
(Kind.Term.eval (Kind.Term.fn13 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12)) = (Kind.Term.FN13 fnid orig (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2) (Kind.Term.eval x3) (Kind.Term.eval x4) (Kind.Term.eval x5) (Kind.Term.eval x6) (Kind.Term.eval x7) (Kind.Term.eval x8) (Kind.Term.eval x9) (Kind.Term.eval x10) (Kind.Term.eval x11) (Kind.Term.eval x12))
(Kind.Term.eval (Kind.Term.fn14 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13)) = (Kind.Term.FN14 fnid orig (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2) (Kind.Term.eval x3) (Kind.Term.eval x4) (Kind.Term.eval x5) (Kind.Term.eval x6) (Kind.Term.eval x7) (Kind.Term.eval x8) (Kind.Term.eval x9) (Kind.Term.eval x10) (Kind.Term.eval x11) (Kind.Term.eval x12) (Kind.Term.eval x13))
(Kind.Term.eval (Kind.Term.fn15 fnid orig x0)) = (Kind.Term.FN15 fnid orig (Kind.Term.eval x0))
(Kind.Term.eval (Kind.Term.fn16 fnid orig x0)) = (Kind.Term.FN16 fnid orig (Kind.Term.eval x0))
(Kind.Term.eval (Kind.Term.args15 x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14)) = (Kind.Term.args15 (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2) (Kind.Term.eval x3) (Kind.Term.eval x4) (Kind.Term.eval x5) (Kind.Term.eval x6) (Kind.Term.eval x7) (Kind.Term.eval x8) (Kind.Term.eval x9) (Kind.Term.eval x10) (Kind.Term.eval x11) (Kind.Term.eval x12) (Kind.Term.eval x13) (Kind.Term.eval x14))
(Kind.Term.eval (Kind.Term.args16 x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15)) = (Kind.Term.args16 (Kind.Term.eval x0) (Kind.Term.eval x1) (Kind.Term.eval x2) (Kind.Term.eval x3) (Kind.Term.eval x4) (Kind.Term.eval x5) (Kind.Term.eval x6) (Kind.Term.eval x7) (Kind.Term.eval x8) (Kind.Term.eval x9) (Kind.Term.eval x10) (Kind.Term.eval x11) (Kind.Term.eval x12) (Kind.Term.eval x13) (Kind.Term.eval x14) (Kind.Term.eval x15))
// Kind.Term.eval_sub (orig: U60) (name: U60) (indx: U60) (redx: U60) (expr: (Kind.Term)) : (Kind.Term)
(Kind.Term.eval_sub orig name indx redx expr) = expr
// Kind.Term.eval_app (orig: U60) (left: (Kind.Term)) (right: (Kind.Term)) : (Kind.Term)
(Kind.Term.eval_app orig (Kind.Term.lam orig1 name body) arg) = (body arg)
(Kind.Term.eval_app orig func arg) = (Kind.Term.app orig func arg)
// Kind.Term.eval_ann (orig: U60) (expr: (Kind.Term)) (type: (Kind.Term)) : (Kind.Term)
(Kind.Term.eval_ann orig expr type) = expr
// Kind.Term.eval_let (orig: U60) (name: U60) (expr: (Kind.Term)) (body: (_: (Kind.Term)) (Kind.Term)) : (Kind.Term)
(Kind.Term.eval_let orig name expr body) = (body expr)
// Kind.Term.eval_op (orig: U60) (op: (Kind.Operator)) (left: (Kind.Term)) (right: (Kind.Term)) : (Kind.Term)
(Kind.Term.eval_op orig (Kind.Operator.add) (Kind.Term.num a.orig a.num) (Kind.Term.num b.orig b.num)) = (Kind.Term.num 0 (+ a.num b.num))
(Kind.Term.eval_op orig (Kind.Operator.sub) (Kind.Term.num a.orig a.num) (Kind.Term.num b.orig b.num)) = (Kind.Term.num 0 (- a.num b.num))
(Kind.Term.eval_op orig (Kind.Operator.mul) (Kind.Term.num a.orig a.num) (Kind.Term.num b.orig b.num)) = (Kind.Term.num 0 (* a.num b.num))
(Kind.Term.eval_op orig (Kind.Operator.div) (Kind.Term.num a.orig a.num) (Kind.Term.num b.orig b.num)) = (Kind.Term.num 0 (/ a.num b.num))
(Kind.Term.eval_op orig (Kind.Operator.mod) (Kind.Term.num a.orig a.num) (Kind.Term.num b.orig b.num)) = (Kind.Term.num 0 (% a.num b.num))
(Kind.Term.eval_op orig (Kind.Operator.and) (Kind.Term.num a.orig a.num) (Kind.Term.num b.orig b.num)) = (Kind.Term.num 0 (& a.num b.num))
(Kind.Term.eval_op orig (Kind.Operator.or) (Kind.Term.num a.orig a.num) (Kind.Term.num b.orig b.num)) = (Kind.Term.num 0 (| a.num b.num))
(Kind.Term.eval_op orig (Kind.Operator.xor) (Kind.Term.num a.orig a.num) (Kind.Term.num b.orig b.num)) = (Kind.Term.num 0 (^ a.num b.num))
(Kind.Term.eval_op orig (Kind.Operator.shl) (Kind.Term.num a.orig a.num) (Kind.Term.num b.orig b.num)) = (Kind.Term.num 0 (<< a.num b.num))
(Kind.Term.eval_op orig (Kind.Operator.shr) (Kind.Term.num a.orig a.num) (Kind.Term.num b.orig b.num)) = (Kind.Term.num 0 (>> a.num b.num))
(Kind.Term.eval_op orig (Kind.Operator.ltn) (Kind.Term.num a.orig a.num) (Kind.Term.num b.orig b.num)) = (Kind.Term.num 0 (< a.num b.num))
(Kind.Term.eval_op orig (Kind.Operator.lte) (Kind.Term.num a.orig a.num) (Kind.Term.num b.orig b.num)) = (Kind.Term.num 0 (<= a.num b.num))
(Kind.Term.eval_op orig (Kind.Operator.eql) (Kind.Term.num a.orig a.num) (Kind.Term.num b.orig b.num)) = (Kind.Term.num 0 (== a.num b.num))
(Kind.Term.eval_op orig (Kind.Operator.gte) (Kind.Term.num a.orig a.num) (Kind.Term.num b.orig b.num)) = (Kind.Term.num 0 (>= a.num b.num))
(Kind.Term.eval_op orig (Kind.Operator.gtn) (Kind.Term.num a.orig a.num) (Kind.Term.num b.orig b.num)) = (Kind.Term.num 0 (> a.num b.num))
(Kind.Term.eval_op orig (Kind.Operator.neq) (Kind.Term.num a.orig a.num) (Kind.Term.num b.orig b.num)) = (Kind.Term.num 0 (!= a.num b.num))
(Kind.Term.eval_op orig op left right) = (Kind.Term.op2 orig op left right)
// Kind.Checker.unify (checker: (Kind.Checker (Unit))) : (Kind.Checker (Unit))
(Kind.Checker.unify checker) = (Kind.Checker.bind checker @_ (Kind.Checker.bind (Kind.Checker.get_equations) @equations (Kind.Checker.unify.go equations (List.nil) (Bool.false))))
// Kind.Checker.unify.go (equations: (List (Kind.Equation))) (unsolved: (List (Kind.Equation))) (changed: (Bool)) : (Kind.Checker (Unit))
(Kind.Checker.unify.go (List.nil) (List.nil) changed) = (Kind.Checker.pure (Unit.new))
(Kind.Checker.unify.go (List.nil) unsolved (Bool.true)) = (Kind.Checker.unify.go unsolved (List.nil) (Bool.false))
(Kind.Checker.unify.go (List.nil) unsolved (Bool.false)) = (Kind.Checker.unify.go.fail unsolved)
(Kind.Checker.unify.go (List.cons (Kind.Equation.new ctx orig left right) equations) unsolved changed) = (Kind.Checker.bind (Kind.Checker.with_context (Kind.Checker.equal (Kind.Term.eval left) (Kind.Term.eval right)) ctx) @is_equal let unify = (Bool.if is_equal @equations @unsolved (Kind.Checker.unify.go equations unsolved (Bool.true)) @equations @unsolved let eqt = (Kind.Equation.new ctx orig left right); (Kind.Checker.unify.go equations (List.cons eqt unsolved) changed)); ((unify equations) unsolved))
// Kind.Checker.unify.go.fail (equations: (List (Kind.Equation))) : (Kind.Checker (Unit))
(Kind.Checker.unify.go.fail (List.nil)) = (Kind.Checker.pure (Unit.new))
(Kind.Checker.unify.go.fail (List.cons (Kind.Equation.new ctx orig left right) eqts)) = (Kind.Checker.bind (Kind.Checker.error (Kind.Error.type_mismatch ctx orig left right) (Unit.new)) @_ (Kind.Checker.unify.go.fail eqts))
// Kind.Checker (a: Type) : Type
(Kind.Checker a) = 0
// Kind.Checker.with_context -(a: Type) (checker: (Kind.Checker a)) (context: (Kind.Context)) : (Kind.Checker a)
(Kind.Checker.with_context checker new_context) = (Kind.Checker.bind (Kind.Checker.set_context new_context) @old_context (Kind.Checker.bind checker @got (Kind.Checker.bind (Kind.Checker.set_context old_context) @_ (Kind.Checker.pure got))))
// Kind.Checker.pure -(t: Type) (a: t) : (Kind.Checker t)
(Kind.Checker.pure res) = @context @depth @rhs @subst @eqts @errs (Kind.Result.checked context depth rhs subst eqts errs res)
// Kind.Checker.set_context (new_context: (Kind.Context)) : (Kind.Checker (Kind.Context))
(Kind.Checker.set_context new_context) = @old_context @depth @rhs @subst @eqts @errs (Kind.Result.checked new_context depth rhs subst eqts errs old_context)
// Kind.Checker.bind.result -(a: Type) -(b: Type) (result: (Kind.Result a)) (then: (_: a) (Kind.Checker b)) : (Kind.Result b)
(Kind.Checker.bind.result (Kind.Result.checked context depth rhs sub equations errs ret) then) = (((((((then ret) context) depth) rhs) sub) equations) errs)
(Kind.Checker.bind.result (Kind.Result.errored context sub errs) then) = (Kind.Result.errored context sub errs)
// Kind.Checker.bind -(a: Type) -(b: Type) (checker: (Kind.Checker a)) (then: (_: a) (Kind.Checker b)) : (Kind.Checker b)
(Kind.Checker.bind checker then) = @context @depth @rhs @subst @eqts @errs (Kind.Checker.bind.result ((((((checker context) depth) rhs) subst) eqts) errs) then)
// Kind.Checker.equal (left: (Kind.Term)) (right: (Kind.Term)) : (Kind.Checker (Bool))
(Kind.Checker.equal (Kind.Term.typ orig) (Kind.Term.typ orig1)) = (Kind.Checker.pure (Bool.true))
(Kind.Checker.equal (Kind.Term.all a.orig a.name a.type a.body) (Kind.Term.all b.orig b.name b.type b.body)) = (Kind.Checker.bind (Kind.Checker.get_depth) @dep (Kind.Checker.bind (Kind.Checker.equal a.type b.type) @type (Kind.Checker.bind (Kind.Checker.extended (Kind.Checker.equal (a.body (Kind.Term.var a.orig a.name dep)) (b.body (Kind.Term.var b.orig b.name dep))) (Null) (Null) (List.nil)) @body (Kind.Checker.pure (Bool.and type body)))))
(Kind.Checker.equal (Kind.Term.lam a.orig a.name a.body) (Kind.Term.lam b.orig b.name b.body)) = (Kind.Checker.bind (Kind.Checker.get_depth) @dep (Kind.Checker.bind (Kind.Checker.extended (Kind.Checker.equal (a.body (Kind.Term.var a.orig a.name dep)) (b.body (Kind.Term.var b.orig b.name dep))) (Null) (Null) (List.nil)) @body (Kind.Checker.pure body)))
(Kind.Checker.equal (Kind.Term.app a.orig a.func a.argm) (Kind.Term.app b.orig b.func b.argm)) = (Kind.Checker.bind (Kind.Checker.equal a.func b.func) @func (Kind.Checker.bind (Kind.Checker.equal a.argm b.argm) @argm (Kind.Checker.pure (Bool.and func argm))))
(Kind.Checker.equal (Kind.Term.let a.orig a.name a.expr a.body) (Kind.Term.let b.orig b.name b.expr b.body)) = (Kind.Checker.bind (Kind.Checker.get_depth) @dep (Kind.Checker.bind (Kind.Checker.equal a.expr b.expr) @expr (Kind.Checker.bind (Kind.Checker.extended (Kind.Checker.equal (a.body (Kind.Term.var a.orig a.name dep)) (b.body (Kind.Term.var b.orig b.name dep))) (Null) (Null) (List.nil)) @body (Kind.Checker.pure (Bool.and expr body)))))
(Kind.Checker.equal (Kind.Term.ann a.orig a.expr a.type) (Kind.Term.ann b.orig b.expr b.type)) = (Kind.Checker.bind (Kind.Checker.equal a.expr b.expr) @func (Kind.Checker.bind (Kind.Checker.equal a.type b.type) @type (Kind.Checker.pure (Bool.and func type))))
(Kind.Checker.equal (Kind.Term.sub a.orig a.name a.indx a.redx a.expr) (Kind.Term.sub b.orig b.name b.indx b.redx b.expr)) = (Kind.Checker.bind (Kind.Checker.equal a.expr b.expr) @func (Kind.Checker.pure func))
(Kind.Checker.equal (Kind.Term.u60 a.orig) (Kind.Term.u60 b.orig)) = (Kind.Checker.pure (Bool.true))
(Kind.Checker.equal (Kind.Term.num a.orig a.num) (Kind.Term.num b.orig b.num)) = (Kind.Checker.pure (U60.equal a.num b.num))
(Kind.Checker.equal (Kind.Term.op2 a.orig a.op a.val0 a.val1) (Kind.Term.op2 b.orig b.op b.val0 b.val1)) = let op = (Kind.Operator.equal a.op b.op); (Kind.Checker.bind (Kind.Checker.equal a.val0 b.val0) @val0 (Kind.Checker.bind (Kind.Checker.equal a.val1 b.val1) @val1 (Kind.Checker.pure (Bool.and op (Bool.and val0 val1)))))
(Kind.Checker.equal (Kind.Term.hol a.orig a.numb) (Kind.Term.hol b.orig b.numb)) = (Bool.if (U60.equal a.numb b.numb) (Kind.Checker.pure (Bool.true)) (Kind.Checker.equal.hol a.orig a.numb (Kind.Term.hol b.orig b.numb)))
(Kind.Checker.equal (Kind.Term.hol a.orig a.numb) b) = (Kind.Checker.equal.hol a.orig a.numb b)
(Kind.Checker.equal b (Kind.Term.hol a.orig a.numb)) = (Kind.Checker.equal.hol a.orig a.numb b)
(Kind.Checker.equal (Kind.Term.var a.orig a.name a.idx) b) = (Kind.Checker.bind (Kind.Checker.get_right_hand_side) @rhs (Kind.Checker.equal.var rhs a.orig a.name a.idx b))
(Kind.Checker.equal b (Kind.Term.var a.orig a.name a.idx)) = (Kind.Checker.bind (Kind.Checker.get_right_hand_side) @rhs (Kind.Checker.equal.var rhs a.orig a.name a.idx b))
(Kind.Checker.equal (Kind.Term.ct0 a.ctid a.orig) (Kind.Term.ct0 b.ctid b.orig)) = let ctid = (U60.equal (HashOf a.ctid) (HashOf b.ctid)); (Kind.Checker.pure ctid)
(Kind.Checker.equal (Kind.Term.ct1 a.ctid a.orig a.x0) (Kind.Term.ct1 b.ctid b.orig b.x0)) = let ctid = (U60.equal (HashOf a.ctid) (HashOf b.ctid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.pure (Bool.and ctid x0)))
(Kind.Checker.equal (Kind.Term.ct2 a.ctid a.orig a.x0 a.x1) (Kind.Term.ct2 b.ctid b.orig b.x0 b.x1)) = let ctid = (U60.equal (HashOf a.ctid) (HashOf b.ctid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.pure (Bool.and ctid (Bool.and x0 x1)))))
(Kind.Checker.equal (Kind.Term.ct3 a.ctid a.orig a.x0 a.x1 a.x2) (Kind.Term.ct3 b.ctid b.orig b.x0 b.x1 b.x2)) = let ctid = (U60.equal (HashOf a.ctid) (HashOf b.ctid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.pure (Bool.and ctid (Bool.and x0 (Bool.and x1 x2)))))))
(Kind.Checker.equal (Kind.Term.ct4 a.ctid a.orig a.x0 a.x1 a.x2 a.x3) (Kind.Term.ct4 b.ctid b.orig b.x0 b.x1 b.x2 b.x3)) = let ctid = (U60.equal (HashOf a.ctid) (HashOf b.ctid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.bind (Kind.Checker.equal a.x3 b.x3) @x3 (Kind.Checker.pure (Bool.and ctid (Bool.and x0 (Bool.and x1 (Bool.and x2 x3)))))))))
(Kind.Checker.equal (Kind.Term.ct5 a.ctid a.orig a.x0 a.x1 a.x2 a.x3 a.x4) (Kind.Term.ct5 b.ctid b.orig b.x0 b.x1 b.x2 b.x3 b.x4)) = let ctid = (U60.equal (HashOf a.ctid) (HashOf b.ctid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.bind (Kind.Checker.equal a.x3 b.x3) @x3 (Kind.Checker.bind (Kind.Checker.equal a.x4 b.x4) @x4 (Kind.Checker.pure (Bool.and ctid (Bool.and x0 (Bool.and x1 (Bool.and x2 (Bool.and x3 x4)))))))))))
(Kind.Checker.equal (Kind.Term.ct6 a.ctid a.orig a.x0 a.x1 a.x2 a.x3 a.x4 a.x5) (Kind.Term.ct6 b.ctid b.orig b.x0 b.x1 b.x2 b.x3 b.x4 b.x5)) = let ctid = (U60.equal (HashOf a.ctid) (HashOf b.ctid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.bind (Kind.Checker.equal a.x3 b.x3) @x3 (Kind.Checker.bind (Kind.Checker.equal a.x4 b.x4) @x4 (Kind.Checker.bind (Kind.Checker.equal a.x5 b.x5) @x5 (Kind.Checker.pure (Bool.and ctid (Bool.and x0 (Bool.and x1 (Bool.and x2 (Bool.and x3 (Bool.and x4 x5)))))))))))))
(Kind.Checker.equal (Kind.Term.ct7 a.ctid a.orig a.x0 a.x1 a.x2 a.x3 a.x4 a.x5 a.x6) (Kind.Term.ct7 b.ctid b.orig b.x0 b.x1 b.x2 b.x3 b.x4 b.x5 b.x6)) = let ctid = (U60.equal (HashOf a.ctid) (HashOf b.ctid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.bind (Kind.Checker.equal a.x3 b.x3) @x3 (Kind.Checker.bind (Kind.Checker.equal a.x4 b.x4) @x4 (Kind.Checker.bind (Kind.Checker.equal a.x5 b.x5) @x5 (Kind.Checker.bind (Kind.Checker.equal a.x6 b.x6) @x6 (Kind.Checker.pure (Bool.and ctid (Bool.and x0 (Bool.and x1 (Bool.and x2 (Bool.and x3 (Bool.and x4 (Bool.and x5 x6)))))))))))))))
(Kind.Checker.equal (Kind.Term.ct8 a.ctid a.orig a.x0 a.x1 a.x2 a.x3 a.x4 a.x5 a.x6 a.x7) (Kind.Term.ct8 b.ctid b.orig b.x0 b.x1 b.x2 b.x3 b.x4 b.x5 b.x6 b.x7)) = let ctid = (U60.equal (HashOf a.ctid) (HashOf b.ctid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.bind (Kind.Checker.equal a.x3 b.x3) @x3 (Kind.Checker.bind (Kind.Checker.equal a.x4 b.x4) @x4 (Kind.Checker.bind (Kind.Checker.equal a.x5 b.x5) @x5 (Kind.Checker.bind (Kind.Checker.equal a.x6 b.x6) @x6 (Kind.Checker.bind (Kind.Checker.equal a.x7 b.x7) @x7 (Kind.Checker.pure (Bool.and ctid (Bool.and x0 (Bool.and x1 (Bool.and x2 (Bool.and x3 (Bool.and x4 (Bool.and x5 (Bool.and x6 x7)))))))))))))))))
(Kind.Checker.equal (Kind.Term.ct9 a.ctid a.orig a.x0 a.x1 a.x2 a.x3 a.x4 a.x5 a.x6 a.x7 a.x8) (Kind.Term.ct9 b.ctid b.orig b.x0 b.x1 b.x2 b.x3 b.x4 b.x5 b.x6 b.x7 b.x8)) = let ctid = (U60.equal (HashOf a.ctid) (HashOf b.ctid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.bind (Kind.Checker.equal a.x3 b.x3) @x3 (Kind.Checker.bind (Kind.Checker.equal a.x4 b.x4) @x4 (Kind.Checker.bind (Kind.Checker.equal a.x5 b.x5) @x5 (Kind.Checker.bind (Kind.Checker.equal a.x6 b.x6) @x6 (Kind.Checker.bind (Kind.Checker.equal a.x7 b.x7) @x7 (Kind.Checker.bind (Kind.Checker.equal a.x8 b.x8) @x8 (Kind.Checker.pure (Bool.and ctid (Bool.and x0 (Bool.and x1 (Bool.and x2 (Bool.and x3 (Bool.and x4 (Bool.and x5 (Bool.and x6 (Bool.and x7 x8)))))))))))))))))))
(Kind.Checker.equal (Kind.Term.ct10 a.ctid a.orig a.x0 a.x1 a.x2 a.x3 a.x4 a.x5 a.x6 a.x7 a.x8 a.x9) (Kind.Term.ct10 b.ctid b.orig b.x0 b.x1 b.x2 b.x3 b.x4 b.x5 b.x6 b.x7 b.x8 b.x9)) = let ctid = (U60.equal (HashOf a.ctid) (HashOf b.ctid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.bind (Kind.Checker.equal a.x3 b.x3) @x3 (Kind.Checker.bind (Kind.Checker.equal a.x4 b.x4) @x4 (Kind.Checker.bind (Kind.Checker.equal a.x5 b.x5) @x5 (Kind.Checker.bind (Kind.Checker.equal a.x6 b.x6) @x6 (Kind.Checker.bind (Kind.Checker.equal a.x7 b.x7) @x7 (Kind.Checker.bind (Kind.Checker.equal a.x8 b.x8) @x8 (Kind.Checker.bind (Kind.Checker.equal a.x9 b.x9) @x9 (Kind.Checker.pure (Bool.and ctid (Bool.and x0 (Bool.and x1 (Bool.and x2 (Bool.and x3 (Bool.and x4 (Bool.and x5 (Bool.and x6 (Bool.and x7 (Bool.and x8 x9)))))))))))))))))))))
(Kind.Checker.equal (Kind.Term.ct11 a.ctid a.orig a.x0 a.x1 a.x2 a.x3 a.x4 a.x5 a.x6 a.x7 a.x8 a.x9 a.x10) (Kind.Term.ct11 b.ctid b.orig b.x0 b.x1 b.x2 b.x3 b.x4 b.x5 b.x6 b.x7 b.x8 b.x9 b.x10)) = let ctid = (U60.equal (HashOf a.ctid) (HashOf b.ctid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.bind (Kind.Checker.equal a.x3 b.x3) @x3 (Kind.Checker.bind (Kind.Checker.equal a.x4 b.x4) @x4 (Kind.Checker.bind (Kind.Checker.equal a.x5 b.x5) @x5 (Kind.Checker.bind (Kind.Checker.equal a.x6 b.x6) @x6 (Kind.Checker.bind (Kind.Checker.equal a.x7 b.x7) @x7 (Kind.Checker.bind (Kind.Checker.equal a.x8 b.x8) @x8 (Kind.Checker.bind (Kind.Checker.equal a.x9 b.x9) @x9 (Kind.Checker.bind (Kind.Checker.equal a.x10 b.x10) @x10 (Kind.Checker.pure (Bool.and ctid (Bool.and x0 (Bool.and x1 (Bool.and x2 (Bool.and x3 (Bool.and x4 (Bool.and x5 (Bool.and x6 (Bool.and x7 (Bool.and x8 (Bool.and x9 x10)))))))))))))))))))))))
(Kind.Checker.equal (Kind.Term.ct12 a.ctid a.orig a.x0 a.x1 a.x2 a.x3 a.x4 a.x5 a.x6 a.x7 a.x8 a.x9 a.x10 a.x11) (Kind.Term.ct12 b.ctid b.orig b.x0 b.x1 b.x2 b.x3 b.x4 b.x5 b.x6 b.x7 b.x8 b.x9 b.x10 b.x11)) = let ctid = (U60.equal (HashOf a.ctid) (HashOf b.ctid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.bind (Kind.Checker.equal a.x3 b.x3) @x3 (Kind.Checker.bind (Kind.Checker.equal a.x4 b.x4) @x4 (Kind.Checker.bind (Kind.Checker.equal a.x5 b.x5) @x5 (Kind.Checker.bind (Kind.Checker.equal a.x6 b.x6) @x6 (Kind.Checker.bind (Kind.Checker.equal a.x7 b.x7) @x7 (Kind.Checker.bind (Kind.Checker.equal a.x8 b.x8) @x8 (Kind.Checker.bind (Kind.Checker.equal a.x9 b.x9) @x9 (Kind.Checker.bind (Kind.Checker.equal a.x10 b.x10) @x10 (Kind.Checker.bind (Kind.Checker.equal a.x11 b.x11) @x11 (Kind.Checker.pure (Bool.and ctid (Bool.and x0 (Bool.and x1 (Bool.and x2 (Bool.and x3 (Bool.and x4 (Bool.and x5 (Bool.and x6 (Bool.and x7 (Bool.and x8 (Bool.and x9 (Bool.and x10 x11)))))))))))))))))))))))))
(Kind.Checker.equal (Kind.Term.ct13 a.ctid a.orig a.x0 a.x1 a.x2 a.x3 a.x4 a.x5 a.x6 a.x7 a.x8 a.x9 a.x10 a.x11 a.x12) (Kind.Term.ct13 b.ctid b.orig b.x0 b.x1 b.x2 b.x3 b.x4 b.x5 b.x6 b.x7 b.x8 b.x9 b.x10 b.x11 b.x12)) = let ctid = (U60.equal (HashOf a.ctid) (HashOf b.ctid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.bind (Kind.Checker.equal a.x3 b.x3) @x3 (Kind.Checker.bind (Kind.Checker.equal a.x4 b.x4) @x4 (Kind.Checker.bind (Kind.Checker.equal a.x5 b.x5) @x5 (Kind.Checker.bind (Kind.Checker.equal a.x6 b.x6) @x6 (Kind.Checker.bind (Kind.Checker.equal a.x7 b.x7) @x7 (Kind.Checker.bind (Kind.Checker.equal a.x8 b.x8) @x8 (Kind.Checker.bind (Kind.Checker.equal a.x9 b.x9) @x9 (Kind.Checker.bind (Kind.Checker.equal a.x10 b.x10) @x10 (Kind.Checker.bind (Kind.Checker.equal a.x11 b.x11) @x11 (Kind.Checker.bind (Kind.Checker.equal a.x12 b.x12) @x12 (Kind.Checker.pure (Bool.and ctid (Bool.and x0 (Bool.and x1 (Bool.and x2 (Bool.and x3 (Bool.and x4 (Bool.and x5 (Bool.and x6 (Bool.and x7 (Bool.and x8 (Bool.and x9 (Bool.and x10 (Bool.and x11 x12)))))))))))))))))))))))))))
(Kind.Checker.equal (Kind.Term.ct14 a.ctid a.orig a.x0 a.x1 a.x2 a.x3 a.x4 a.x5 a.x6 a.x7 a.x8 a.x9 a.x10 a.x11 a.x12 a.x13) (Kind.Term.ct14 b.ctid b.orig b.x0 b.x1 b.x2 b.x3 b.x4 b.x5 b.x6 b.x7 b.x8 b.x9 b.x10 b.x11 b.x12 b.x13)) = let ctid = (U60.equal (HashOf a.ctid) (HashOf b.ctid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.bind (Kind.Checker.equal a.x3 b.x3) @x3 (Kind.Checker.bind (Kind.Checker.equal a.x4 b.x4) @x4 (Kind.Checker.bind (Kind.Checker.equal a.x5 b.x5) @x5 (Kind.Checker.bind (Kind.Checker.equal a.x6 b.x6) @x6 (Kind.Checker.bind (Kind.Checker.equal a.x7 b.x7) @x7 (Kind.Checker.bind (Kind.Checker.equal a.x8 b.x8) @x8 (Kind.Checker.bind (Kind.Checker.equal a.x9 b.x9) @x9 (Kind.Checker.bind (Kind.Checker.equal a.x10 b.x10) @x10 (Kind.Checker.bind (Kind.Checker.equal a.x11 b.x11) @x11 (Kind.Checker.bind (Kind.Checker.equal a.x12 b.x12) @x12 (Kind.Checker.bind (Kind.Checker.equal a.x13 b.x13) @x13 (Kind.Checker.pure (Bool.and ctid (Bool.and x0 (Bool.and x1 (Bool.and x2 (Bool.and x3 (Bool.and x4 (Bool.and x5 (Bool.and x6 (Bool.and x7 (Bool.and x8 (Bool.and x9 (Bool.and x10 (Bool.and x11 (Bool.and x12 x13)))))))))))))))))))))))))))))
(Kind.Checker.equal (Kind.Term.ct15 a.ctid a.orig a.args) (Kind.Term.ct15 b.ctid b.orig b.args)) = let ctid = (U60.equal (HashOf a.ctid) (HashOf b.ctid)); (Kind.Checker.bind (Kind.Checker.equal a.args b.args) @xargs (Kind.Checker.pure (Bool.and ctid xargs)))
(Kind.Checker.equal (Kind.Term.ct16 a.ctid a.orig a.args) (Kind.Term.ct16 b.ctid b.orig b.args)) = let ctid = (U60.equal (HashOf a.ctid) (HashOf b.ctid)); (Kind.Checker.bind (Kind.Checker.equal a.args b.args) @xargs (Kind.Checker.pure (Bool.and ctid xargs)))
(Kind.Checker.equal (Kind.Term.args15 a.x0 a.x1 a.x2 a.x3 a.x4 a.x5 a.x6 a.x7 a.x8 a.x9 a.x10 a.x11 a.x12 a.x13 a.x14) (Kind.Term.args15 b.x0 b.x1 b.x2 b.x3 b.x4 b.x5 b.x6 b.x7 b.x8 b.x9 b.x10 b.x11 b.x12 b.x13 b.x14)) = (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.bind (Kind.Checker.equal a.x3 b.x3) @x3 (Kind.Checker.bind (Kind.Checker.equal a.x4 b.x4) @x4 (Kind.Checker.bind (Kind.Checker.equal a.x5 b.x5) @x5 (Kind.Checker.bind (Kind.Checker.equal a.x6 b.x6) @x6 (Kind.Checker.bind (Kind.Checker.equal a.x7 b.x7) @x7 (Kind.Checker.bind (Kind.Checker.equal a.x8 b.x8) @x8 (Kind.Checker.bind (Kind.Checker.equal a.x9 b.x9) @x9 (Kind.Checker.bind (Kind.Checker.equal a.x10 b.x10) @x10 (Kind.Checker.bind (Kind.Checker.equal a.x11 b.x11) @x11 (Kind.Checker.bind (Kind.Checker.equal a.x12 b.x12) @x12 (Kind.Checker.bind (Kind.Checker.equal a.x13 b.x13) @x13 (Kind.Checker.bind (Kind.Checker.equal a.x14 b.x14) @x14 (Kind.Checker.pure (Bool.and x0 (Bool.and x1 (Bool.and x2 (Bool.and x3 (Bool.and x4 (Bool.and x5 (Bool.and x6 (Bool.and x7 (Bool.and x8 (Bool.and x9 (Bool.and x10 (Bool.and x11 (Bool.and x12 (Bool.and x13 x14))))))))))))))))))))))))))))))
(Kind.Checker.equal (Kind.Term.args16 a.x0 a.x1 a.x2 a.x3 a.x4 a.x5 a.x6 a.x7 a.x8 a.x9 a.x10 a.x11 a.x12 a.x13 a.x14 a.x15) (Kind.Term.args16 b.x0 b.x1 b.x2 b.x3 b.x4 b.x5 b.x6 b.x7 b.x8 b.x9 b.x10 b.x11 b.x12 b.x13 b.x14 b.x15)) = (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.bind (Kind.Checker.equal a.x3 b.x3) @x3 (Kind.Checker.bind (Kind.Checker.equal a.x4 b.x4) @x4 (Kind.Checker.bind (Kind.Checker.equal a.x5 b.x5) @x5 (Kind.Checker.bind (Kind.Checker.equal a.x6 b.x6) @x6 (Kind.Checker.bind (Kind.Checker.equal a.x7 b.x7) @x7 (Kind.Checker.bind (Kind.Checker.equal a.x8 b.x8) @x8 (Kind.Checker.bind (Kind.Checker.equal a.x9 b.x9) @x9 (Kind.Checker.bind (Kind.Checker.equal a.x10 b.x10) @x10 (Kind.Checker.bind (Kind.Checker.equal a.x11 b.x11) @x11 (Kind.Checker.bind (Kind.Checker.equal a.x12 b.x12) @x12 (Kind.Checker.bind (Kind.Checker.equal a.x13 b.x13) @x13 (Kind.Checker.bind (Kind.Checker.equal a.x14 b.x14) @x14 (Kind.Checker.bind (Kind.Checker.equal a.x15 b.x15) @x15 (Kind.Checker.pure (Bool.and x0 (Bool.and x1 (Bool.and x2 (Bool.and x3 (Bool.and x4 (Bool.and x5 (Bool.and x6 (Bool.and x7 (Bool.and x8 (Bool.and x9 (Bool.and x10 (Bool.and x11 (Bool.and x12 (Bool.and x13 (Bool.and x14 x15))))))))))))))))))))))))))))))))
(Kind.Checker.equal (Kind.Term.fn0 a.fnid a.orig) (Kind.Term.fn0 b.fnid b.orig)) = let fnid = (U60.equal (HashOf a.fnid) (HashOf b.fnid)); (Kind.Checker.pure fnid)
(Kind.Checker.equal (Kind.Term.fn1 a.fnid a.orig a.x0) (Kind.Term.fn1 b.fnid b.orig b.x0)) = let fnid = (U60.equal (HashOf a.fnid) (HashOf b.fnid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.pure (Bool.and fnid x0)))
(Kind.Checker.equal (Kind.Term.fn2 a.fnid a.orig a.x0 a.x1) (Kind.Term.fn2 b.fnid b.orig b.x0 b.x1)) = let fnid = (U60.equal (HashOf a.fnid) (HashOf b.fnid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.pure (Bool.and fnid (Bool.and x0 x1)))))
(Kind.Checker.equal (Kind.Term.fn3 a.fnid a.orig a.x0 a.x1 a.x2) (Kind.Term.fn3 b.fnid b.orig b.x0 b.x1 b.x2)) = let fnid = (U60.equal (HashOf a.fnid) (HashOf b.fnid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.pure (Bool.and fnid (Bool.and x0 (Bool.and x1 x2)))))))
(Kind.Checker.equal (Kind.Term.fn4 a.fnid a.orig a.x0 a.x1 a.x2 a.x3) (Kind.Term.fn4 b.fnid b.orig b.x0 b.x1 b.x2 b.x3)) = let fnid = (U60.equal (HashOf a.fnid) (HashOf b.fnid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.bind (Kind.Checker.equal a.x3 b.x3) @x3 (Kind.Checker.pure (Bool.and fnid (Bool.and x0 (Bool.and x1 (Bool.and x2 x3)))))))))
(Kind.Checker.equal (Kind.Term.fn5 a.fnid a.orig a.x0 a.x1 a.x2 a.x3 a.x4) (Kind.Term.fn5 b.fnid b.orig b.x0 b.x1 b.x2 b.x3 b.x4)) = let fnid = (U60.equal (HashOf a.fnid) (HashOf b.fnid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.bind (Kind.Checker.equal a.x3 b.x3) @x3 (Kind.Checker.bind (Kind.Checker.equal a.x4 b.x4) @x4 (Kind.Checker.pure (Bool.and fnid (Bool.and x0 (Bool.and x1 (Bool.and x2 (Bool.and x3 x4)))))))))))
(Kind.Checker.equal (Kind.Term.fn6 a.fnid a.orig a.x0 a.x1 a.x2 a.x3 a.x4 a.x5) (Kind.Term.fn6 b.fnid b.orig b.x0 b.x1 b.x2 b.x3 b.x4 b.x5)) = let fnid = (U60.equal (HashOf a.fnid) (HashOf b.fnid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.bind (Kind.Checker.equal a.x3 b.x3) @x3 (Kind.Checker.bind (Kind.Checker.equal a.x4 b.x4) @x4 (Kind.Checker.bind (Kind.Checker.equal a.x5 b.x5) @x5 (Kind.Checker.pure (Bool.and fnid (Bool.and x0 (Bool.and x1 (Bool.and x2 (Bool.and x3 (Bool.and x4 x5)))))))))))))
(Kind.Checker.equal (Kind.Term.fn7 a.fnid a.orig a.x0 a.x1 a.x2 a.x3 a.x4 a.x5 a.x6) (Kind.Term.fn7 b.fnid b.orig b.x0 b.x1 b.x2 b.x3 b.x4 b.x5 b.x6)) = let fnid = (U60.equal (HashOf a.fnid) (HashOf b.fnid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.bind (Kind.Checker.equal a.x3 b.x3) @x3 (Kind.Checker.bind (Kind.Checker.equal a.x4 b.x4) @x4 (Kind.Checker.bind (Kind.Checker.equal a.x5 b.x5) @x5 (Kind.Checker.bind (Kind.Checker.equal a.x6 b.x6) @x6 (Kind.Checker.pure (Bool.and fnid (Bool.and x0 (Bool.and x1 (Bool.and x2 (Bool.and x3 (Bool.and x4 (Bool.and x5 x6)))))))))))))))
(Kind.Checker.equal (Kind.Term.fn8 a.fnid a.orig a.x0 a.x1 a.x2 a.x3 a.x4 a.x5 a.x6 a.x7) (Kind.Term.fn8 b.fnid b.orig b.x0 b.x1 b.x2 b.x3 b.x4 b.x5 b.x6 b.x7)) = let fnid = (U60.equal (HashOf a.fnid) (HashOf b.fnid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.bind (Kind.Checker.equal a.x3 b.x3) @x3 (Kind.Checker.bind (Kind.Checker.equal a.x4 b.x4) @x4 (Kind.Checker.bind (Kind.Checker.equal a.x5 b.x5) @x5 (Kind.Checker.bind (Kind.Checker.equal a.x6 b.x6) @x6 (Kind.Checker.bind (Kind.Checker.equal a.x7 b.x7) @x7 (Kind.Checker.pure (Bool.and fnid (Bool.and x0 (Bool.and x1 (Bool.and x2 (Bool.and x3 (Bool.and x4 (Bool.and x5 (Bool.and x6 x7)))))))))))))))))
(Kind.Checker.equal (Kind.Term.fn9 a.fnid a.orig a.x0 a.x1 a.x2 a.x3 a.x4 a.x5 a.x6 a.x7 a.x8) (Kind.Term.fn9 b.fnid b.orig b.x0 b.x1 b.x2 b.x3 b.x4 b.x5 b.x6 b.x7 b.x8)) = let fnid = (U60.equal (HashOf a.fnid) (HashOf b.fnid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.bind (Kind.Checker.equal a.x3 b.x3) @x3 (Kind.Checker.bind (Kind.Checker.equal a.x4 b.x4) @x4 (Kind.Checker.bind (Kind.Checker.equal a.x5 b.x5) @x5 (Kind.Checker.bind (Kind.Checker.equal a.x6 b.x6) @x6 (Kind.Checker.bind (Kind.Checker.equal a.x7 b.x7) @x7 (Kind.Checker.bind (Kind.Checker.equal a.x8 b.x8) @x8 (Kind.Checker.pure (Bool.and fnid (Bool.and x0 (Bool.and x1 (Bool.and x2 (Bool.and x3 (Bool.and x4 (Bool.and x5 (Bool.and x6 (Bool.and x7 x8)))))))))))))))))))
(Kind.Checker.equal (Kind.Term.fn10 a.fnid a.orig a.x0 a.x1 a.x2 a.x3 a.x4 a.x5 a.x6 a.x7 a.x8 a.x9) (Kind.Term.fn10 b.fnid b.orig b.x0 b.x1 b.x2 b.x3 b.x4 b.x5 b.x6 b.x7 b.x8 b.x9)) = let fnid = (U60.equal (HashOf a.fnid) (HashOf b.fnid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.bind (Kind.Checker.equal a.x3 b.x3) @x3 (Kind.Checker.bind (Kind.Checker.equal a.x4 b.x4) @x4 (Kind.Checker.bind (Kind.Checker.equal a.x5 b.x5) @x5 (Kind.Checker.bind (Kind.Checker.equal a.x6 b.x6) @x6 (Kind.Checker.bind (Kind.Checker.equal a.x7 b.x7) @x7 (Kind.Checker.bind (Kind.Checker.equal a.x8 b.x8) @x8 (Kind.Checker.bind (Kind.Checker.equal a.x9 b.x9) @x9 (Kind.Checker.pure (Bool.and fnid (Bool.and x0 (Bool.and x1 (Bool.and x2 (Bool.and x3 (Bool.and x4 (Bool.and x5 (Bool.and x6 (Bool.and x7 (Bool.and x8 x9)))))))))))))))))))))
(Kind.Checker.equal (Kind.Term.fn11 a.fnid a.orig a.x0 a.x1 a.x2 a.x3 a.x4 a.x5 a.x6 a.x7 a.x8 a.x9 a.x10) (Kind.Term.fn11 b.fnid b.orig b.x0 b.x1 b.x2 b.x3 b.x4 b.x5 b.x6 b.x7 b.x8 b.x9 b.x10)) = let fnid = (U60.equal (HashOf a.fnid) (HashOf b.fnid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.bind (Kind.Checker.equal a.x3 b.x3) @x3 (Kind.Checker.bind (Kind.Checker.equal a.x4 b.x4) @x4 (Kind.Checker.bind (Kind.Checker.equal a.x5 b.x5) @x5 (Kind.Checker.bind (Kind.Checker.equal a.x6 b.x6) @x6 (Kind.Checker.bind (Kind.Checker.equal a.x7 b.x7) @x7 (Kind.Checker.bind (Kind.Checker.equal a.x8 b.x8) @x8 (Kind.Checker.bind (Kind.Checker.equal a.x9 b.x9) @x9 (Kind.Checker.bind (Kind.Checker.equal a.x10 b.x10) @x10 (Kind.Checker.pure (Bool.and fnid (Bool.and x0 (Bool.and x1 (Bool.and x2 (Bool.and x3 (Bool.and x4 (Bool.and x5 (Bool.and x6 (Bool.and x7 (Bool.and x8 (Bool.and x9 x10)))))))))))))))))))))))
(Kind.Checker.equal (Kind.Term.fn12 a.fnid a.orig a.x0 a.x1 a.x2 a.x3 a.x4 a.x5 a.x6 a.x7 a.x8 a.x9 a.x10 a.x11) (Kind.Term.fn12 b.fnid b.orig b.x0 b.x1 b.x2 b.x3 b.x4 b.x5 b.x6 b.x7 b.x8 b.x9 b.x10 b.x11)) = let fnid = (U60.equal (HashOf a.fnid) (HashOf b.fnid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.bind (Kind.Checker.equal a.x3 b.x3) @x3 (Kind.Checker.bind (Kind.Checker.equal a.x4 b.x4) @x4 (Kind.Checker.bind (Kind.Checker.equal a.x5 b.x5) @x5 (Kind.Checker.bind (Kind.Checker.equal a.x6 b.x6) @x6 (Kind.Checker.bind (Kind.Checker.equal a.x7 b.x7) @x7 (Kind.Checker.bind (Kind.Checker.equal a.x8 b.x8) @x8 (Kind.Checker.bind (Kind.Checker.equal a.x9 b.x9) @x9 (Kind.Checker.bind (Kind.Checker.equal a.x10 b.x10) @x10 (Kind.Checker.bind (Kind.Checker.equal a.x11 b.x11) @x11 (Kind.Checker.pure (Bool.and fnid (Bool.and x0 (Bool.and x1 (Bool.and x2 (Bool.and x3 (Bool.and x4 (Bool.and x5 (Bool.and x6 (Bool.and x7 (Bool.and x8 (Bool.and x9 (Bool.and x10 x11)))))))))))))))))))))))))
(Kind.Checker.equal (Kind.Term.fn13 a.fnid a.orig a.x0 a.x1 a.x2 a.x3 a.x4 a.x5 a.x6 a.x7 a.x8 a.x9 a.x10 a.x11 a.x12) (Kind.Term.fn13 b.fnid b.orig b.x0 b.x1 b.x2 b.x3 b.x4 b.x5 b.x6 b.x7 b.x8 b.x9 b.x10 b.x11 b.x12)) = let fnid = (U60.equal (HashOf a.fnid) (HashOf b.fnid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.bind (Kind.Checker.equal a.x3 b.x3) @x3 (Kind.Checker.bind (Kind.Checker.equal a.x4 b.x4) @x4 (Kind.Checker.bind (Kind.Checker.equal a.x5 b.x5) @x5 (Kind.Checker.bind (Kind.Checker.equal a.x6 b.x6) @x6 (Kind.Checker.bind (Kind.Checker.equal a.x7 b.x7) @x7 (Kind.Checker.bind (Kind.Checker.equal a.x8 b.x8) @x8 (Kind.Checker.bind (Kind.Checker.equal a.x9 b.x9) @x9 (Kind.Checker.bind (Kind.Checker.equal a.x10 b.x10) @x10 (Kind.Checker.bind (Kind.Checker.equal a.x11 b.x11) @x11 (Kind.Checker.bind (Kind.Checker.equal a.x12 b.x12) @x12 (Kind.Checker.pure (Bool.and fnid (Bool.and x0 (Bool.and x1 (Bool.and x2 (Bool.and x3 (Bool.and x4 (Bool.and x5 (Bool.and x6 (Bool.and x7 (Bool.and x8 (Bool.and x9 (Bool.and x10 (Bool.and x11 x12)))))))))))))))))))))))))))
(Kind.Checker.equal (Kind.Term.fn14 a.fnid a.orig a.x0 a.x1 a.x2 a.x3 a.x4 a.x5 a.x6 a.x7 a.x8 a.x9 a.x10 a.x11 a.x12 a.x13) (Kind.Term.fn14 b.fnid b.orig b.x0 b.x1 b.x2 b.x3 b.x4 b.x5 b.x6 b.x7 b.x8 b.x9 b.x10 b.x11 b.x12 b.x13)) = let fnid = (U60.equal (HashOf a.fnid) (HashOf b.fnid)); (Kind.Checker.bind (Kind.Checker.equal a.x0 b.x0) @x0 (Kind.Checker.bind (Kind.Checker.equal a.x1 b.x1) @x1 (Kind.Checker.bind (Kind.Checker.equal a.x2 b.x2) @x2 (Kind.Checker.bind (Kind.Checker.equal a.x3 b.x3) @x3 (Kind.Checker.bind (Kind.Checker.equal a.x4 b.x4) @x4 (Kind.Checker.bind (Kind.Checker.equal a.x5 b.x5) @x5 (Kind.Checker.bind (Kind.Checker.equal a.x6 b.x6) @x6 (Kind.Checker.bind (Kind.Checker.equal a.x7 b.x7) @x7 (Kind.Checker.bind (Kind.Checker.equal a.x8 b.x8) @x8 (Kind.Checker.bind (Kind.Checker.equal a.x9 b.x9) @x9 (Kind.Checker.bind (Kind.Checker.equal a.x10 b.x10) @x10 (Kind.Checker.bind (Kind.Checker.equal a.x11 b.x11) @x11 (Kind.Checker.bind (Kind.Checker.equal a.x12 b.x12) @x12 (Kind.Checker.bind (Kind.Checker.equal a.x13 b.x13) @x13 (Kind.Checker.pure (Bool.and fnid (Bool.and x0 (Bool.and x1 (Bool.and x2 (Bool.and x3 (Bool.and x4 (Bool.and x5 (Bool.and x6 (Bool.and x7 (Bool.and x8 (Bool.and x9 (Bool.and x10 (Bool.and x11 (Bool.and x12 x13)))))))))))))))))))))))))))))
(Kind.Checker.equal (Kind.Term.fn15 a.fnid a.orig a.args) (Kind.Term.fn15 b.fnid b.orig b.args)) = let fnid = (U60.equal (HashOf a.fnid) (HashOf b.fnid)); (Kind.Checker.bind (Kind.Checker.equal a.args b.args) @xargs (Kind.Checker.pure (Bool.and fnid xargs)))
(Kind.Checker.equal (Kind.Term.fn16 a.fnid a.orig a.args) (Kind.Term.fn16 b.fnid b.orig b.args)) = let fnid = (U60.equal (HashOf a.fnid) (HashOf b.fnid)); (Kind.Checker.bind (Kind.Checker.equal a.args b.args) @xargs (Kind.Checker.pure (Bool.and fnid xargs)))
(Kind.Checker.equal a b) = (Kind.Checker.bind (Kind.Checker.get_subst) @sub (Bool.if (Bool.or (Kind.Term.fillable a sub) (Kind.Term.fillable b sub)) (Kind.Checker.equal (Kind.Term.fill a sub) (Kind.Term.fill b sub)) (Kind.Checker.pure (Bool.false))))
// Kind.Checker.equal.var (rhs: (Bool)) (orig: U60) (name: U60) (idx: U60) (b: (Kind.Term)) : (Kind.Checker (Bool))
(Kind.Checker.equal.var (Bool.false) orig name idx b) = (Kind.Checker.bind (Kind.Checker.add_value idx b) @_ (Kind.Checker.pure (Bool.true)))
(Kind.Checker.equal.var (Bool.true) a.orig a.name a.idx (Kind.Term.var b.orig b.name b.idx)) = (Bool.if (U60.equal a.idx b.idx) (Kind.Checker.pure (Bool.true)) (Kind.Checker.bind (Kind.Checker.find a.idx (List.nil) @n @t @v v) @a.val (Kind.Checker.bind (Kind.Checker.find b.idx (List.nil) @n @t @v v) @b.val (Kind.Checker.bind (Kind.Checker.equal.var.try_values a.val (Kind.Term.var b.orig b.name b.idx)) @a.chk (Kind.Checker.bind (Kind.Checker.equal.var.try_values b.val (Kind.Term.var a.orig a.name a.idx)) @b.chk (Kind.Checker.pure (Bool.or a.chk b.chk)))))))
(Kind.Checker.equal.var (Bool.true) a.orig a.name a.idx b) = (Kind.Checker.bind (Kind.Checker.get_subst) @sub (Bool.if (Kind.Term.fillable b sub) (Kind.Checker.equal (Kind.Term.var a.orig a.name a.idx) (Kind.Term.fill b sub)) (Kind.Checker.bind (Kind.Checker.find a.idx (List.nil) @n @t @v v) @a.val (Kind.Checker.bind (Kind.Checker.equal.var.try_values a.val b) @res (Kind.Checker.pure res)))))
// Kind.Checker.equal.var.try_values (ls: (List (Kind.Term))) (term: (Kind.Term)) : (Kind.Checker (Bool))
(Kind.Checker.equal.var.try_values (List.nil) term) = (Kind.Checker.pure (Bool.false))
(Kind.Checker.equal.var.try_values (List.cons x xs) term) = (Kind.Checker.bind (Kind.Checker.equal x term) @head (Bool.if head (Kind.Checker.pure (Bool.true)) (Kind.Checker.equal.var.try_values xs term)))
// Kind.Checker.equal.hol (orig: U60) (numb: U60) (b: (Kind.Term)) : (Kind.Checker (Bool))
(Kind.Checker.equal.hol a.orig a.numb b) = (Kind.Checker.bind (Kind.Checker.look a.numb) @got (Kind.Checker.bind (Kind.Checker.equal.hol.val got a.orig a.numb b) @res (Kind.Checker.pure res)))
// Kind.Checker.equal.hol.val (val: (Maybe (Kind.Term))) (orig: U60) (numb: U60) (b: (Kind.Term)) : (Kind.Checker (Bool))
(Kind.Checker.equal.hol.val (Maybe.none) orig numb b) = (Kind.Checker.bind (Kind.Checker.fill numb b) @_ (Kind.Checker.pure (Bool.true)))
(Kind.Checker.equal.hol.val (Maybe.some val) orig numb b) = (Kind.Checker.equal val b)
// Kind.Checker.extended -(a: Type) (checker: (Kind.Checker a)) (name: U60) (type: (Kind.Term)) (vals: (List (Kind.Term))) : (Kind.Checker a)
(Kind.Checker.extended checker name type vals) = (Kind.Checker.bind (Kind.Checker.extend name type vals) @_ (Kind.Checker.bind checker @got (Kind.Checker.bind (Kind.Checker.shrink) @_ (Kind.Checker.pure got))))
// Kind.Checker.shrink : (Kind.Checker (Unit))
(Kind.Checker.shrink) = @context @depth @rhs @subst @eqts @errs (Kind.Result.checked (Kind.Context.shrink context) (- depth 1) rhs subst eqts errs (Unit.new))
// Kind.Context.shrink (ctx: (Kind.Context)) : (Kind.Context)
(Kind.Context.shrink (Kind.Context.empty)) = (Kind.Context.empty)
(Kind.Context.shrink (Kind.Context.entry name type vals (Kind.Context.empty))) = (Kind.Context.empty)
(Kind.Context.shrink (Kind.Context.entry name type vals rest)) = (Kind.Context.entry name type vals (Kind.Context.shrink rest))
// Kind.Checker.extend (name: U60) (type: (Kind.Term)) (vals: (List (Kind.Term))) : (Kind.Checker (Unit))
(Kind.Checker.extend name type vals) = @context @depth @rhs @subst @eqts @errs (Kind.Result.checked (Kind.Context.extend context name type vals) (+ depth 1) rhs subst eqts errs (Unit.new))
// Kind.Context.extend (prev: (Kind.Context)) (name: U60) (term: (Kind.Term)) (ls: (List (Kind.Term))) : (Kind.Context)
(Kind.Context.extend (Kind.Context.empty) name type values) = (Kind.Context.entry name type values (Kind.Context.empty))
(Kind.Context.extend (Kind.Context.entry n t v rest) name type values) = (Kind.Context.entry n t v (Kind.Context.extend rest name type values))
// Kind.Checker.find -(r: Type) (index: U60) (alt: r) (fun: (_: U60) (_: (Kind.Term)) (_: (List (Kind.Term))) r) : (Kind.Checker r)
(Kind.Checker.find index alt fun) = @context @depth @rhs @subst @eqts @errs (Kind.Result.checked context depth rhs subst eqts errs (Kind.Context.find context index alt fun))
// Kind.Context.find -(res: Type) (ctx: (Kind.Context)) (name: U60) (alt: res) (fun: (_: U60) (_: (Kind.Term)) (_: (List (Kind.Term))) res) : res
(Kind.Context.find (Kind.Context.entry name type vals rest) 0 alt fun) = (((fun name) type) vals)
(Kind.Context.find (Kind.Context.entry name type vals rest) n alt fun) = (Kind.Context.find rest (- n 1) alt fun)
(Kind.Context.find (Kind.Context.empty) n alt fun) = alt
// Kind.Checker.get_depth : (Kind.Checker U60)
(Kind.Checker.get_depth) = @context @depth @rhs @subst @eqts @errs (Kind.Result.checked context depth rhs subst eqts errs depth)
// Kind.Checker.look (index: U60) : (Kind.Checker (Maybe (Kind.Term)))
(Kind.Checker.look index) = @context @depth @rhs @subst @eqts @errs (Kind.Result.checked context depth rhs subst eqts errs (Kind.Subst.look subst index))
// Kind.Subst.look (subst: (Kind.Subst)) (depth: U60) : (Maybe (Kind.Term))
(Kind.Subst.look (Kind.Subst.end) 0) = (Maybe.none)
(Kind.Subst.look (Kind.Subst.unfilled rest) 0) = (Maybe.none)
(Kind.Subst.look (Kind.Subst.sub term rest) 0) = (Maybe.some term)
(Kind.Subst.look (Kind.Subst.end) n) = (Maybe.none)
(Kind.Subst.look (Kind.Subst.unfilled rest) n) = (Kind.Subst.look rest (- n 1))
(Kind.Subst.look (Kind.Subst.sub term rest) n) = (Kind.Subst.look rest (- n 1))
// Bool.and (a: (Bool)) (b: (Bool)) : (Bool)
(Bool.and (Bool.true) b) = b
(Bool.and (Bool.false) b) = (Bool.false)
// Kind.Checker.add_value (idx: U60) (val: (Kind.Term)) : (Kind.Checker (Unit))
(Kind.Checker.add_value idx val) = @context @depth @rhs @subst @eqts @errs (Kind.Result.checked (Kind.Context.add_value context idx val) depth rhs subst eqts errs (Unit.new))
// Kind.Context.add_value (prev: (Kind.Context)) (name: U60) (term: (Kind.Term)) : (Kind.Context)
(Kind.Context.add_value (Kind.Context.entry name type vals rest) 0 val) = (Kind.Context.entry name type (List.cons val vals) rest)
(Kind.Context.add_value (Kind.Context.entry name type vals rest) n val) = (Kind.Context.entry name type vals (Kind.Context.add_value rest (- n 1) val))
(Kind.Context.add_value (Kind.Context.empty) n val) = (Kind.Context.empty)
// Kind.Term.fillable (term: (Kind.Term)) (sub: (Kind.Subst)) : (Bool)
(Kind.Term.fillable term (Kind.Subst.end)) = (Bool.false)
(Kind.Term.fillable (Kind.Term.typ orig) sub) = (Bool.false)
(Kind.Term.fillable (Kind.Term.var orig name index) sub) = (Bool.false)
(Kind.Term.fillable (Kind.Term.hlp orig) sub) = (Bool.false)
(Kind.Term.fillable (Kind.Term.u60 orig) sub) = (Bool.false)
(Kind.Term.fillable (Kind.Term.num orig num) sub) = (Bool.false)
(Kind.Term.fillable (Kind.Term.all orig name typ body) sub) = (Bool.or (Kind.Term.fillable typ sub) (Kind.Term.fillable (body (Kind.Term.hlp 0)) sub))
(Kind.Term.fillable (Kind.Term.lam orig name body) sub) = (Kind.Term.fillable (body (Kind.Term.hlp 0)) sub)
(Kind.Term.fillable (Kind.Term.app orig expr typ) sub) = (Bool.or (Kind.Term.fillable expr sub) (Kind.Term.fillable typ sub))
(Kind.Term.fillable (Kind.Term.let orig name expr body) sub) = (Bool.or (Kind.Term.fillable expr sub) (Kind.Term.fillable (body (Kind.Term.hlp 0)) sub))
(Kind.Term.fillable (Kind.Term.ann orig expr typ) sub) = (Bool.or (Kind.Term.fillable expr sub) (Kind.Term.fillable typ sub))
(Kind.Term.fillable (Kind.Term.sub orig name indx redx expr) sub) = (Kind.Term.fillable expr sub)
(Kind.Term.fillable (Kind.Term.op2 orig op left right) sub) = (Bool.or (Kind.Term.fillable left sub) (Kind.Term.fillable right sub))
(Kind.Term.fillable (Kind.Term.hol orig numb) sub) = (Maybe.is_some (Kind.Subst.look sub numb))
(Kind.Term.fillable (Kind.Term.ct0 ctid orig) sub) = (Bool.false)
(Kind.Term.fillable (Kind.Term.ct1 ctid orig x0) sub) = (Kind.Term.fillable x0 sub)
(Kind.Term.fillable (Kind.Term.ct2 ctid orig x0 x1) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Kind.Term.fillable x1 sub))
(Kind.Term.fillable (Kind.Term.ct3 ctid orig x0 x1 x2) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Kind.Term.fillable x2 sub)))
(Kind.Term.fillable (Kind.Term.ct4 ctid orig x0 x1 x2 x3) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Bool.or (Kind.Term.fillable x2 sub) (Kind.Term.fillable x3 sub))))
(Kind.Term.fillable (Kind.Term.ct5 ctid orig x0 x1 x2 x3 x4) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Bool.or (Kind.Term.fillable x2 sub) (Bool.or (Kind.Term.fillable x3 sub) (Kind.Term.fillable x4 sub)))))
(Kind.Term.fillable (Kind.Term.ct6 ctid orig x0 x1 x2 x3 x4 x5) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Bool.or (Kind.Term.fillable x2 sub) (Bool.or (Kind.Term.fillable x3 sub) (Bool.or (Kind.Term.fillable x4 sub) (Kind.Term.fillable x5 sub))))))
(Kind.Term.fillable (Kind.Term.ct7 ctid orig x0 x1 x2 x3 x4 x5 x6) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Bool.or (Kind.Term.fillable x2 sub) (Bool.or (Kind.Term.fillable x3 sub) (Bool.or (Kind.Term.fillable x4 sub) (Bool.or (Kind.Term.fillable x5 sub) (Kind.Term.fillable x6 sub)))))))
(Kind.Term.fillable (Kind.Term.ct8 ctid orig x0 x1 x2 x3 x4 x5 x6 x7) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Bool.or (Kind.Term.fillable x2 sub) (Bool.or (Kind.Term.fillable x3 sub) (Bool.or (Kind.Term.fillable x4 sub) (Bool.or (Kind.Term.fillable x5 sub) (Bool.or (Kind.Term.fillable x6 sub) (Kind.Term.fillable x7 sub))))))))
(Kind.Term.fillable (Kind.Term.ct9 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Bool.or (Kind.Term.fillable x2 sub) (Bool.or (Kind.Term.fillable x3 sub) (Bool.or (Kind.Term.fillable x4 sub) (Bool.or (Kind.Term.fillable x5 sub) (Bool.or (Kind.Term.fillable x6 sub) (Bool.or (Kind.Term.fillable x7 sub) (Kind.Term.fillable x8 sub)))))))))
(Kind.Term.fillable (Kind.Term.ct10 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Bool.or (Kind.Term.fillable x2 sub) (Bool.or (Kind.Term.fillable x3 sub) (Bool.or (Kind.Term.fillable x4 sub) (Bool.or (Kind.Term.fillable x5 sub) (Bool.or (Kind.Term.fillable x6 sub) (Bool.or (Kind.Term.fillable x7 sub) (Bool.or (Kind.Term.fillable x8 sub) (Kind.Term.fillable x9 sub))))))))))
(Kind.Term.fillable (Kind.Term.ct11 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Bool.or (Kind.Term.fillable x2 sub) (Bool.or (Kind.Term.fillable x3 sub) (Bool.or (Kind.Term.fillable x4 sub) (Bool.or (Kind.Term.fillable x5 sub) (Bool.or (Kind.Term.fillable x6 sub) (Bool.or (Kind.Term.fillable x7 sub) (Bool.or (Kind.Term.fillable x8 sub) (Bool.or (Kind.Term.fillable x9 sub) (Kind.Term.fillable x10 sub)))))))))))
(Kind.Term.fillable (Kind.Term.ct12 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Bool.or (Kind.Term.fillable x2 sub) (Bool.or (Kind.Term.fillable x3 sub) (Bool.or (Kind.Term.fillable x4 sub) (Bool.or (Kind.Term.fillable x5 sub) (Bool.or (Kind.Term.fillable x6 sub) (Bool.or (Kind.Term.fillable x7 sub) (Bool.or (Kind.Term.fillable x8 sub) (Bool.or (Kind.Term.fillable x9 sub) (Bool.or (Kind.Term.fillable x10 sub) (Kind.Term.fillable x11 sub))))))))))))
(Kind.Term.fillable (Kind.Term.ct13 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Bool.or (Kind.Term.fillable x2 sub) (Bool.or (Kind.Term.fillable x3 sub) (Bool.or (Kind.Term.fillable x4 sub) (Bool.or (Kind.Term.fillable x5 sub) (Bool.or (Kind.Term.fillable x6 sub) (Bool.or (Kind.Term.fillable x7 sub) (Bool.or (Kind.Term.fillable x8 sub) (Bool.or (Kind.Term.fillable x9 sub) (Bool.or (Kind.Term.fillable x10 sub) (Bool.or (Kind.Term.fillable x11 sub) (Kind.Term.fillable x12 sub)))))))))))))
(Kind.Term.fillable (Kind.Term.ct14 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Bool.or (Kind.Term.fillable x2 sub) (Bool.or (Kind.Term.fillable x3 sub) (Bool.or (Kind.Term.fillable x4 sub) (Bool.or (Kind.Term.fillable x5 sub) (Bool.or (Kind.Term.fillable x6 sub) (Bool.or (Kind.Term.fillable x7 sub) (Bool.or (Kind.Term.fillable x8 sub) (Bool.or (Kind.Term.fillable x9 sub) (Bool.or (Kind.Term.fillable x10 sub) (Bool.or (Kind.Term.fillable x11 sub) (Bool.or (Kind.Term.fillable x12 sub) (Kind.Term.fillable x13 sub))))))))))))))
(Kind.Term.fillable (Kind.Term.ct15 fnid orig args) sub) = (Kind.Term.fillable args sub)
(Kind.Term.fillable (Kind.Term.ct16 fnid orig args) sub) = (Kind.Term.fillable args sub)
(Kind.Term.fillable (Kind.Term.fn0 fnid orig) sub) = (Bool.false)
(Kind.Term.fillable (Kind.Term.fn1 fnid orig x0) sub) = (Kind.Term.fillable x0 sub)
(Kind.Term.fillable (Kind.Term.fn2 fnid orig x0 x1) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Kind.Term.fillable x1 sub))
(Kind.Term.fillable (Kind.Term.fn3 fnid orig x0 x1 x2) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Kind.Term.fillable x2 sub)))
(Kind.Term.fillable (Kind.Term.fn4 fnid orig x0 x1 x2 x3) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Bool.or (Kind.Term.fillable x2 sub) (Kind.Term.fillable x3 sub))))
(Kind.Term.fillable (Kind.Term.fn5 fnid orig x0 x1 x2 x3 x4) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Bool.or (Kind.Term.fillable x2 sub) (Bool.or (Kind.Term.fillable x3 sub) (Kind.Term.fillable x4 sub)))))
(Kind.Term.fillable (Kind.Term.fn6 fnid orig x0 x1 x2 x3 x4 x5) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Bool.or (Kind.Term.fillable x2 sub) (Bool.or (Kind.Term.fillable x3 sub) (Bool.or (Kind.Term.fillable x4 sub) (Kind.Term.fillable x5 sub))))))
(Kind.Term.fillable (Kind.Term.fn7 fnid orig x0 x1 x2 x3 x4 x5 x6) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Bool.or (Kind.Term.fillable x2 sub) (Bool.or (Kind.Term.fillable x3 sub) (Bool.or (Kind.Term.fillable x4 sub) (Bool.or (Kind.Term.fillable x5 sub) (Kind.Term.fillable x6 sub)))))))
(Kind.Term.fillable (Kind.Term.fn8 fnid orig x0 x1 x2 x3 x4 x5 x6 x7) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Bool.or (Kind.Term.fillable x2 sub) (Bool.or (Kind.Term.fillable x3 sub) (Bool.or (Kind.Term.fillable x4 sub) (Bool.or (Kind.Term.fillable x5 sub) (Bool.or (Kind.Term.fillable x6 sub) (Kind.Term.fillable x7 sub))))))))
(Kind.Term.fillable (Kind.Term.fn9 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Bool.or (Kind.Term.fillable x2 sub) (Bool.or (Kind.Term.fillable x3 sub) (Bool.or (Kind.Term.fillable x4 sub) (Bool.or (Kind.Term.fillable x5 sub) (Bool.or (Kind.Term.fillable x6 sub) (Bool.or (Kind.Term.fillable x7 sub) (Kind.Term.fillable x8 sub)))))))))
(Kind.Term.fillable (Kind.Term.fn10 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Bool.or (Kind.Term.fillable x2 sub) (Bool.or (Kind.Term.fillable x3 sub) (Bool.or (Kind.Term.fillable x4 sub) (Bool.or (Kind.Term.fillable x5 sub) (Bool.or (Kind.Term.fillable x6 sub) (Bool.or (Kind.Term.fillable x7 sub) (Bool.or (Kind.Term.fillable x8 sub) (Kind.Term.fillable x9 sub))))))))))
(Kind.Term.fillable (Kind.Term.fn11 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Bool.or (Kind.Term.fillable x2 sub) (Bool.or (Kind.Term.fillable x3 sub) (Bool.or (Kind.Term.fillable x4 sub) (Bool.or (Kind.Term.fillable x5 sub) (Bool.or (Kind.Term.fillable x6 sub) (Bool.or (Kind.Term.fillable x7 sub) (Bool.or (Kind.Term.fillable x8 sub) (Bool.or (Kind.Term.fillable x9 sub) (Kind.Term.fillable x10 sub)))))))))))
(Kind.Term.fillable (Kind.Term.fn12 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Bool.or (Kind.Term.fillable x2 sub) (Bool.or (Kind.Term.fillable x3 sub) (Bool.or (Kind.Term.fillable x4 sub) (Bool.or (Kind.Term.fillable x5 sub) (Bool.or (Kind.Term.fillable x6 sub) (Bool.or (Kind.Term.fillable x7 sub) (Bool.or (Kind.Term.fillable x8 sub) (Bool.or (Kind.Term.fillable x9 sub) (Bool.or (Kind.Term.fillable x10 sub) (Kind.Term.fillable x11 sub))))))))))))
(Kind.Term.fillable (Kind.Term.fn13 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Bool.or (Kind.Term.fillable x2 sub) (Bool.or (Kind.Term.fillable x3 sub) (Bool.or (Kind.Term.fillable x4 sub) (Bool.or (Kind.Term.fillable x5 sub) (Bool.or (Kind.Term.fillable x6 sub) (Bool.or (Kind.Term.fillable x7 sub) (Bool.or (Kind.Term.fillable x8 sub) (Bool.or (Kind.Term.fillable x9 sub) (Bool.or (Kind.Term.fillable x10 sub) (Bool.or (Kind.Term.fillable x11 sub) (Kind.Term.fillable x12 sub)))))))))))))
(Kind.Term.fillable (Kind.Term.fn14 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Bool.or (Kind.Term.fillable x2 sub) (Bool.or (Kind.Term.fillable x3 sub) (Bool.or (Kind.Term.fillable x4 sub) (Bool.or (Kind.Term.fillable x5 sub) (Bool.or (Kind.Term.fillable x6 sub) (Bool.or (Kind.Term.fillable x7 sub) (Bool.or (Kind.Term.fillable x8 sub) (Bool.or (Kind.Term.fillable x9 sub) (Bool.or (Kind.Term.fillable x10 sub) (Bool.or (Kind.Term.fillable x11 sub) (Bool.or (Kind.Term.fillable x12 sub) (Kind.Term.fillable x13 sub))))))))))))))
(Kind.Term.fillable (Kind.Term.fn15 fnid orig args) sub) = (Kind.Term.fillable args sub)
(Kind.Term.fillable (Kind.Term.fn16 fnid orig args) sub) = (Kind.Term.fillable args sub)
(Kind.Term.fillable (Kind.Term.args15 x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Bool.or (Kind.Term.fillable x2 sub) (Bool.or (Kind.Term.fillable x3 sub) (Bool.or (Kind.Term.fillable x4 sub) (Bool.or (Kind.Term.fillable x5 sub) (Bool.or (Kind.Term.fillable x6 sub) (Bool.or (Kind.Term.fillable x7 sub) (Bool.or (Kind.Term.fillable x8 sub) (Bool.or (Kind.Term.fillable x9 sub) (Bool.or (Kind.Term.fillable x10 sub) (Bool.or (Kind.Term.fillable x11 sub) (Bool.or (Kind.Term.fillable x12 sub) (Bool.or (Kind.Term.fillable x13 sub) (Kind.Term.fillable x14 sub)))))))))))))))
(Kind.Term.fillable (Kind.Term.args16 x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15) sub) = (Bool.or (Kind.Term.fillable x0 sub) (Bool.or (Kind.Term.fillable x1 sub) (Bool.or (Kind.Term.fillable x2 sub) (Bool.or (Kind.Term.fillable x3 sub) (Bool.or (Kind.Term.fillable x4 sub) (Bool.or (Kind.Term.fillable x5 sub) (Bool.or (Kind.Term.fillable x6 sub) (Bool.or (Kind.Term.fillable x7 sub) (Bool.or (Kind.Term.fillable x8 sub) (Bool.or (Kind.Term.fillable x9 sub) (Bool.or (Kind.Term.fillable x10 sub) (Bool.or (Kind.Term.fillable x11 sub) (Bool.or (Kind.Term.fillable x12 sub) (Bool.or (Kind.Term.fillable x13 sub) (Bool.or (Kind.Term.fillable x14 sub) (Kind.Term.fillable x15 sub))))))))))))))))
// Maybe.is_some -(a: Type) (m: (Maybe a)) : (Bool)
(Maybe.is_some (Maybe.none)) = (Bool.false)
(Maybe.is_some (Maybe.some v)) = (Bool.true)
// Bool.or (a: (Bool)) (b: (Bool)) : (Bool)
(Bool.or (Bool.true) b) = (Bool.true)
(Bool.or (Bool.false) b) = b
// Bool.if -(a: Type) (b: (Bool)) (t: a) (f: a) : a
(Bool.if (Bool.true) t f) = t
(Bool.if (Bool.false) t f) = f
// U60.equal (a: U60) (b: U60) : (Bool)
(U60.equal a b) = (U60.to_bool (== a b))
// U60.to_bool (n: U60) : (Bool)
(U60.to_bool 0) = (Bool.false)
(U60.to_bool n) = (Bool.true)
// Kind.Checker.fill (index: U60) (val: (Kind.Term)) : (Kind.Checker (Unit))
(Kind.Checker.fill index val) = @context @depth @rhs @subst @eqts @errs (Kind.Result.checked context depth rhs (Kind.Subst.fill subst index val) eqts errs (Unit.new))
// Kind.Subst.fill (subst: (Kind.Subst)) (depth: U60) (term: (Kind.Term)) : (Kind.Subst)
(Kind.Subst.fill (Kind.Subst.end) 0 term) = (Kind.Subst.sub term (Kind.Subst.end))
(Kind.Subst.fill (Kind.Subst.unfilled rest) 0 term) = (Kind.Subst.sub term rest)
(Kind.Subst.fill (Kind.Subst.sub lost rest) 0 term) = (Kind.Subst.sub term rest)
(Kind.Subst.fill (Kind.Subst.end) n term) = (Kind.Subst.unfilled (Kind.Subst.fill (Kind.Subst.end) (- n 1) term))
(Kind.Subst.fill (Kind.Subst.unfilled rest) n term) = (Kind.Subst.unfilled (Kind.Subst.fill rest (- n 1) term))
(Kind.Subst.fill (Kind.Subst.sub keep rest) n term) = (Kind.Subst.sub keep (Kind.Subst.fill rest (- n 1) term))
// Kind.Checker.get_right_hand_side : (Kind.Checker (Bool))
(Kind.Checker.get_right_hand_side) = @context @depth @rhs @subst @eqts @errs (Kind.Result.checked context depth rhs subst eqts errs rhs)
// Kind.Term.fill (term: (Kind.Term)) (subst: (Kind.Subst)) : (Kind.Term)
(Kind.Term.fill term (Kind.Subst.end)) = term
(Kind.Term.fill (Kind.Term.typ orig) sub) = (Kind.Term.typ orig)
(Kind.Term.fill (Kind.Term.var orig name index) sub) = (Kind.Term.var orig name index)
(Kind.Term.fill (Kind.Term.all orig name typ body) sub) = (Kind.Term.all orig name (Kind.Term.fill typ sub) @x (Kind.Term.fill (body x) sub))
(Kind.Term.fill (Kind.Term.lam orig name body) sub) = (Kind.Term.lam orig name @x (Kind.Term.fill (body x) sub))
(Kind.Term.fill (Kind.Term.let orig name expr body) sub) = (Kind.Term.eval_let orig name (Kind.Term.fill expr sub) @x (Kind.Term.fill (body x) sub))
(Kind.Term.fill (Kind.Term.ann orig expr typ) sub) = (Kind.Term.eval_ann orig (Kind.Term.fill expr sub) (Kind.Term.fill typ sub))
(Kind.Term.fill (Kind.Term.sub orig name indx redx expr) sub) = (Kind.Term.eval_sub orig name indx redx (Kind.Term.fill expr sub))
(Kind.Term.fill (Kind.Term.app orig expr typ) sub) = (Kind.Term.eval_app orig (Kind.Term.fill expr sub) (Kind.Term.fill typ sub))
(Kind.Term.fill (Kind.Term.hlp orig) sub) = (Kind.Term.hlp orig)
(Kind.Term.fill (Kind.Term.u60 orig) sub) = (Kind.Term.u60 orig)
(Kind.Term.fill (Kind.Term.num orig num) sub) = (Kind.Term.num orig num)
(Kind.Term.fill (Kind.Term.op2 orig op left right) sub) = (Kind.Term.op2 orig op (Kind.Term.fill left sub) (Kind.Term.fill right sub))
(Kind.Term.fill (Kind.Term.ct0 ctid orig) sub) = (Kind.Term.ct0 ctid orig)
(Kind.Term.fill (Kind.Term.ct1 ctid orig x0) sub) = (Kind.Term.ct1 ctid orig (Kind.Term.fill x0 sub))
(Kind.Term.fill (Kind.Term.ct2 ctid orig x0 x1) sub) = (Kind.Term.ct2 ctid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub))
(Kind.Term.fill (Kind.Term.ct3 ctid orig x0 x1 x2) sub) = (Kind.Term.ct3 ctid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub))
(Kind.Term.fill (Kind.Term.ct4 ctid orig x0 x1 x2 x3) sub) = (Kind.Term.ct4 ctid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub) (Kind.Term.fill x3 sub))
(Kind.Term.fill (Kind.Term.ct5 ctid orig x0 x1 x2 x3 x4) sub) = (Kind.Term.ct5 ctid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub) (Kind.Term.fill x3 sub) (Kind.Term.fill x4 sub))
(Kind.Term.fill (Kind.Term.ct6 ctid orig x0 x1 x2 x3 x4 x5) sub) = (Kind.Term.ct6 ctid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub) (Kind.Term.fill x3 sub) (Kind.Term.fill x4 sub) (Kind.Term.fill x5 sub))
(Kind.Term.fill (Kind.Term.ct7 ctid orig x0 x1 x2 x3 x4 x5 x6) sub) = (Kind.Term.ct7 ctid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub) (Kind.Term.fill x3 sub) (Kind.Term.fill x4 sub) (Kind.Term.fill x5 sub) (Kind.Term.fill x6 sub))
(Kind.Term.fill (Kind.Term.ct8 ctid orig x0 x1 x2 x3 x4 x5 x6 x7) sub) = (Kind.Term.ct8 ctid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub) (Kind.Term.fill x3 sub) (Kind.Term.fill x4 sub) (Kind.Term.fill x5 sub) (Kind.Term.fill x6 sub) (Kind.Term.fill x7 sub))
(Kind.Term.fill (Kind.Term.ct9 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8) sub) = (Kind.Term.ct9 ctid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub) (Kind.Term.fill x3 sub) (Kind.Term.fill x4 sub) (Kind.Term.fill x5 sub) (Kind.Term.fill x6 sub) (Kind.Term.fill x7 sub) (Kind.Term.fill x8 sub))
(Kind.Term.fill (Kind.Term.ct10 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9) sub) = (Kind.Term.ct10 ctid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub) (Kind.Term.fill x3 sub) (Kind.Term.fill x4 sub) (Kind.Term.fill x5 sub) (Kind.Term.fill x6 sub) (Kind.Term.fill x7 sub) (Kind.Term.fill x8 sub) (Kind.Term.fill x9 sub))
(Kind.Term.fill (Kind.Term.ct11 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10) sub) = (Kind.Term.ct11 ctid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub) (Kind.Term.fill x3 sub) (Kind.Term.fill x4 sub) (Kind.Term.fill x5 sub) (Kind.Term.fill x6 sub) (Kind.Term.fill x7 sub) (Kind.Term.fill x8 sub) (Kind.Term.fill x9 sub) (Kind.Term.fill x10 sub))
(Kind.Term.fill (Kind.Term.ct12 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11) sub) = (Kind.Term.ct12 ctid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub) (Kind.Term.fill x3 sub) (Kind.Term.fill x4 sub) (Kind.Term.fill x5 sub) (Kind.Term.fill x6 sub) (Kind.Term.fill x7 sub) (Kind.Term.fill x8 sub) (Kind.Term.fill x9 sub) (Kind.Term.fill x10 sub) (Kind.Term.fill x11 sub))
(Kind.Term.fill (Kind.Term.ct13 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) sub) = (Kind.Term.ct13 ctid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub) (Kind.Term.fill x3 sub) (Kind.Term.fill x4 sub) (Kind.Term.fill x5 sub) (Kind.Term.fill x6 sub) (Kind.Term.fill x7 sub) (Kind.Term.fill x8 sub) (Kind.Term.fill x9 sub) (Kind.Term.fill x10 sub) (Kind.Term.fill x11 sub) (Kind.Term.fill x12 sub))
(Kind.Term.fill (Kind.Term.ct14 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13) sub) = (Kind.Term.ct14 ctid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub) (Kind.Term.fill x3 sub) (Kind.Term.fill x4 sub) (Kind.Term.fill x5 sub) (Kind.Term.fill x6 sub) (Kind.Term.fill x7 sub) (Kind.Term.fill x8 sub) (Kind.Term.fill x9 sub) (Kind.Term.fill x10 sub) (Kind.Term.fill x11 sub) (Kind.Term.fill x12 sub) (Kind.Term.fill x13 sub))
(Kind.Term.fill (Kind.Term.ct15 ctid orig x0) sub) = (Kind.Term.ct15 ctid orig (Kind.Term.fill x0 sub))
(Kind.Term.fill (Kind.Term.ct16 ctid orig x0) sub) = (Kind.Term.ct16 ctid orig (Kind.Term.fill x0 sub))
(Kind.Term.fill (Kind.Term.fn0 fnid orig) sub) = (Kind.Term.FN0 fnid orig)
(Kind.Term.fill (Kind.Term.fn1 fnid orig x0) sub) = (Kind.Term.FN1 fnid orig (Kind.Term.fill x0 sub))
(Kind.Term.fill (Kind.Term.fn2 fnid orig x0 x1) sub) = (Kind.Term.FN2 fnid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub))
(Kind.Term.fill (Kind.Term.fn3 fnid orig x0 x1 x2) sub) = (Kind.Term.FN3 fnid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub))
(Kind.Term.fill (Kind.Term.fn4 fnid orig x0 x1 x2 x3) sub) = (Kind.Term.FN4 fnid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub) (Kind.Term.fill x3 sub))
(Kind.Term.fill (Kind.Term.fn5 fnid orig x0 x1 x2 x3 x4) sub) = (Kind.Term.FN5 fnid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub) (Kind.Term.fill x3 sub) (Kind.Term.fill x4 sub))
(Kind.Term.fill (Kind.Term.fn6 fnid orig x0 x1 x2 x3 x4 x5) sub) = (Kind.Term.FN6 fnid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub) (Kind.Term.fill x3 sub) (Kind.Term.fill x4 sub) (Kind.Term.fill x5 sub))
(Kind.Term.fill (Kind.Term.fn7 fnid orig x0 x1 x2 x3 x4 x5 x6) sub) = (Kind.Term.FN7 fnid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub) (Kind.Term.fill x3 sub) (Kind.Term.fill x4 sub) (Kind.Term.fill x5 sub) (Kind.Term.fill x6 sub))
(Kind.Term.fill (Kind.Term.fn8 fnid orig x0 x1 x2 x3 x4 x5 x6 x7) sub) = (Kind.Term.FN8 fnid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub) (Kind.Term.fill x3 sub) (Kind.Term.fill x4 sub) (Kind.Term.fill x5 sub) (Kind.Term.fill x6 sub) (Kind.Term.fill x7 sub))
(Kind.Term.fill (Kind.Term.fn9 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8) sub) = (Kind.Term.FN9 fnid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub) (Kind.Term.fill x3 sub) (Kind.Term.fill x4 sub) (Kind.Term.fill x5 sub) (Kind.Term.fill x6 sub) (Kind.Term.fill x7 sub) (Kind.Term.fill x8 sub))
(Kind.Term.fill (Kind.Term.fn10 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9) sub) = (Kind.Term.FN10 fnid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub) (Kind.Term.fill x3 sub) (Kind.Term.fill x4 sub) (Kind.Term.fill x5 sub) (Kind.Term.fill x6 sub) (Kind.Term.fill x7 sub) (Kind.Term.fill x8 sub) (Kind.Term.fill x9 sub))
(Kind.Term.fill (Kind.Term.fn11 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10) sub) = (Kind.Term.FN11 fnid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub) (Kind.Term.fill x3 sub) (Kind.Term.fill x4 sub) (Kind.Term.fill x5 sub) (Kind.Term.fill x6 sub) (Kind.Term.fill x7 sub) (Kind.Term.fill x8 sub) (Kind.Term.fill x9 sub) (Kind.Term.fill x10 sub))
(Kind.Term.fill (Kind.Term.fn12 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11) sub) = (Kind.Term.FN12 fnid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub) (Kind.Term.fill x3 sub) (Kind.Term.fill x4 sub) (Kind.Term.fill x5 sub) (Kind.Term.fill x6 sub) (Kind.Term.fill x7 sub) (Kind.Term.fill x8 sub) (Kind.Term.fill x9 sub) (Kind.Term.fill x10 sub) (Kind.Term.fill x11 sub))
(Kind.Term.fill (Kind.Term.fn13 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) sub) = (Kind.Term.FN13 fnid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub) (Kind.Term.fill x3 sub) (Kind.Term.fill x4 sub) (Kind.Term.fill x5 sub) (Kind.Term.fill x6 sub) (Kind.Term.fill x7 sub) (Kind.Term.fill x8 sub) (Kind.Term.fill x9 sub) (Kind.Term.fill x10 sub) (Kind.Term.fill x11 sub) (Kind.Term.fill x12 sub))
(Kind.Term.fill (Kind.Term.fn14 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13) sub) = (Kind.Term.FN14 fnid orig (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub) (Kind.Term.fill x3 sub) (Kind.Term.fill x4 sub) (Kind.Term.fill x5 sub) (Kind.Term.fill x6 sub) (Kind.Term.fill x7 sub) (Kind.Term.fill x8 sub) (Kind.Term.fill x9 sub) (Kind.Term.fill x10 sub) (Kind.Term.fill x11 sub) (Kind.Term.fill x12 sub) (Kind.Term.fill x13 sub))
(Kind.Term.fill (Kind.Term.fn15 ctid orig x0) sub) = (Kind.Term.FN15 ctid orig (Kind.Term.fill x0 sub))
(Kind.Term.fill (Kind.Term.fn16 ctid orig x0) sub) = (Kind.Term.FN16 ctid orig (Kind.Term.fill x0 sub))
(Kind.Term.fill (Kind.Term.args15 x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14) sub) = (Kind.Term.args15 (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub) (Kind.Term.fill x3 sub) (Kind.Term.fill x4 sub) (Kind.Term.fill x5 sub) (Kind.Term.fill x6 sub) (Kind.Term.fill x7 sub) (Kind.Term.fill x8 sub) (Kind.Term.fill x9 sub) (Kind.Term.fill x10 sub) (Kind.Term.fill x11 sub) (Kind.Term.fill x12 sub) (Kind.Term.fill x13 sub) (Kind.Term.fill x14 sub))
(Kind.Term.fill (Kind.Term.args16 x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15) sub) = (Kind.Term.args16 (Kind.Term.fill x0 sub) (Kind.Term.fill x1 sub) (Kind.Term.fill x2 sub) (Kind.Term.fill x3 sub) (Kind.Term.fill x4 sub) (Kind.Term.fill x5 sub) (Kind.Term.fill x6 sub) (Kind.Term.fill x7 sub) (Kind.Term.fill x8 sub) (Kind.Term.fill x9 sub) (Kind.Term.fill x10 sub) (Kind.Term.fill x11 sub) (Kind.Term.fill x12 sub) (Kind.Term.fill x13 sub) (Kind.Term.fill x14 sub) (Kind.Term.fill x15 sub))
(Kind.Term.fill (Kind.Term.hol orig numb) sub) = let substRes = (Kind.Subst.look sub numb); (Maybe.match substRes (Kind.Term.hol orig numb) @substRes.value (Kind.Term.fill substRes.value sub))
// Kind.Operator.equal (left: (Kind.Operator)) (right: (Kind.Operator)) : (Bool)
(Kind.Operator.equal (Kind.Operator.and) (Kind.Operator.and)) = (Bool.true)
(Kind.Operator.equal (Kind.Operator.sub) (Kind.Operator.sub)) = (Bool.true)
(Kind.Operator.equal (Kind.Operator.mul) (Kind.Operator.mul)) = (Bool.true)
(Kind.Operator.equal (Kind.Operator.div) (Kind.Operator.div)) = (Bool.true)
(Kind.Operator.equal (Kind.Operator.mod) (Kind.Operator.mod)) = (Bool.true)
(Kind.Operator.equal (Kind.Operator.and) (Kind.Operator.and)) = (Bool.true)
(Kind.Operator.equal (Kind.Operator.or) (Kind.Operator.or)) = (Bool.true)
(Kind.Operator.equal (Kind.Operator.xor) (Kind.Operator.xor)) = (Bool.true)
(Kind.Operator.equal (Kind.Operator.shl) (Kind.Operator.shl)) = (Bool.true)
(Kind.Operator.equal (Kind.Operator.shr) (Kind.Operator.shr)) = (Bool.true)
(Kind.Operator.equal (Kind.Operator.ltn) (Kind.Operator.ltn)) = (Bool.true)
(Kind.Operator.equal (Kind.Operator.lte) (Kind.Operator.lte)) = (Bool.true)
(Kind.Operator.equal (Kind.Operator.eql) (Kind.Operator.eql)) = (Bool.true)
(Kind.Operator.equal (Kind.Operator.gte) (Kind.Operator.gte)) = (Bool.true)
(Kind.Operator.equal (Kind.Operator.gtn) (Kind.Operator.gtn)) = (Bool.true)
(Kind.Operator.equal (Kind.Operator.neq) (Kind.Operator.neq)) = (Bool.true)
(Kind.Operator.equal a b) = (Bool.false)
// Kind.Checker.get_subst : (Kind.Checker (Kind.Subst))
(Kind.Checker.get_subst) = @context @depth @rhs @subst @eqts @errs (Kind.Result.checked context depth rhs subst eqts errs subst)
// Kind.Checker.error -(t: Type) (err: (Kind.Error)) (ret: t) : (Kind.Checker t)
(Kind.Checker.error err ret) = @context @depth @rhs @subst @eqts @errs (Kind.Result.checked context depth rhs subst eqts (List.cons err errs) ret)
// Kind.Checker.get_equations : (Kind.Checker (List (Kind.Equation)))
(Kind.Checker.get_equations) = @context @depth @rhs @subst @eqts @errs (Kind.Result.checked context depth rhs subst eqts errs eqts)
// Kind.Checker.rule (rule: (Kind.Rule)) (term: (Kind.Term)) : (Kind.Checker (Unit))
(Kind.Checker.rule (Kind.Rule.lhs arg args) (Kind.Term.all orig name type body)) = (Kind.Checker.bind (Kind.Checker.check arg type) @_ (Kind.Checker.bind (Kind.Checker.rule args (body arg)) @_ (Kind.Checker.pure (Unit.new))))
(Kind.Checker.rule (Kind.Rule.lhs arg args) other) = (Kind.Checker.bind (Kind.Checker.get_context) @ctx (Kind.Checker.fail (Kind.Error.too_many_arguments ctx (Kind.Term.get_origin arg @orig @term orig))))
(Kind.Checker.rule (Kind.Rule.rhs expr) type) = (Kind.Checker.bind (Kind.Checker.set_right_hand_side (Bool.true)) @_ (Kind.Checker.bind (Kind.Checker.check expr type) @_ (Kind.Checker.pure (Unit.new))))
// Kind.Checker.get_context : (Kind.Checker (Kind.Context))
(Kind.Checker.get_context) = @context @depth @rhs @subst @eqts @errs (Kind.Result.checked context depth rhs subst eqts errs context)
// Kind.Checker.set_right_hand_side (rhs: (Bool)) : (Kind.Checker (Unit))
(Kind.Checker.set_right_hand_side to_rhs) = @context @depth @rhs @subst @eqts @errs (Kind.Result.checked context depth to_rhs subst eqts errs (Unit.new))
// Kind.Term.get_origin -(r: Type) (term: (Kind.Term)) (got: (_: U60) (_: (Kind.Term)) r) : r
(Kind.Term.get_origin (Kind.Term.typ orig) got) = ((got orig) (Kind.Term.typ orig))
(Kind.Term.get_origin (Kind.Term.var orig name index) got) = ((got orig) (Kind.Term.var orig name index))
(Kind.Term.get_origin (Kind.Term.hol orig numb) got) = ((got orig) (Kind.Term.hol orig numb))
(Kind.Term.get_origin (Kind.Term.all orig name typ body) got) = ((got orig) (Kind.Term.all orig name typ body))
(Kind.Term.get_origin (Kind.Term.lam orig name body) got) = ((got orig) (Kind.Term.lam orig name body))
(Kind.Term.get_origin (Kind.Term.let orig name expr body) got) = ((got orig) (Kind.Term.let orig name expr body))
(Kind.Term.get_origin (Kind.Term.ann orig expr typ) got) = ((got orig) (Kind.Term.ann orig expr typ))
(Kind.Term.get_origin (Kind.Term.sub orig name indx redx expr) got) = ((got orig) (Kind.Term.sub orig name indx redx expr))
(Kind.Term.get_origin (Kind.Term.app orig func arg) got) = ((got orig) (Kind.Term.app orig func arg))
(Kind.Term.get_origin (Kind.Term.hlp orig) got) = ((got orig) (Kind.Term.hlp orig))
(Kind.Term.get_origin (Kind.Term.u60 orig) got) = ((got orig) (Kind.Term.u60 orig))
(Kind.Term.get_origin (Kind.Term.num orig num) got) = ((got orig) (Kind.Term.num orig num))
(Kind.Term.get_origin (Kind.Term.op2 orig op left right) got) = ((got orig) (Kind.Term.op2 orig op left right))
(Kind.Term.get_origin (Kind.Term.ct0 ctid orig) got) = ((got orig) (Kind.Term.ct0 ctid orig))
(Kind.Term.get_origin (Kind.Term.ct1 ctid orig x0) got) = ((got orig) (Kind.Term.ct1 ctid orig x0))
(Kind.Term.get_origin (Kind.Term.ct2 ctid orig x0 x1) got) = ((got orig) (Kind.Term.ct2 ctid orig x0 x1))
(Kind.Term.get_origin (Kind.Term.ct3 ctid orig x0 x1 x2) got) = ((got orig) (Kind.Term.ct3 ctid orig x0 x1 x2))
(Kind.Term.get_origin (Kind.Term.ct4 ctid orig x0 x1 x2 x3) got) = ((got orig) (Kind.Term.ct4 ctid orig x0 x1 x2 x3))
(Kind.Term.get_origin (Kind.Term.ct5 ctid orig x0 x1 x2 x3 x4) got) = ((got orig) (Kind.Term.ct5 ctid orig x0 x1 x2 x3 x4))
(Kind.Term.get_origin (Kind.Term.ct6 ctid orig x0 x1 x2 x3 x4 x5) got) = ((got orig) (Kind.Term.ct6 ctid orig x0 x1 x2 x3 x4 x5))
(Kind.Term.get_origin (Kind.Term.ct7 ctid orig x0 x1 x2 x3 x4 x5 x6) got) = ((got orig) (Kind.Term.ct7 ctid orig x0 x1 x2 x3 x4 x5 x6))
(Kind.Term.get_origin (Kind.Term.ct8 ctid orig x0 x1 x2 x3 x4 x5 x6 x7) got) = ((got orig) (Kind.Term.ct8 ctid orig x0 x1 x2 x3 x4 x5 x6 x7))
(Kind.Term.get_origin (Kind.Term.ct9 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8) got) = ((got orig) (Kind.Term.ct9 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8))
(Kind.Term.get_origin (Kind.Term.ct10 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9) got) = ((got orig) (Kind.Term.ct10 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9))
(Kind.Term.get_origin (Kind.Term.ct11 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10) got) = ((got orig) (Kind.Term.ct11 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10))
(Kind.Term.get_origin (Kind.Term.ct12 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11) got) = ((got orig) (Kind.Term.ct12 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11))
(Kind.Term.get_origin (Kind.Term.ct13 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) got) = ((got orig) (Kind.Term.ct13 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12))
(Kind.Term.get_origin (Kind.Term.ct14 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13) got) = ((got orig) (Kind.Term.ct14 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13))
(Kind.Term.get_origin (Kind.Term.ct15 fnid orig args) got) = ((got orig) (Kind.Term.ct15 fnid orig args))
(Kind.Term.get_origin (Kind.Term.ct16 fnid orig args) got) = ((got orig) (Kind.Term.ct16 fnid orig args))
(Kind.Term.get_origin (Kind.Term.fn0 fnid orig) got) = ((got orig) (Kind.Term.fn0 fnid orig))
(Kind.Term.get_origin (Kind.Term.fn1 fnid orig x0) got) = ((got orig) (Kind.Term.fn1 fnid orig x0))
(Kind.Term.get_origin (Kind.Term.fn2 fnid orig x0 x1) got) = ((got orig) (Kind.Term.fn2 fnid orig x0 x1))
(Kind.Term.get_origin (Kind.Term.fn3 fnid orig x0 x1 x2) got) = ((got orig) (Kind.Term.fn3 fnid orig x0 x1 x2))
(Kind.Term.get_origin (Kind.Term.fn4 fnid orig x0 x1 x2 x3) got) = ((got orig) (Kind.Term.fn4 fnid orig x0 x1 x2 x3))
(Kind.Term.get_origin (Kind.Term.fn5 fnid orig x0 x1 x2 x3 x4) got) = ((got orig) (Kind.Term.fn5 fnid orig x0 x1 x2 x3 x4))
(Kind.Term.get_origin (Kind.Term.fn6 fnid orig x0 x1 x2 x3 x4 x5) got) = ((got orig) (Kind.Term.fn6 fnid orig x0 x1 x2 x3 x4 x5))
(Kind.Term.get_origin (Kind.Term.fn7 fnid orig x0 x1 x2 x3 x4 x5 x6) got) = ((got orig) (Kind.Term.fn7 fnid orig x0 x1 x2 x3 x4 x5 x6))
(Kind.Term.get_origin (Kind.Term.fn8 fnid orig x0 x1 x2 x3 x4 x5 x6 x7) got) = ((got orig) (Kind.Term.fn8 fnid orig x0 x1 x2 x3 x4 x5 x6 x7))
(Kind.Term.get_origin (Kind.Term.fn9 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8) got) = ((got orig) (Kind.Term.fn9 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8))
(Kind.Term.get_origin (Kind.Term.fn10 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9) got) = ((got orig) (Kind.Term.fn10 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9))
(Kind.Term.get_origin (Kind.Term.fn11 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10) got) = ((got orig) (Kind.Term.fn11 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10))
(Kind.Term.get_origin (Kind.Term.fn12 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11) got) = ((got orig) (Kind.Term.fn12 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11))
(Kind.Term.get_origin (Kind.Term.fn13 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) got) = ((got orig) (Kind.Term.fn13 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12))
(Kind.Term.get_origin (Kind.Term.fn14 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13) got) = ((got orig) (Kind.Term.fn14 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13))
(Kind.Term.get_origin (Kind.Term.fn15 fnid orig args) got) = ((got orig) (Kind.Term.fn15 fnid orig args))
(Kind.Term.get_origin (Kind.Term.fn16 fnid orig args) got) = ((got orig) (Kind.Term.fn16 fnid orig args))
// Kind.Checker.check (term: (Kind.Term)) (type: (Kind.Term)) : (Kind.Checker (Unit))
(Kind.Checker.check (Kind.Term.lam orig name body) type) = (Kind.Checker.bind (Kind.Checker.get_subst) @subst let fun = (Kind.Term.if_all type @t_orig @t_name @t_type @t_body @orig @name @body (Kind.Checker.bind (Kind.Checker.get_depth) @dep (Kind.Checker.bind (Kind.Checker.extended (Kind.Checker.check (body (Kind.Term.var orig name dep)) (t_body (Kind.Term.var t_orig t_name dep))) name t_type (List.nil)) @chk (Kind.Checker.pure (Unit.new)))) @orig @name @body (Kind.Checker.bind (Kind.Checker.get_context) @ctx (Kind.Checker.fail (Kind.Error.cant_infer_lambda ctx orig)))); (((fun orig) name) body))
(Kind.Checker.check (Kind.Term.let orig name expr body) type) = (Kind.Checker.bind (Kind.Checker.get_depth) @dep (Kind.Checker.bind (Kind.Checker.infer expr) @expr_typ (Kind.Checker.bind (Kind.Checker.extended (Kind.Checker.check (body (Kind.Term.var orig name dep)) type) name expr_typ (List.cons (Kind.Term.eval expr) (List.nil))) @body_chk (Kind.Checker.pure (Unit.new)))))
(Kind.Checker.check (Kind.Term.hlp orig) type) = (Kind.Checker.bind (Kind.Checker.get_context) @ctx (Kind.Checker.bind (Kind.Checker.error (Kind.Error.inspection ctx orig type) (Unit.new)) @_ (Kind.Checker.pure (Unit.new))))
(Kind.Checker.check (Kind.Term.var orig name idx) type) = (Kind.Checker.bind (Kind.Checker.get_right_hand_side) @rhs (Bool.if rhs (Kind.Checker.compare rhs (Kind.Term.var orig name idx) type) (Kind.Checker.extend name type (List.nil))))
(Kind.Checker.check (Kind.Term.hol orig numb) type) = (Kind.Checker.pure (Unit.new))
(Kind.Checker.check term type) = (Kind.Checker.bind (Kind.Checker.get_right_hand_side) @rhs (Kind.Checker.compare rhs term type))
// Kind.Checker.compare (rhs: (Bool)) (term: (Kind.Term)) (type: (Kind.Term)) : (Kind.Checker (Unit))
(Kind.Checker.compare rhs term type) = (Kind.Term.get_origin term @orig @term (Kind.Checker.bind (Kind.Checker.infer term) @term_typ let fun = (Bool.if rhs @term_typ @type (Kind.Checker.new_equation orig type term_typ) @term_typ @type (Kind.Checker.bind (Kind.Checker.equal (Kind.Term.eval term_typ) (Kind.Term.eval type)) @is_equal (Bool.if is_equal (Kind.Checker.pure (Unit.new)) (Kind.Checker.bind (Kind.Checker.get_context) @ctx (Kind.Checker.fail (Kind.Error.impossible_case ctx orig type term_typ)))))); ((fun term_typ) type)))
// Kind.Checker.infer_args (args: (Kind.Term)) : (_: (Kind.Term)) (_: U60) (Kind.Term)
(Kind.Checker.infer_args (Kind.Term.args15 x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14)) = @term @orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig term x0) x1) x2) x3) x4) x5) x6) x7) x8) x9) x10) x11) x12) x13) x14)
(Kind.Checker.infer_args (Kind.Term.args16 x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15)) = @term @orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig term x0) x1) x2) x3) x4) x5) x6) x7) x8) x9) x10) x11) x12) x13) x14) x15)
// Kind.Checker.infer (term: (Kind.Term)) : (Kind.Checker (Kind.Term))
(Kind.Checker.infer (Kind.Term.var orig name index)) = (Kind.Checker.bind (Kind.Checker.find index (Maybe.none) @n @t @v (Maybe.some t)) @got_type (Maybe.match got_type (Kind.Checker.bind (Kind.Checker.get_context) @ctx (Kind.Checker.fail (Kind.Error.unbound_variable ctx orig))) @got_type.value (Kind.Checker.pure got_type.value)))
(Kind.Checker.infer (Kind.Term.hol orig numb)) = (Kind.Checker.bind (Kind.Checker.get_context) @ctx (Kind.Checker.fail (Kind.Error.cant_infer_hole ctx orig)))
(Kind.Checker.infer (Kind.Term.typ orig)) = (Kind.Checker.pure (Kind.Term.typ orig))
(Kind.Checker.infer (Kind.Term.all orig name type body)) = (Kind.Checker.bind (Kind.Checker.get_depth) @depth (Kind.Checker.bind (Kind.Checker.check type (Kind.Term.typ orig)) @_ (Kind.Checker.bind (Kind.Checker.extended (Kind.Checker.check (body (Kind.Term.var orig name depth)) (Kind.Term.typ orig)) name (Kind.Term.eval type) (List.nil)) @_ (Kind.Checker.pure (Kind.Term.typ orig)))))
(Kind.Checker.infer (Kind.Term.lam orig name body)) = (Kind.Checker.bind (Kind.Checker.get_context) @ctx (Kind.Checker.fail (Kind.Error.cant_infer_lambda ctx orig)))
(Kind.Checker.infer (Kind.Term.app orig func argm)) = (Kind.Checker.bind (Kind.Checker.infer func) @fn_infer (Kind.Checker.bind (Kind.Checker.infer.forall fn_infer @fn_orig @fn_name @fn_type @fn_body (Kind.Checker.bind (Kind.Checker.check argm fn_type) @_ (Kind.Checker.pure (fn_body (Kind.Term.eval argm)))) (Kind.Checker.bind (Kind.Checker.get_context) @ctx (Kind.Checker.fail (Kind.Error.invalid_call ctx orig)))) @ap_infer (Kind.Checker.pure ap_infer)))
(Kind.Checker.infer (Kind.Term.let orig name expr body)) = (Kind.Checker.bind (Kind.Checker.get_depth) @dep (Kind.Checker.bind (Kind.Checker.infer expr) @expr_typ (Kind.Checker.bind (Kind.Checker.extended (Kind.Checker.infer (body (Kind.Term.var orig name dep))) name expr_typ (List.cons (Kind.Term.eval expr) (List.nil))) @body_typ (Kind.Checker.pure body_typ))))
(Kind.Checker.infer (Kind.Term.ann orig expr type)) = let type = (Kind.Term.eval type); (Kind.Checker.bind (Kind.Checker.check expr type) @_ (Kind.Checker.pure type))
(Kind.Checker.infer (Kind.Term.sub orig name indx redx expr)) = (Kind.Checker.bind (Kind.Checker.get_depth) @dep (Kind.Checker.bind (Kind.Checker.find indx (Maybe.none) @n @t @v (Maybe.some (Pair.new t v))) @got (Maybe.match got (Kind.Checker.bind (Kind.Checker.get_context) @ctx (Kind.Checker.fail (Kind.Error.unbound_variable ctx orig))) @got.value (Pair.match got.value @got.value.fst @got.value.snd (Maybe.match (List.at.u60 got.value.snd redx) (Kind.Checker.bind (Kind.Checker.get_context) @ctx (Kind.Checker.fail (Kind.Error.unbound_variable ctx orig))) @reduction.value (Kind.Checker.bind (Kind.Checker.infer expr) @expr_typ (Kind.Checker.pure (Kind.Term.eval (Kind.Term.replace expr_typ indx reduction.value)))))))))
(Kind.Checker.infer (Kind.Term.ct0 ctid orig)) = (Kind.Checker.pure (Kind.Term.eval (TypeOf ctid)))
(Kind.Checker.infer (Kind.Term.ct1 ctid orig x0)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.ct0 ctid orig) x0))
(Kind.Checker.infer (Kind.Term.ct2 ctid orig x0 x1)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.ct0 ctid orig) x0) x1))
(Kind.Checker.infer (Kind.Term.ct3 ctid orig x0 x1 x2)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.ct0 ctid orig) x0) x1) x2))
(Kind.Checker.infer (Kind.Term.ct4 ctid orig x0 x1 x2 x3)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.ct0 ctid orig) x0) x1) x2) x3))
(Kind.Checker.infer (Kind.Term.ct5 ctid orig x0 x1 x2 x3 x4)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.ct0 ctid orig) x0) x1) x2) x3) x4))
(Kind.Checker.infer (Kind.Term.ct6 ctid orig x0 x1 x2 x3 x4 x5)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.ct0 ctid orig) x0) x1) x2) x3) x4) x5))
(Kind.Checker.infer (Kind.Term.ct7 ctid orig x0 x1 x2 x3 x4 x5 x6)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.ct0 ctid orig) x0) x1) x2) x3) x4) x5) x6))
(Kind.Checker.infer (Kind.Term.ct8 ctid orig x0 x1 x2 x3 x4 x5 x6 x7)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.ct0 ctid orig) x0) x1) x2) x3) x4) x5) x6) x7))
(Kind.Checker.infer (Kind.Term.ct9 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.ct0 ctid orig) x0) x1) x2) x3) x4) x5) x6) x7) x8))
(Kind.Checker.infer (Kind.Term.ct10 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.ct0 ctid orig) x0) x1) x2) x3) x4) x5) x6) x7) x8) x9))
(Kind.Checker.infer (Kind.Term.ct11 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.ct0 ctid orig) x0) x1) x2) x3) x4) x5) x6) x7) x8) x9) x10))
(Kind.Checker.infer (Kind.Term.ct12 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.ct0 ctid orig) x0) x1) x2) x3) x4) x5) x6) x7) x8) x9) x10) x11))
(Kind.Checker.infer (Kind.Term.ct13 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.ct0 ctid orig) x0) x1) x2) x3) x4) x5) x6) x7) x8) x9) x10) x11) x12))
(Kind.Checker.infer (Kind.Term.ct14 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.ct0 ctid orig) x0) x1) x2) x3) x4) x5) x6) x7) x8) x9) x10) x11) x12) x13))
(Kind.Checker.infer (Kind.Term.ct15 ctid orig x0)) = let expr = (Kind.Checker.infer_args x0); (Kind.Checker.infer ((expr (Kind.Term.ct0 ctid orig)) orig))
(Kind.Checker.infer (Kind.Term.ct16 ctid orig x0)) = let expr = (Kind.Checker.infer_args x0); (Kind.Checker.infer ((expr (Kind.Term.ct0 ctid orig)) orig))
(Kind.Checker.infer (Kind.Term.fn0 fnid orig)) = (Kind.Checker.pure (Kind.Term.eval (TypeOf fnid)))
(Kind.Checker.infer (Kind.Term.fn1 fnid orig x0)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.fn0 fnid orig) x0))
(Kind.Checker.infer (Kind.Term.fn2 fnid orig x0 x1)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.fn0 fnid orig) x0) x1))
(Kind.Checker.infer (Kind.Term.fn3 fnid orig x0 x1 x2)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.fn0 fnid orig) x0) x1) x2))
(Kind.Checker.infer (Kind.Term.fn4 fnid orig x0 x1 x2 x3)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.fn0 fnid orig) x0) x1) x2) x3))
(Kind.Checker.infer (Kind.Term.fn5 fnid orig x0 x1 x2 x3 x4)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.fn0 fnid orig) x0) x1) x2) x3) x4))
(Kind.Checker.infer (Kind.Term.fn6 fnid orig x0 x1 x2 x3 x4 x5)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.fn0 fnid orig) x0) x1) x2) x3) x4) x5))
(Kind.Checker.infer (Kind.Term.fn7 fnid orig x0 x1 x2 x3 x4 x5 x6)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.fn0 fnid orig) x0) x1) x2) x3) x4) x5) x6))
(Kind.Checker.infer (Kind.Term.fn8 fnid orig x0 x1 x2 x3 x4 x5 x6 x7)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.fn0 fnid orig) x0) x1) x2) x3) x4) x5) x6) x7))
(Kind.Checker.infer (Kind.Term.fn9 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.fn0 fnid orig) x0) x1) x2) x3) x4) x5) x6) x7) x8))
(Kind.Checker.infer (Kind.Term.fn10 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.fn0 fnid orig) x0) x1) x2) x3) x4) x5) x6) x7) x8) x9))
(Kind.Checker.infer (Kind.Term.fn11 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.fn0 fnid orig) x0) x1) x2) x3) x4) x5) x6) x7) x8) x9) x10))
(Kind.Checker.infer (Kind.Term.fn12 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.fn0 fnid orig) x0) x1) x2) x3) x4) x5) x6) x7) x8) x9) x10) x11))
(Kind.Checker.infer (Kind.Term.fn13 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.fn0 fnid orig) x0) x1) x2) x3) x4) x5) x6) x7) x8) x9) x10) x11) x12))
(Kind.Checker.infer (Kind.Term.fn14 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13)) = (Kind.Checker.infer (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.app orig (Kind.Term.fn0 fnid orig) x0) x1) x2) x3) x4) x5) x6) x7) x8) x9) x10) x11) x12) x13))
(Kind.Checker.infer (Kind.Term.fn15 fnid orig x0)) = let expr = (Kind.Checker.infer_args x0); (Kind.Checker.infer ((expr (Kind.Term.fn0 fnid orig)) orig))
(Kind.Checker.infer (Kind.Term.fn16 fnid orig x0)) = let expr = (Kind.Checker.infer_args x0); (Kind.Checker.infer ((expr (Kind.Term.fn0 fnid orig)) orig))
(Kind.Checker.infer (Kind.Term.hlp orig)) = (Kind.Checker.bind (Kind.Checker.get_context) @ctx (Kind.Checker.fail (Kind.Error.inspection ctx orig (Kind.Term.hlp 0))))
(Kind.Checker.infer (Kind.Term.u60 orig)) = (Kind.Checker.pure (Kind.Term.typ 0))
(Kind.Checker.infer (Kind.Term.num orig numb)) = (Kind.Checker.pure (Kind.Term.u60 0))
(Kind.Checker.infer (Kind.Term.op2 orig oper left right)) = (Kind.Checker.bind (Kind.Checker.check left (Kind.Term.u60 0)) @_ (Kind.Checker.bind (Kind.Checker.check right (Kind.Term.u60 0)) @_ (Kind.Checker.pure (Kind.Term.u60 0))))
// Kind.Checker.infer.forall -(r: Type) (term: (Kind.Term)) (then_fn: (_: U60) (_: U60) (_: (Kind.Term)) (_: (_: (Kind.Term)) (Kind.Term)) (Kind.Checker r)) (else_val: (Kind.Checker r)) : (Kind.Checker r)
(Kind.Checker.infer.forall (Kind.Term.all orig name type body) then_fn else_val) = ((((then_fn orig) name) type) body)
(Kind.Checker.infer.forall (Kind.Term.var orig name index) then_fn else_val) = (Kind.Checker.bind (Kind.Checker.find index (List.nil) @n @t @v v) @reducs (Kind.Checker.bind (Kind.Checker.infer.forall.try_values reducs then_fn else_val) @result (Kind.Checker.pure result)))
(Kind.Checker.infer.forall other then_fn else_val) = else_val
// Kind.Checker.infer.forall.try_values -(r: Type) (terms: (List (Kind.Term))) (then_fn: (_: U60) (_: U60) (_: (Kind.Term)) (_: (_: (Kind.Term)) (Kind.Term)) (Kind.Checker r)) (else_val: (Kind.Checker r)) : (Kind.Checker r)
(Kind.Checker.infer.forall.try_values (List.cons (Kind.Term.all orig name type body) terms) then_fn else_val) = ((((then_fn orig) name) type) body)
(Kind.Checker.infer.forall.try_values (List.cons other terms) then_fn else_val) = (Kind.Checker.infer.forall.try_values terms then_fn else_val)
(Kind.Checker.infer.forall.try_values (List.nil) then_fn else_val) = else_val
// Pair.match -(a: Type) -(b: Type) (x: (Pair a b)) -(p: (x: (Pair a b)) Type) (new: (fst: a) (snd: b) (p (Pair.new a b fst snd))) : (p x)
(Pair.match (Pair.new fst_ snd_) new) = ((new fst_) snd_)
// List.at.u60 -(a: Type) (xs: (List a)) (idx: U60) : (Maybe a)
(List.at.u60 (List.nil) idx) = (Maybe.none)
(List.at.u60 (List.cons head tail) 0) = (Maybe.some head)
(List.at.u60 (List.cons head tail) idx) = (List.at.u60 tail (- idx 1))
// Kind.Checker.fail -(t: Type) (err: (Kind.Error)) : (Kind.Checker t)
(Kind.Checker.fail err) = @context @depth @rhs @subst @eqts @errs (Kind.Result.errored context subst (List.cons err errs))
// Kind.Term.replace (term: (Kind.Term)) (index: U60) (value: (Kind.Term)) : (Kind.Term)
(Kind.Term.replace (Kind.Term.typ orig) idx val) = (Kind.Term.typ orig)
(Kind.Term.replace (Kind.Term.var orig name index) idx val) = (Bool.if (U60.equal idx index) val (Kind.Term.var orig name index))
(Kind.Term.replace (Kind.Term.all orig name typ body) idx val) = (Kind.Term.all orig name (Kind.Term.replace typ idx val) @x (Kind.Term.replace (body x) idx val))
(Kind.Term.replace (Kind.Term.lam orig name body) idx val) = (Kind.Term.lam orig name @x (Kind.Term.replace (body x) idx val))
(Kind.Term.replace (Kind.Term.let orig name expr body) idx val) = (Kind.Term.let orig name (Kind.Term.replace expr idx val) @x (Kind.Term.replace (body x) idx val))
(Kind.Term.replace (Kind.Term.ann orig expr typ) idx val) = (Kind.Term.ann orig (Kind.Term.replace expr idx val) (Kind.Term.replace typ idx val))
(Kind.Term.replace (Kind.Term.sub orig name indx redx expr) idx val) = (Kind.Term.sub orig name indx redx (Kind.Term.replace expr idx val))
(Kind.Term.replace (Kind.Term.app orig expr typ) idx val) = (Kind.Term.app orig (Kind.Term.replace expr idx val) (Kind.Term.replace typ idx val))
(Kind.Term.replace (Kind.Term.hlp orig) idx val) = (Kind.Term.hlp orig)
(Kind.Term.replace (Kind.Term.u60 orig) idx val) = (Kind.Term.u60 orig)
(Kind.Term.replace (Kind.Term.num orig num) idx val) = (Kind.Term.num orig num)
(Kind.Term.replace (Kind.Term.op2 orig op left right) idx val) = (Kind.Term.op2 orig op (Kind.Term.replace left idx val) (Kind.Term.replace right idx val))
(Kind.Term.replace (Kind.Term.ct0 ctid orig) idx val) = (Kind.Term.ct0 ctid orig)
(Kind.Term.replace (Kind.Term.ct1 ctid orig x0) idx val) = (Kind.Term.ct1 ctid orig (Kind.Term.replace x0 idx val))
(Kind.Term.replace (Kind.Term.ct2 ctid orig x0 x1) idx val) = (Kind.Term.ct2 ctid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val))
(Kind.Term.replace (Kind.Term.ct3 ctid orig x0 x1 x2) idx val) = (Kind.Term.ct3 ctid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val))
(Kind.Term.replace (Kind.Term.ct4 ctid orig x0 x1 x2 x3) idx val) = (Kind.Term.ct4 ctid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val) (Kind.Term.replace x3 idx val))
(Kind.Term.replace (Kind.Term.ct5 ctid orig x0 x1 x2 x3 x4) idx val) = (Kind.Term.ct5 ctid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val) (Kind.Term.replace x3 idx val) (Kind.Term.replace x4 idx val))
(Kind.Term.replace (Kind.Term.ct6 ctid orig x0 x1 x2 x3 x4 x5) idx val) = (Kind.Term.ct6 ctid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val) (Kind.Term.replace x3 idx val) (Kind.Term.replace x4 idx val) (Kind.Term.replace x5 idx val))
(Kind.Term.replace (Kind.Term.ct7 ctid orig x0 x1 x2 x3 x4 x5 x6) idx val) = (Kind.Term.ct7 ctid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val) (Kind.Term.replace x3 idx val) (Kind.Term.replace x4 idx val) (Kind.Term.replace x5 idx val) (Kind.Term.replace x6 idx val))
(Kind.Term.replace (Kind.Term.ct8 ctid orig x0 x1 x2 x3 x4 x5 x6 x7) idx val) = (Kind.Term.ct8 ctid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val) (Kind.Term.replace x3 idx val) (Kind.Term.replace x4 idx val) (Kind.Term.replace x5 idx val) (Kind.Term.replace x6 idx val) (Kind.Term.replace x7 idx val))
(Kind.Term.replace (Kind.Term.ct9 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8) idx val) = (Kind.Term.ct9 ctid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val) (Kind.Term.replace x3 idx val) (Kind.Term.replace x4 idx val) (Kind.Term.replace x5 idx val) (Kind.Term.replace x6 idx val) (Kind.Term.replace x7 idx val) (Kind.Term.replace x8 idx val))
(Kind.Term.replace (Kind.Term.ct10 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9) idx val) = (Kind.Term.ct10 ctid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val) (Kind.Term.replace x3 idx val) (Kind.Term.replace x4 idx val) (Kind.Term.replace x5 idx val) (Kind.Term.replace x6 idx val) (Kind.Term.replace x7 idx val) (Kind.Term.replace x8 idx val) (Kind.Term.replace x9 idx val))
(Kind.Term.replace (Kind.Term.ct11 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10) idx val) = (Kind.Term.ct11 ctid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val) (Kind.Term.replace x3 idx val) (Kind.Term.replace x4 idx val) (Kind.Term.replace x5 idx val) (Kind.Term.replace x6 idx val) (Kind.Term.replace x7 idx val) (Kind.Term.replace x8 idx val) (Kind.Term.replace x9 idx val) (Kind.Term.replace x10 idx val))
(Kind.Term.replace (Kind.Term.ct12 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11) idx val) = (Kind.Term.ct12 ctid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val) (Kind.Term.replace x3 idx val) (Kind.Term.replace x4 idx val) (Kind.Term.replace x5 idx val) (Kind.Term.replace x6 idx val) (Kind.Term.replace x7 idx val) (Kind.Term.replace x8 idx val) (Kind.Term.replace x9 idx val) (Kind.Term.replace x10 idx val) (Kind.Term.replace x11 idx val))
(Kind.Term.replace (Kind.Term.ct13 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) idx val) = (Kind.Term.ct13 ctid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val) (Kind.Term.replace x3 idx val) (Kind.Term.replace x4 idx val) (Kind.Term.replace x5 idx val) (Kind.Term.replace x6 idx val) (Kind.Term.replace x7 idx val) (Kind.Term.replace x8 idx val) (Kind.Term.replace x9 idx val) (Kind.Term.replace x10 idx val) (Kind.Term.replace x11 idx val) (Kind.Term.replace x12 idx val))
(Kind.Term.replace (Kind.Term.ct14 ctid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13) idx val) = (Kind.Term.ct14 ctid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val) (Kind.Term.replace x3 idx val) (Kind.Term.replace x4 idx val) (Kind.Term.replace x5 idx val) (Kind.Term.replace x6 idx val) (Kind.Term.replace x7 idx val) (Kind.Term.replace x8 idx val) (Kind.Term.replace x9 idx val) (Kind.Term.replace x10 idx val) (Kind.Term.replace x11 idx val) (Kind.Term.replace x12 idx val) (Kind.Term.replace x13 idx val))
(Kind.Term.replace (Kind.Term.fn0 fnid orig) idx val) = (Kind.Term.FN0 fnid orig)
(Kind.Term.replace (Kind.Term.fn1 fnid orig x0) idx val) = (Kind.Term.FN1 fnid orig (Kind.Term.replace x0 idx val))
(Kind.Term.replace (Kind.Term.fn2 fnid orig x0 x1) idx val) = (Kind.Term.FN2 fnid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val))
(Kind.Term.replace (Kind.Term.fn3 fnid orig x0 x1 x2) idx val) = (Kind.Term.FN3 fnid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val))
(Kind.Term.replace (Kind.Term.fn4 fnid orig x0 x1 x2 x3) idx val) = (Kind.Term.FN4 fnid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val) (Kind.Term.replace x3 idx val))
(Kind.Term.replace (Kind.Term.fn5 fnid orig x0 x1 x2 x3 x4) idx val) = (Kind.Term.FN5 fnid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val) (Kind.Term.replace x3 idx val) (Kind.Term.replace x4 idx val))
(Kind.Term.replace (Kind.Term.fn6 fnid orig x0 x1 x2 x3 x4 x5) idx val) = (Kind.Term.FN6 fnid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val) (Kind.Term.replace x3 idx val) (Kind.Term.replace x4 idx val) (Kind.Term.replace x5 idx val))
(Kind.Term.replace (Kind.Term.fn7 fnid orig x0 x1 x2 x3 x4 x5 x6) idx val) = (Kind.Term.FN7 fnid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val) (Kind.Term.replace x3 idx val) (Kind.Term.replace x4 idx val) (Kind.Term.replace x5 idx val) (Kind.Term.replace x6 idx val))
(Kind.Term.replace (Kind.Term.fn8 fnid orig x0 x1 x2 x3 x4 x5 x6 x7) idx val) = (Kind.Term.FN8 fnid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val) (Kind.Term.replace x3 idx val) (Kind.Term.replace x4 idx val) (Kind.Term.replace x5 idx val) (Kind.Term.replace x6 idx val) (Kind.Term.replace x7 idx val))
(Kind.Term.replace (Kind.Term.fn9 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8) idx val) = (Kind.Term.FN9 fnid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val) (Kind.Term.replace x3 idx val) (Kind.Term.replace x4 idx val) (Kind.Term.replace x5 idx val) (Kind.Term.replace x6 idx val) (Kind.Term.replace x7 idx val) (Kind.Term.replace x8 idx val))
(Kind.Term.replace (Kind.Term.fn10 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9) idx val) = (Kind.Term.FN10 fnid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val) (Kind.Term.replace x3 idx val) (Kind.Term.replace x4 idx val) (Kind.Term.replace x5 idx val) (Kind.Term.replace x6 idx val) (Kind.Term.replace x7 idx val) (Kind.Term.replace x8 idx val) (Kind.Term.replace x9 idx val))
(Kind.Term.replace (Kind.Term.fn11 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10) idx val) = (Kind.Term.FN11 fnid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val) (Kind.Term.replace x3 idx val) (Kind.Term.replace x4 idx val) (Kind.Term.replace x5 idx val) (Kind.Term.replace x6 idx val) (Kind.Term.replace x7 idx val) (Kind.Term.replace x8 idx val) (Kind.Term.replace x9 idx val) (Kind.Term.replace x10 idx val))
(Kind.Term.replace (Kind.Term.fn12 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11) idx val) = (Kind.Term.FN12 fnid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val) (Kind.Term.replace x3 idx val) (Kind.Term.replace x4 idx val) (Kind.Term.replace x5 idx val) (Kind.Term.replace x6 idx val) (Kind.Term.replace x7 idx val) (Kind.Term.replace x8 idx val) (Kind.Term.replace x9 idx val) (Kind.Term.replace x10 idx val) (Kind.Term.replace x11 idx val))
(Kind.Term.replace (Kind.Term.fn13 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12) idx val) = (Kind.Term.FN13 fnid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val) (Kind.Term.replace x3 idx val) (Kind.Term.replace x4 idx val) (Kind.Term.replace x5 idx val) (Kind.Term.replace x6 idx val) (Kind.Term.replace x7 idx val) (Kind.Term.replace x8 idx val) (Kind.Term.replace x9 idx val) (Kind.Term.replace x10 idx val) (Kind.Term.replace x11 idx val) (Kind.Term.replace x12 idx val))
(Kind.Term.replace (Kind.Term.fn14 fnid orig x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13) idx val) = (Kind.Term.FN14 fnid orig (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val) (Kind.Term.replace x3 idx val) (Kind.Term.replace x4 idx val) (Kind.Term.replace x5 idx val) (Kind.Term.replace x6 idx val) (Kind.Term.replace x7 idx val) (Kind.Term.replace x8 idx val) (Kind.Term.replace x9 idx val) (Kind.Term.replace x10 idx val) (Kind.Term.replace x11 idx val) (Kind.Term.replace x12 idx val) (Kind.Term.replace x13 idx val))
(Kind.Term.replace (Kind.Term.args15 x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14) idx val) = (Kind.Term.args15 (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val) (Kind.Term.replace x3 idx val) (Kind.Term.replace x4 idx val) (Kind.Term.replace x5 idx val) (Kind.Term.replace x6 idx val) (Kind.Term.replace x7 idx val) (Kind.Term.replace x8 idx val) (Kind.Term.replace x9 idx val) (Kind.Term.replace x10 idx val) (Kind.Term.replace x11 idx val) (Kind.Term.replace x12 idx val) (Kind.Term.replace x13 idx val) (Kind.Term.replace x14 idx val))
(Kind.Term.replace (Kind.Term.args16 x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15) idx val) = (Kind.Term.args16 (Kind.Term.replace x0 idx val) (Kind.Term.replace x1 idx val) (Kind.Term.replace x2 idx val) (Kind.Term.replace x3 idx val) (Kind.Term.replace x4 idx val) (Kind.Term.replace x5 idx val) (Kind.Term.replace x6 idx val) (Kind.Term.replace x7 idx val) (Kind.Term.replace x8 idx val) (Kind.Term.replace x9 idx val) (Kind.Term.replace x10 idx val) (Kind.Term.replace x11 idx val) (Kind.Term.replace x12 idx val) (Kind.Term.replace x13 idx val) (Kind.Term.replace x14 idx val) (Kind.Term.replace x15 idx val))
(Kind.Term.replace (Kind.Term.hol orig numb) idx val) = (Kind.Term.hol orig numb)
// Kind.Term.if_all -(res: Type) (term: (Kind.Term)) (if: (_: U60) (_: U60) (_: (Kind.Term)) (_: (_: (Kind.Term)) (Kind.Term)) res) (else: res) : res
(Kind.Term.if_all (Kind.Term.all orig name typ body) func_if else) = ((((func_if orig) name) typ) body)
(Kind.Term.if_all other func_if else) = else
// Kind.Checker.new_equation (orig: U60) (left: (Kind.Term)) (right: (Kind.Term)) : (Kind.Checker (Unit))
(Kind.Checker.new_equation orig left right) = @context @depth @rhs @subst @eqts @errs (Kind.Result.checked context depth rhs subst (List.append eqts (Kind.Equation.new context orig left right)) errs (Unit.new))
// List.append -(a: Type) (xs: (List a)) (x: a) : (List a)
(List.append (List.nil) x) = (List.pure x)
(List.append (List.cons xs.h xs.t) x) = (List.cons xs.h (List.append xs.t x))
// Kind.Checker.run -(t: Type) (checker: (Kind.Checker t)) (rhs: (Bool)) : (Kind.Result t)
(Kind.Checker.run checker rhs) = ((((((checker (Kind.Context.empty)) 0) rhs) (Kind.Subst.end)) (List.nil)) (List.nil))
// String.is_nil (xs: (String)) : (Bool)
(String.is_nil "") = (Bool.true)
(String.is_nil (String.cons x xs)) = (Bool.false)
// Kind.API.output (res: (List (Pair U60 (List (Kind.Result (Unit)))))) : (String)
(Kind.API.output (List.nil)) = ""
(Kind.API.output (List.cons pair rest)) = (Pair.match pair @pair.fst @pair.snd (Kind.Printer.text (List.cons (Kind.API.output.function pair.fst pair.snd) (List.cons (Kind.API.output rest) (List.nil)))))
// Kind.API.output.function (fnid: U60) (ls: (List (Kind.Result (Unit)))) : (String)
(Kind.API.output.function fnid (List.nil)) = ""
(Kind.API.output.function fnid (List.cons (Kind.Result.checked ctx dep rhs sub eqt err val) checks)) = (Kind.API.output.function.show_errors err sub fnid checks)
(Kind.API.output.function fnid (List.cons (Kind.Result.errored ctx sub err) checks)) = (Kind.API.output.function.show_errors err sub fnid checks)
// Kind.API.output.function.show_errors (ls: (List (Kind.Error))) (sub: (Kind.Subst)) (fnid: U60) (res: (List (Kind.Result (Unit)))) : (String)
(Kind.API.output.function.show_errors (List.nil) sub fnid checks) = (Kind.API.output.function fnid checks)
(Kind.API.output.function.show_errors (List.cons err errs) sub fnid checks) = (Kind.Printer.text (List.cons (Kind.API.output.error fnid err sub) (List.cons (String.new_line) (List.cons (Kind.API.output.function.show_errors errs sub fnid checks) (List.nil)))))
// Kind.API.output.error (fnid: U60) (err: (Kind.Error)) (sub: (Kind.Subst)) : (String)
(Kind.API.output.error fnid (Kind.Error.unbound_variable ctx orig) sub) = (Kind.Printer.text (List.cons (Kind.Printer.color "4") (List.cons "Unbound Variable." (List.cons (Kind.Printer.color "0") (List.cons (String.new_line) (List.cons (Kind.API.output.error.details fnid ctx sub orig) (List.nil)))))))
(Kind.API.output.error fnid (Kind.Error.cant_infer_lambda ctx orig) sub) = (Kind.Printer.text (List.cons (Kind.Printer.color "4") (List.cons (String.cons 67 (String.cons 97 (String.cons 110 (String.cons 39 "t infer lambda.")))) (List.cons (Kind.Printer.color "0") (List.cons (String.new_line) (List.cons (Kind.API.output.error.details fnid ctx sub orig) (List.nil)))))))
(Kind.API.output.error fnid (Kind.Error.cant_infer_hole ctx orig) sub) = (Kind.Printer.text (List.cons (Kind.Printer.color "4") (List.cons (String.cons 67 (String.cons 97 (String.cons 110 (String.cons 39 "t infer hole.")))) (List.cons (Kind.Printer.color "0") (List.cons (String.new_line) (List.cons (Kind.API.output.error.details fnid ctx sub orig) (List.nil)))))))
(Kind.API.output.error fnid (Kind.Error.too_many_arguments ctx orig) sub) = (Kind.Printer.text (List.cons (Kind.Printer.color "4") (List.cons "Too many arguments." (List.cons (Kind.Printer.color "0") (List.cons (String.new_line) (List.cons (Kind.API.output.error.details fnid ctx sub orig) (List.nil)))))))
(Kind.API.output.error fnid (Kind.Error.invalid_call ctx orig) sub) = (Kind.Printer.text (List.cons (Kind.Printer.color "4") (List.cons "Invalid call." (List.cons (Kind.Printer.color "0") (List.cons (String.new_line) (List.cons (Kind.API.output.error.details fnid ctx sub orig) (List.nil)))))))
(Kind.API.output.error fnid (Kind.Error.type_mismatch ctx orig expected detected) sub) = (Kind.Printer.text (List.cons (Kind.Printer.color "4") (List.cons "Type mismatch" (List.cons (Kind.Printer.color "0") (List.cons (String.new_line) (List.cons "- Expected: " (List.cons (String.cut (Kind.Term.show (Kind.Term.fill expected sub))) (List.cons (String.new_line) (List.cons "- Detected: " (List.cons (String.cut (Kind.Term.show (Kind.Term.fill detected sub))) (List.cons (String.new_line) (List.cons (Kind.API.output.error.details fnid ctx sub orig) (List.nil)))))))))))))
(Kind.API.output.error fnid (Kind.Error.impossible_case ctx orig expected detected) sub) = (Kind.Printer.text (List.cons (Kind.Printer.color "4") (List.cons "Impossible case. You can remove it." (List.cons (Kind.Printer.color "0") (List.cons (String.new_line) (List.cons (Kind.API.output.error.details fnid ctx sub orig) (List.nil)))))))
(Kind.API.output.error fnid (Kind.Error.inspection ctx orig expected) sub) = (Kind.Printer.text (List.cons (Kind.Printer.color "4") (List.cons "Inspection." (List.cons (Kind.Printer.color "0") (List.cons (String.new_line) (List.cons "- Goal: " (List.cons (String.cut (Kind.Term.show (Kind.Term.fill expected sub))) (List.cons (String.new_line) (List.cons (Kind.API.output.error.details fnid ctx sub orig) (List.nil))))))))))
// Kind.API.output.error.details (fnid: U60) (ctx: (Kind.Context)) (sub: (Kind.Subst)) (origin: U60) : (String)
(Kind.API.output.error.details fnid ctx sub orig) = (Kind.Printer.text (List.cons (Bool.if (Kind.Context.is_empty ctx) "" (Kind.Printer.text (List.cons (Kind.Printer.color "4") (List.cons "Kind.Context:" (List.cons (Kind.Printer.color "0") (List.cons (String.new_line) (List.cons (Kind.Context.show ctx sub) (List.nil)))))))) (List.cons (Kind.Printer.color "4") (List.cons (String.cons 79 (String.cons 110 (String.cons 32 (String.cons 39 "{{#F")))) (List.cons (Show.to_string (U60.show (>> orig 48))) (List.cons (String.cons 70 (String.cons 35 (String.cons 125 (String.cons 125 (String.cons 39 ":"))))) (List.cons (Kind.Printer.color "0") (List.cons (String.new_line) (List.cons "{{#R" (List.cons (Show.to_string (U60.show (>> orig 48))) (List.cons ":" (List.cons (Show.to_string (U60.show (& orig 16777215))) (List.cons ":" (List.cons (Show.to_string (U60.show (& (>> orig 24) 16777215))) (List.cons "R#}}" (List.cons (String.new_line) (List.nil)))))))))))))))))
// Kind.Printer.color (color_code: (String)) : (String)
(Kind.Printer.color color_code) = (Kind.Printer.text (List.cons (String.cons 27 "") (List.cons "[" (List.cons color_code (List.cons "m" (List.nil))))))
// Kind.Context.is_empty (ctx: (Kind.Context)) : (Bool)
(Kind.Context.is_empty (Kind.Context.empty)) = (Bool.true)
(Kind.Context.is_empty (Kind.Context.entry name type vals rest)) = (Bool.false)
// String.cut.go (str: (String)) (df: (String)) (n: U60) : (String)
(String.cut.go "" df n) = ""
(String.cut.go (String.cons x xs) df 0) = df
(String.cut.go (String.cons x xs) df n) = (String.cons x (String.cut.go xs df (- n 1)))
// String.cut (str: (String)) : (String)
(String.cut str) = (String.cut.go str "(...)" 2048)
// Kind.Context.show.type (name: U60) (type: (Kind.Term)) (sub: (Kind.Subst)) (pad: U60) : (String)
(Kind.Context.show.type name type sub pad) = (Kind.Printer.text (List.cons "- " (List.cons (String.pad_right (U60.to_nat pad) 32 (Kind.Name.show name)) (List.cons " : " (List.cons (String.cut (Kind.Term.show (Kind.Term.fill type sub))) (List.cons (String.new_line) (List.nil)))))))
// Kind.Context.show.vals (name: U60) (vals: (List (Kind.Term))) (sub: (Kind.Subst)) (pad: U60) : (String)
(Kind.Context.show.vals name (List.nil) sub pad) = ""
(Kind.Context.show.vals name (List.cons val vals) sub pad) = (Kind.Printer.text (List.cons (Kind.Printer.color "2") (List.cons "- " (List.cons (String.pad_right (U60.to_nat pad) 32 (Kind.Name.show name)) (List.cons " = " (List.cons (String.cut (Kind.Term.show (Kind.Term.fill val sub))) (List.cons (Kind.Printer.color "0") (List.cons (String.new_line) (List.cons (Kind.Context.show.vals name vals sub pad) (List.nil))))))))))
// Kind.Context.show.go (ctx: (Kind.Context)) (subst: (Kind.Subst)) (pad: U60) : (String)
(Kind.Context.show.go (Kind.Context.empty) sub pad) = ""
(Kind.Context.show.go (Kind.Context.entry name type vals rest) sub pad) = (Kind.Printer.text (List.cons (Kind.Context.show.type name type sub pad) (List.cons (Kind.Context.show.vals name vals sub pad) (List.cons (Kind.Context.show.go rest sub pad) (List.nil)))))
// Kind.Context.show (ctx: (Kind.Context)) (subst: (Kind.Subst)) : (String)
(Kind.Context.show ctx subst) = (Kind.Context.show.go ctx subst (Kind.Context.max_name_length ctx))
// Kind.Context.max_name_length.aux (ctx: (Kind.Context)) (acc: U60) : U60
(Kind.Context.max_name_length.aux (Kind.Context.empty) acc) = acc
(Kind.Context.max_name_length.aux (Kind.Context.entry name type vals rest) acc) = (Kind.Context.max_name_length.aux rest (U60.max (Nat.to_u60 (String.length (Kind.Name.show name))) acc))
// Kind.Context.max_name_length (ctx: (Kind.Context)) : U60
(Kind.Context.max_name_length ctx) = (Kind.Context.max_name_length.aux ctx 0)
// Nat.to_u60 (n: (Nat)) : U60
(Nat.to_u60 (Nat.zero)) = 0
(Nat.to_u60 (Nat.succ n)) = (+ 1 (Nat.to_u60 n))
// U60.max (fst: U60) (snd: U60) : U60
(U60.max fst snd) = (U60.if (> fst snd) fst snd)
// String.length (xs: (String)) : (Nat)
(String.length "") = (Nat.zero)
(String.length (String.cons x xs)) = (Nat.succ (String.length xs))
// String.pad_right (size: (Nat)) (chr: (Char)) (str: (String)) : (String)
(String.pad_right (Nat.zero) chr str) = str
(String.pad_right (Nat.succ sp) chr "") = (String.cons chr (String.pad_right sp chr ""))
(String.pad_right (Nat.succ sp) chr (String.cons x xs)) = (String.cons x (String.pad_right sp chr xs))
// U60.to_nat (x: U60) : (Nat)
(U60.to_nat 0) = (Nat.zero)
(U60.to_nat n) = (Nat.succ (U60.to_nat (- n 1)))
// List.reverse -(a: Type) (xs: (List a)) : (List a)
(List.reverse xs) = (List.reverse.go xs (List.nil))
// List.reverse.go -(a: Type) (xs: (List a)) (ys: (List a)) : (List a)
(List.reverse.go (List.nil) ys) = ys
(List.reverse.go (List.cons x xs) ys) = (List.reverse.go xs (List.cons x ys))

File diff suppressed because it is too large Load Diff

View File

@ -1,390 +0,0 @@
#![allow(dead_code)]
#![allow(unused_variables)]
mod language;
mod to_kdl;
mod to_hvm;
use language::{*};
use std::collections::HashMap;
use clap::{Parser, Subcommand};
const CHECKER_HVM: &str = include_str!("checker.hvm");
#[derive(Parser)]
#[clap(author, version, about, long_about = None)]
#[clap(propagate_version = true)]
pub struct Cli {
#[clap(subcommand)]
pub command: Command,
}
#[derive(Subcommand)]
pub enum Command {
/// Check a file
#[clap(aliases = &["c"])]
Check { file: String },
/// Evaluates Main on Kind2
#[clap(aliases = &["r"])]
Eval { file: String },
/// Runs Main on the HVM
#[clap(aliases = &["r"])]
Run { file: String },
/// Derives .kind2 files from a .type file
#[clap(aliases = &["c"])]
Derive { file: String },
/// Generates a checker (.hvm) for a file
#[clap(aliases = &["c"])]
GenChecker { file: String },
/// Stringifies a file
#[clap(aliases = &["c"])]
Show { file: String },
/// Compiles a file to Kindelia (.kdl)
#[clap(aliases = &["c"])]
ToKDL { file: String },
/// Compiles a file to HVM (.hvm)
#[clap(aliases = &["c"])]
ToHVM { file: String },
}
fn main() {
match run_cli() {
Ok(..) => {}
Err(err) => {
eprintln!("{}", err);
}
};
}
fn run_cli() -> Result<(), String> {
let cli_matches = Cli::parse();
match cli_matches.command {
Command::Eval { file: path } => {
cmd_eval_main(&path)
}
Command::Run { file: path } => {
cmd_run_main(&path)
}
Command::Check { file: path } => {
cmd_check_all(&path)
}
Command::Derive { file: path } => {
cmd_derive(&path)
}
Command::GenChecker { file: path } => {
cmd_gen_checker(&path)
}
Command::Show { file: path } => {
cmd_show(&path)
}
Command::ToKDL { file: path } => {
cmd_to_kdl(&path)
}
Command::ToHVM { file: path } => {
cmd_to_hvm(&path)
}
}
}
// Commands
// --------
// Checks all definitions of a Kind2 file
fn cmd_check_all(path: &str) -> Result<(), String> {
let loaded = load(path)?;
let result = run_with_hvm(&gen_checker(&loaded.book), "Kind.API.check_all", true)?;
print!("{}", inject_highlights(&loaded.file, &result.output));
println!("Rewrites: {}", result.rewrites);
Ok(())
}
// Evaluates Main on Kind2
fn cmd_eval_main(path: &str) -> Result<(), String> {
let loaded = load(path)?;
if loaded.book.entrs.contains_key("Main") {
let result = run_with_hvm(&gen_checker(&loaded.book), "Kind.API.eval_main", true)?;
print!("{}", result.output);
println!("Rewrites: {}", result.rewrites);
Ok(())
} else {
Err("Main not found.".to_string())
}
}
// Runs Main on HVM
fn cmd_run_main(path: &str) -> Result<(), String> {
let loaded = load(path)?;
if loaded.book.entrs.contains_key("Main") {
let result = to_hvm::to_hvm_book(&loaded.book);
let result = run_with_hvm(&result, "Main", false)?;
println!("{}", result.output);
println!("Rewrites: {}", result.rewrites);
Ok(())
} else {
Err("Main not found.".to_string())
}
}
// Generates the checker file (`file.kind2` -> `file.checker.hvm`)
fn cmd_gen_checker(path: &str) -> Result<(), String> {
let loaded = load(path)?;
let gen_path = format!("{}.hvm", path.replace(".kind2",".check"));
println!("Generated '{}'.", gen_path);
std::fs::write(gen_path, gen_checker(&loaded.book)).ok();
Ok(())
}
// Stringifies a file
fn cmd_show(path: &str) -> Result<(), String> {
let loaded = load(path)?;
let result = show_book(&loaded.book);
println!("{}", result);
Ok(())
}
// Compiles a file to Kindelia (.kdl)
fn cmd_to_kdl(path: &str) -> Result<(), String> {
let loaded = load(path)?;
let comp_book = language::compile_book(&loaded.book)?;
let kdl_names = to_kdl::get_kdl_names(&comp_book)?;
let result = to_kdl::to_kdl_book(&loaded.book, &kdl_names, &comp_book)?;
print!("{}", result);
Ok(())
}
// Compiles a file to Kindelia (.kdl)
fn cmd_to_hvm(path: &str) -> Result<(), String> {
let loaded = load(path)?;
let result = to_hvm::to_hvm_book(&loaded.book);
print!("{}", result);
Ok(())
}
// Derives generic functions
fn cmd_derive(path: &str) -> Result<(), String> {
let newcode = match std::fs::read_to_string(&path) {
Err(err) => { return Err(format!("File not found: '{}'.", path)); }
Ok(code) => { code }
};
let newtype = match read_newtype(&newcode) {
Err(err) => { return Err(format!("\x1b[1m[{}]\x1b[0m\n{}", path, err)); }
Ok(book) => { book }
};
fn save_derived(path: &str, derived: &Derived) {
let dir = std::path::Path::new(&derived.path);
let txt = show_entry(&derived.entr);
let txt = format!("// Automatically derived from {}\n{}", path, txt);
println!("\x1b[4m\x1b[1mDerived '{}':\x1b[0m", derived.path);
println!("{}\n", txt);
std::fs::create_dir_all(dir.parent().unwrap()).unwrap();
std::fs::write(dir, txt).ok();
}
save_derived(path, &derive_type(&newtype));
for i in 0 .. newtype.ctrs.len() {
save_derived(path, &derive_ctr(&newtype, i));
}
save_derived(path, &derive_match(&newtype));
return Ok(());
}
// Utils
// -----
pub struct RunResult {
output: String,
rewrites: u64,
}
// Replaces line ranges `{{123:456}}` on `target` by slices of `file_code`
fn inject_highlights(file: &Vec<File>, target: &str) -> String {
let mut code = String::new();
let mut cout = target;
// Replaces file ids by names
loop {
let mut injected = false;
if let (Some(init_file_index), Some(last_file_index)) = (cout.find("{{#F"), cout.find("F#}}")) {
let file_text = &cout[init_file_index + 4 .. last_file_index];
let file_numb = file_text.parse::<u64>().unwrap() as usize;
code.push_str(&cout[0 .. init_file_index]);
code.push_str(&file[file_numb].path);
cout = &cout[last_file_index + 4 ..];
injected = true;
}
if let (Some(init_range_index), Some(last_range_index)) = (cout.find("{{#R"), cout.find("R#}}")) {
let range_text = &cout[init_range_index + 4 .. last_range_index];
let range_text = range_text.split(":").map(|x| x.parse::<u64>().unwrap()).collect::<Vec<u64>>();
let range_file = range_text[0] as usize;
let range_init = range_text[1] as usize;
let range_last = range_text[2] as usize;
code.push_str(&cout[0 .. init_range_index]);
code.push_str(&highlight_error::highlight_error(range_init, range_last, &file[range_file].code));
cout = &cout[last_range_index + 4 ..];
injected = true;
}
if !injected {
break;
}
}
code.push_str(cout);
return code;
}
// Given an HVM source, runs an expression
fn run_with_hvm(code: &str, main: &str, read_string: bool) -> Result<RunResult, String> {
let mut rt = hvm::Runtime::from_code(code)?;
let main = rt.alloc_code(main)?;
rt.run_io(main);
rt.normalize(main);
return Ok(RunResult {
output: if read_string { readback_string(&rt, main) } else { rt.show(main) },
rewrites: rt.get_rewrites(),
});
}
// Converts a HVM string to a Rust string
pub fn readback_string(rt: &hvm::Runtime, host: u64) -> String {
let str_cons = rt.get_id("String.cons");
let str_nil = rt.get_id("String.nil");
let mut term = rt.at(host);
let mut text = String::new();
loop {
if hvm::get_tag(term) == hvm::CTR {
let fid = hvm::get_ext(term);
if fid == str_cons {
let head = rt.at(hvm::get_loc(term, 0));
let tail = rt.at(hvm::get_loc(term, 1));
if hvm::get_tag(head) == hvm::NUM {
text.push(std::char::from_u32(hvm::get_num(head) as u32).unwrap_or('?'));
term = tail;
continue;
}
}
if fid == str_nil {
break;
}
}
panic!("Invalid output: {} {}", hvm::get_tag(term), rt.show(host));
}
return text;
}
// Generates a .hvm checker for a Book
fn gen_checker(book: &Book) -> String {
// Compile the Kind2 file to HVM checker
let base_check_code = to_checker_book(&book);
let mut check_code = CHECKER_HVM.to_string();
check_code.push_str(&base_check_code);
return check_code;
}
// Loader
// ======
pub struct File {
path: String,
code: String,
}
pub struct Load {
file: Vec<File>,
book: Book,
}
pub fn load(name: &str) -> Result<Load, String> {
let mut load = Load {
file: Vec::new(),
book: Book {
names: vec![],
entrs: HashMap::new(),
holes: 0,
}
};
if !std::path::Path::new(name).is_file() {
return Err(format!("File not found: '{}'", name));
}
load_entry(name, &mut load)?;
// Adjusts the Kind2 book
match adjust_book(&load.book) {
Ok(book) => {
load.book = book;
}
Err(err) => {
let (file, init, last) = get_origin_range(err.orig);
let high_line = highlight_error::highlight_error(init, last, &load.file[file].code);
return match err.kind {
AdjustErrorKind::IncorrectArity => Err(format!("Incorrect arity.\n{}", high_line)),
AdjustErrorKind::UnboundVariable { name } => Err(format!("Unbound variable '{}'.\n{}", name, high_line)),
AdjustErrorKind::RepeatedVariable => Err(format!("Repeated variable.\n{}", high_line)),
AdjustErrorKind::CantLoadType => Err(format!("Can't load type.\n{}", high_line)),
AdjustErrorKind::NoCoverage => Err(format!("Incomplete constructor coverage.\n{}", high_line)),
};
}
};
return Ok(load);
}
pub fn load_entry(name: &str, load: &mut Load) -> Result<(), String> {
if !load.book.entrs.contains_key(name) {
let path : String;
if name.ends_with(".kind2") {
path = name.to_string();
} else {
let inside_path = format!("{}/_.kind2", &name.replace(".","/")); // path ending with 'Name/_.kind'
let normal_path = format!("{}.kind2", &name.replace(".","/")); // path ending with 'Name.kind'
if std::path::Path::new(&inside_path).is_file() {
if std::path::Path::new(&normal_path).is_file() {
return Err(format!("The following files can't exist simultaneously:\n- {}\n- {}\nPlease delete one and try again.", inside_path, normal_path));
}
path = inside_path;
} else {
path = normal_path;
}
};
let newcode = match std::fs::read_to_string(&path) {
Err(err) => { return Ok(()); }
Ok(code) => { code }
};
let mut new_book = match read_book(&newcode) {
Err(err) => { return Err(format!("\x1b[1m[{}]\x1b[0m\n{}", path, err)); }
Ok(book) => { book }
};
book_set_origin_file(&mut new_book, load.file.len());
load.file.push(File { path: path.clone(), code: newcode });
for name in &new_book.names {
load.book.names.push(name.clone());
load.book.entrs.insert(name.clone(), new_book.entrs.get(name).unwrap().clone());
}
for unbound in book_get_unbounds(&new_book) {
load_entry(&unbound, load)?;
}
}
return Ok(());
}

View File

@ -1,141 +0,0 @@
// TODO: linearize variables, adding dups
// TODO: U120?
use crate::language::{*};
pub fn to_hvm_term(book: &Book, term: &Term) -> String {
if let Some(as_string) = interpret_as_string(term) {
return format!("\"{}\"", as_string);
}
match term {
Term::Typ { .. } => {
format!("Type")
}
Term::Var { orig: _, name } => {
format!("{}", name)
}
Term::Lam { orig: _, name, body } => {
let body = to_hvm_term(book, body);
format!("@{} {}", name, body)
}
Term::App { orig: _, func, argm } => {
let func = to_hvm_term(book, func);
let argm = to_hvm_term(book, argm);
format!("({} {})", func, argm)
}
Term::All { orig: _, name, tipo, body } => {
let body = to_hvm_term(book, body);
format!("0")
}
Term::Let { orig: _, name, expr, body } => {
let expr = to_hvm_term(book, expr);
let body = to_hvm_term(book, body);
format!("let {} = {}; {}", name, expr, body)
}
Term::Ann { orig: _, expr, tipo: _ } => {
let expr = to_hvm_term(book, expr);
format!("{}", expr)
}
Term::Sub { orig: _, expr, name: _, indx: _, redx: _ } => {
let expr = to_hvm_term(book, expr);
format!("{}", expr)
}
Term::Ctr { orig: _, name, args } => {
let entr = book.entrs.get(name).unwrap();
let args = args.iter().enumerate().filter(|(i,x)| !entr.args[*i].eras).map(|x| &**x.1).collect::<Vec<&Term>>();
format!("({}{})", name, args.iter().map(|x| format!(" {}", to_hvm_term(book, x))).collect::<String>())
}
Term::Fun { orig: _, name, args } => {
let entr = book.entrs.get(name).unwrap();
let args = args.iter().enumerate().filter(|(i,x)| !entr.args[*i].eras).map(|x| &**x.1).collect::<Vec<&Term>>();
format!("({}{})", name, args.iter().map(|x| format!(" {}", to_hvm_term(book, x))).collect::<String>())
}
Term::Hlp { orig: _ } => {
format!("0")
}
Term::U60 { orig: _ } => {
format!("0")
}
Term::Num { orig: _, numb } => {
format!("{}", numb)
}
Term::Op2 { orig: _, oper, val0, val1 } => {
let val0 = to_hvm_term(book, val0);
let val1 = to_hvm_term(book, val1);
format!("({} {} {})", show_oper(&oper), val0, val1)
}
Term::Hol { orig: _, numb } => {
format!("_")
}
Term::Mat { .. } => {
panic!("Internal error."); // removed after adjust()
}
}
}
pub fn to_hvm_oper(oper: &Oper) -> String {
match oper {
Oper::Add => format!("+"),
Oper::Sub => format!("-"),
Oper::Mul => format!("*"),
Oper::Div => format!("/"),
Oper::Mod => format!("%"),
Oper::And => format!("&"),
Oper::Or => format!("|"),
Oper::Xor => format!("^"),
Oper::Shl => format!("<<"),
Oper::Shr => format!(">>"),
Oper::Ltn => format!("<"),
Oper::Lte => format!("<="),
Oper::Eql => format!("=="),
Oper::Gte => format!(">="),
Oper::Gtn => format!(">"),
Oper::Neq => format!("!="),
}
}
pub fn to_hvm_rule(book: &Book, rule: &Rule) -> String {
let name = &rule.name;
let entry = book.entrs.get(name).unwrap();
let mut pats = vec![];
for (arg,pat) in entry.args.iter().zip(rule.pats.iter()) {
if !arg.eras {
pats.push(" ".to_string());
pats.push(to_hvm_term(book, pat));
}
}
let body = to_hvm_term(book, &rule.body);
format!("({}{}) = {}", name, pats.join(""), body)
}
pub fn to_hvm_entry(book: &Book, entry: &Entry) -> String {
let kind_name = if let Some(kdln) = &entry.kdln {
format!("{} #{}", entry.name, kdln)
} else {
entry.name.clone()
};
let hvm_name = &entry.name;
if hvm_name == "HVM.log" {
return "".to_string();
}
let mut args = vec![];
for arg in &entry.args {
args.push(format!(" {}({}: {})", if arg.eras { "-" } else { "" }, arg.name, show_term(&arg.tipo)));
}
if entry.rules.len() > 0 {
let mut rules = vec![];
for rule in &entry.rules {
rules.push(format!("\n{}", to_hvm_rule(book, rule)));
}
return format!("// {}{} : {}{}\n\n", kind_name, args.join(""), show_term(&entry.tipo), rules.join(""))
}
return "".to_string();
}
pub fn to_hvm_book(book: &Book) -> String {
let mut lines = vec![];
for name in &book.names {
lines.push(to_hvm_entry(book, book.entrs.get(name).unwrap()));
}
lines.join("")
}

View File

@ -1,200 +0,0 @@
use crate::language::{*};
use std::collections::HashMap;
use rand::Rng;
pub const KDL_NAME_LEN: usize = 12;
pub fn to_kdl_term(kdl_names: &HashMap<String, String>, term: &CompTerm) -> Result<String, String> {
let term = match term {
CompTerm::Var { name } => {
format!("{}", name)
}
CompTerm::Lam { name, body } => {
let body = to_kdl_term(kdl_names, body)?;
format!("@{} {}", name, body)
}
CompTerm::App { func, argm } => {
let func = to_kdl_term(kdl_names, func)?;
let argm = to_kdl_term(kdl_names, argm)?;
format!("({} {})", func, argm)
}
CompTerm::Dup { nam0, nam1, expr, body } => {
let expr = to_kdl_term(kdl_names, expr)?;
let body = to_kdl_term(kdl_names, body)?;
format!("dup {} {} = {}; {}", nam0, nam1, expr, body)
}
CompTerm::Let { name, expr, body } => {
let expr = to_kdl_term(kdl_names, expr)?;
let body = to_kdl_term(kdl_names, body)?;
format!("let {} = {}; {}", name, expr, body)
}
CompTerm::Ctr { name, args } => {
let kdl_name = kdl_names.get(name).expect(&format!("{}", name));
let args = args.iter().map(|x| to_kdl_term(kdl_names, x)).collect::<Result<Vec<String>, String>>()?;
let args = args.iter().map(|x| format!(" {}", x)).collect::<String>();
format!("{{{}{}}}", kdl_name, args)
}
CompTerm::Fun { name, args } => {
let kdl_name = kdl_names.get(name).expect(&format!("{}", name));
let args = args.iter().map(|x| to_kdl_term(kdl_names, x)).collect::<Result<Vec<String>, String>>()?;
let args = args.iter().map(|x| format!(" {}", x)).collect::<String>();
format!("({}{})", kdl_name, args)
}
CompTerm::Num { numb } => {
format!("#{}", numb)
}
CompTerm::Op2 { oper, val0, val1 } => {
let oper = show_oper(&oper);
let val0 = to_kdl_term(kdl_names, val0)?;
let val1 = to_kdl_term(kdl_names, val1)?;
format!("({} {} {})", oper, val0, val1)
}
CompTerm::Nil => {
return Err("Found nil term in compiled term while converting to kindelia".to_string());
}
};
Ok(term)
}
pub fn to_kdl_rule(book: &Book, kdl_names: &HashMap<String, String>, rule: &CompRule) -> Result<String, String> {
let name = &rule.name;
let kdl_name = kdl_names.get(name).unwrap();
let mut pats = vec![]; // stringified pattern args
for pat in rule.pats.iter() {
let pat = to_kdl_term(kdl_names, &pat)?;
pats.push(" ".to_string());
pats.push(pat);
}
let body = to_kdl_term(kdl_names, &rule.body)?;
let rule = format!("({}{}) = {}", kdl_name, pats.join(""), body);
Ok(rule)
}
pub fn to_kdl_entry(book: &Book, kdl_names: &HashMap<String, String>, entry: &CompEntry) -> Result<String, String> {
let entry = match entry.name.as_str() {
// Main is compiled to a run block
// TODO: Maybe we should have run blocks come from a specific type of function instead
// TODO: run statements should always come last in the block
"Main" => format!("run {{\n {}\n}}\n\n", to_kdl_term(kdl_names, &*entry.rules[0].body)?),
_ => {
let kdl_name = kdl_names.get(&entry.name).unwrap();
let args_names = entry.args.iter().map(|arg| format!(" {}", arg)).collect::<String>();
// If this entry existed in the original kind code, add some annotations as comments
let kind_entry = book.entrs.get(&entry.name);
let is_knd_ent = matches!(kind_entry, Some(_));
let cmnt = if is_knd_ent {
let kind_entry = kind_entry.unwrap();
let args_typed = kind_entry.args.iter().map(|arg|
format!(" {}({}: {})", if arg.eras { "-" } else { "" }, arg.name, show_term(&arg.tipo))
).collect::<String>();
let kind_name = format!("{} #{}", entry.name, kdl_name);
format!("// {}{} : {}\n", kind_name, args_typed, show_term(&kind_entry.tipo))
} else {
String::new()
};
// Entries with no rules become constructors
// Entries with rules become functions
let fun = if entry.rules.is_empty() {
format!("ctr {{{}{}}}\n\n", kdl_name, args_names)
} else {
let mut rules = vec![];
for rule in &entry.rules {
rules.push(format!("\n {}", to_kdl_rule(book, kdl_names, rule)?));
}
format!("fun ({}{}) {{{}\n}}\n\n", kdl_name, args_names, rules.join(""))
};
cmnt + &fun
}
};
Ok(entry)
}
pub fn to_kdl_book(book: &Book, kdl_names: &HashMap<String, String>, comp_book: &CompBook) -> Result<String, String> {
let mut lines = vec![];
for name in &comp_book.names {
let entry = comp_book.entrs.get(name).unwrap();
lines.push(to_kdl_entry(book, kdl_names, entry)?);
}
Ok(lines.join(""))
}
// Utils
// -----
// Returns a map of kind names to kindelia names
// Returns an err if any of the names can't be converted
pub fn get_kdl_names(book: &CompBook) -> Result<HashMap<String, String>, String> {
// Fits a name to the max size allowed by kindelia.
// If the name is too large, truncates and replaces the last characters by random chars.
// Fails if the namespace is too large.
fn rand_shorten(name: &String) -> Result<String, String> {
let (ns, fun) = name.rsplit_once('.').unwrap_or(("", name));
let ns = if !ns.is_empty() { format!("{}.", ns) } else { ns.to_string() };
if ns.len() > KDL_NAME_LEN - 1 {
let err = format!("Namespace for \"{}\" has more than {} characters.", name, KDL_NAME_LEN - 1);
return Err(err);
}
let max_fn_name = KDL_NAME_LEN - ns.len();
// If the name doesn't fit, truncate and insert some random characters at the end
let fun = if fun.len() > max_fn_name {
let n_rnd_chrs = usize::min(3, max_fn_name);
let fun_cut = fun[..max_fn_name - n_rnd_chrs].to_string();
let mut rng = rand::thread_rng();
let rnd_chrs = (0..n_rnd_chrs)
.map(|_| rng.gen_range(0..63))
.map(|n| encode_base64(n))
.collect::<String>();
format!("{}{}", fun_cut, rnd_chrs)
} else {
fun.to_string()
};
Ok(format!("{}{}", ns, fun))
}
fn get_kdl_name(entry: &CompEntry) -> Result<String, String> {
let kind_name = &entry.name;
let kdln = match &entry.kdln {
Some(kdln) => {
// If the entry uses a kindelia name, use it
if !kdln.chars().next().unwrap().is_uppercase() {
let err = format!("Kindelia name \"{}\" doesn't start with an uppercase letter.", kdln);
return Err(err);
}
if entry.orig {
if kdln.len() > KDL_NAME_LEN {
let err = format!("Kindelia name \"{}\" for \"{}\" has more than {} characters.", kdln, kind_name, KDL_NAME_LEN - 1);
return Err(err);
}
kdln.clone()
} else {
// For entries created by the flattener, we shorten even the kindelia name
// TODO: Since these rules can come first,
// if the kdln is too large the err will happen in the generated function,
// potentially confusing the user.
rand_shorten(kdln)?
}
},
// Otherwise, try to fit the normal kind name
None => rand_shorten(kind_name)?,
};
Ok(kdln)
}
fn encode_base64(num: u8) -> char {
match num {
0 ..= 9 => (num + b'0') as char,
10 ..= 35 => (num - 10 + b'A') as char,
36 ..= 61 => (num - 36 + b'a') as char,
62 .. => '_',
}
}
let mut kdl_names = HashMap::new();
for name in &book.names {
let kdln = get_kdl_name(book.entrs.get(name).unwrap())?;
kdl_names.insert(name.clone(), kdln);
}
Ok(kdl_names)
}