refactor: started to refactor the entire compiler inspired in rustc

This commit is contained in:
Felipe g 2022-10-04 14:02:44 -03:00
parent d1694c4c65
commit b09b544e55
162 changed files with 1040 additions and 13490 deletions

View File

@ -1,2 +1,5 @@
# Kind2 0.2.76
The main.rs and language.rs files have been broken into several parts.
The main.rs and language.rs files have been broken into several parts.
# Kind2 0.2.79
New architecture and better error messages.

1357
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,29 +1,16 @@
[package]
name = "kind2"
version = "0.2.79"
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"]
# 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"
[dev-dependencies]
pretty_assertions = "1.3.0"
ntest = "0.8.1"
walkdir = "2"
[profile.dev.package.hvm]
opt-level = 3
[[test]]
name = "kind2-tests"
path = "tests/mod.rs"
[workspace]
members = [
"src/kind-cli",
"src/kind-query",
"src/kind-tree",
"src/kind-span",
"src/kind-parser",
"src/kind-pass",
"src/kind-report",
"src/kind-checker",
"src/kind-target-kdl",
"src/kind-target-hvm",
"src/kind-optimization",
"src/kind-derive",
"src/kind-lint",
]

View File

@ -1,229 +0,0 @@
// 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;
// Types of names.
pub mod new_type;
use crate::book::name::Ident;
use crate::book::span::{FileOffset, Localized, Span};
use crate::book::term::Term;
use std::collections::HashMap;
use std::fmt::{Display, Error, Formatter};
#[derive(Clone, Debug)]
pub struct Attribute {
pub name: Ident,
pub value: Option<Ident>,
pub orig: Span
}
// A book is a collection of entries.
#[derive(Clone, Debug, Default)]
pub struct Book {
pub names: Vec<String>,
pub entrs: HashMap<Ident, Box<Entry>>,
pub holes: u64,
}
// A entry describes a function that has
// rules and a type.
#[derive(Clone, Debug)]
pub struct Entry {
pub name: Ident,
pub orig: Span,
pub args: Vec<Box<Argument>>,
pub tipo: Box<Term>,
pub rules: Vec<Box<Rule>>,
pub attrs: Vec<Attribute>
}
#[derive(Clone, Debug)]
pub struct Rule {
pub orig: Span,
pub name: Ident,
pub pats: Vec<Box<Term>>,
pub body: Box<Term>,
}
#[derive(Clone, Debug)]
pub struct Argument {
pub hide: bool,
pub orig: Span,
pub eras: bool,
pub name: Ident,
pub tipo: Box<Term>,
}
impl Book {
pub fn set_origin_file(&mut self, file: FileOffset) {
for entr in self.entrs.values_mut() {
entr.set_origin_file(file);
}
}
}
// Some constructors that are really useful.
impl Argument {
pub fn new_hidden(name: Ident, tipo: Box<Term>) -> Argument {
Argument {
hide: true,
orig: Span::Generated,
eras: true,
name,
tipo
}
}
pub fn new_accessible(name: Ident, tipo: Box<Term>) -> Argument {
Argument {
hide: false,
orig: Span::Generated,
eras: false,
name,
tipo
}
}
pub fn new_erased(name: Ident, tipo: Box<Term>) -> Argument {
Argument {
hide: false,
orig: Span::Generated,
eras: true,
name,
tipo
}
}
}
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 += 1;
}
if arg.eras {
eraseds += 1;
}
}
(hiddens, eraseds)
}
pub fn get_attribute(&self, name: &str) -> Option<Attribute> {
for attr in &self.attrs {
if attr.name.0 == name {
return Some(attr.clone())
}
}
None
}
pub fn new_type_signature(name: Ident, args: Vec<Box<Argument>>) -> Entry {
Entry {
name,
orig: Span::Generated,
args,
tipo: Box::new(Term::Typ { orig: Span::Generated }),
rules: Vec::new(),
attrs: vec![]
}
}
}
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> {
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 {
writeln!(f, "{}\n", self.entrs.get(&Ident(name.clone())).unwrap())?;
}
Ok(())
}
}
impl Localized for Rule {
fn get_origin(&self) -> Span {
self.orig
}
fn set_origin_file(&mut self, file: FileOffset) {
self.orig = self.orig.set_file(file);
for pat in &mut self.pats {
pat.set_origin_file(file);
}
self.body.set_origin_file(file);
}
}
impl Localized for Entry {
fn get_origin(&self) -> Span {
self.orig
}
fn set_origin_file(&mut self, file: FileOffset) {
self.orig = self.orig.set_file(file);
for arg in &mut self.args {
arg.set_origin_file(file);
}
for rule in &mut self.rules {
rule.set_origin_file(file);
}
self.tipo.set_origin_file(file);
}
}
impl Localized for Argument {
fn get_origin(&self) -> Span {
self.orig
}
fn set_origin_file(&mut self, file: FileOffset) {
self.tipo.set_origin_file(file);
}
}

View File

@ -1,111 +0,0 @@
use std::fmt::{Display, Error, Formatter};
#[derive(Clone, Debug)]
pub struct EncodedName(u64);
/// Describes an identifier of the language.
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Ident(pub String);
#[derive(Clone)]
pub enum Path {
Qualified(String, String),
Local(String)
}
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 /= 64;
}
name.chars().rev().collect()
}
pub fn from_string(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);
}
}
EncodedName(num)
}
}
impl Ident {
pub fn encode(&self) -> EncodedName {
EncodedName::from_string(&self.0)
}
pub fn new_path(path: &str, name: &str) -> Ident {
Ident(format!("{}.{}", path, name))
}
pub fn to_path(&self) -> String {
self.0.replace('.', "/")
}
pub fn is_ctr(&self) -> bool {
if !self.0.is_empty() {
let chr = self.0.chars().next().unwrap();
chr == '/' || ('A'..='Z').contains(&chr)
} else {
false
}
}
}
impl Path {
pub fn encode(&self) -> EncodedName {
EncodedName::from_string(&format!("{}", self))
}
pub fn new_path(path: &str, name: &str) -> Path {
Path::Qualified(path.to_string(), name.to_string())
}
}
impl Display for Ident {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
write!(f, "{}", self.0)
}
}
impl Display for Path {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
match self {
Path::Qualified(p, e) => write!(f, "{}.{}", p, e),
Path::Local(e) => write!(f, "{}", e)
}
}
}
impl Display for EncodedName {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
write!(f, "{}", self.0)
}
}

View File

@ -1,36 +0,0 @@
use std::path::{PathBuf};
use crate::book::name::Ident;
use crate::book::{Argument, Entry};
#[derive(Clone, Debug)]
pub enum NewType {
Sum(SumType),
Prod(ProdType)
}
#[derive(Clone, Debug)]
pub struct SumType {
pub name: Ident,
pub pars: Vec<Box<Argument>>,
pub ctrs: Vec<Box<Constructor>>,
}
#[derive(Clone, Debug)]
pub struct ProdType {
pub name: Ident,
pub pars: Vec<Box<Argument>>,
pub fields: Vec<Box<Argument>>,
}
#[derive(Clone, Debug)]
pub struct Constructor {
pub name: Ident,
pub args: Vec<Box<Argument>>,
}
#[derive(Clone, Debug)]
pub struct Derived {
pub path: PathBuf,
pub entr: Entry,
}

View File

@ -1,58 +0,0 @@
#[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) })
}
pub fn set_file(&self, new_file: FileOffset) -> Span {
match self {
Span::Generated => Span::Generated,
Span::Localized(SpanData { start, end, .. }) => Span::Localized(SpanData {
start: *start,
end: *end,
file: new_file,
}),
}
}
#[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),
}
}
}
pub trait Localized {
fn get_origin(&self) -> Span;
fn set_origin_file(&mut self, file: FileOffset);
}

View File

@ -1,329 +0,0 @@
use crate::book::name::Ident;
use crate::book::span::{FileOffset, Localized, 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: Ident,
args: Vec<Box<Term>>,
},
Fun {
orig: Span,
name: Ident,
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: Ident,
name: Ident,
expr: Box<Term>,
cses: Vec<(Ident, Box<Term>)>,
moti: Box<Term>,
},
Open {
orig: Span,
tipo: Ident,
name: Ident,
expr: Box<Term>,
moti: Box<Term>,
body: Box<Term>
}
}
impl Term {
pub fn new_var(name: Ident) -> Term {
Term::Var {
orig: Span::Generated,
name
}
}
pub fn interpret_as_string(&self) -> Option<String> {
let mut text = String::new();
let mut term = self;
let string_nil = Ident::new_path("String", "nil");
let string_cons = Ident::new_path("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.is_empty() {
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 { name, 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."),
Open { .. } => panic!("Internal Error: Cannot display a Term::Open because it's removed after adjust."),
}
}
}
}
impl Localized for Term {
fn get_origin(&self) -> Span {
use Term::*;
match self {
Typ { orig } => *orig,
Hlp { orig } => *orig,
U60 { orig } => *orig,
Hol { orig, .. } => *orig,
Var { orig, .. } => *orig,
Num { orig, .. } => *orig,
Lam { orig, .. } => *orig,
Ann { orig, .. } => *orig,
Op2 { orig, .. } => *orig,
All { orig, .. } => *orig,
Let { orig, .. } => *orig,
Sub { orig, .. } => *orig,
Ctr { orig, .. } => *orig,
Fun { orig, .. } => *orig,
App { orig, .. } => *orig,
Mat { orig, .. } => *orig,
Open { orig, .. } => *orig,
}
}
fn set_origin_file(&mut self, file: FileOffset) {
use Term::*;
match self {
Typ { orig } => {
*orig = orig.set_file(file);
}
Hlp { orig } => {
*orig = orig.set_file(file);
}
U60 { orig } => {
*orig = orig.set_file(file);
}
Hol { orig, .. } => {
*orig = orig.set_file(file);
}
Var { orig, .. } => {
*orig = orig.set_file(file);
}
Num { orig, .. } => {
*orig = orig.set_file(file);
}
Lam { orig, body, .. } => {
*orig = orig.set_file(file);
body.set_origin_file(file);
}
Ann { orig, expr, tipo } => {
*orig = orig.set_file(file);
expr.set_origin_file(file);
tipo.set_origin_file(file);
}
Op2 { orig, oper: _, val0, val1 } => {
*orig = orig.set_file(file);
val0.set_origin_file(file);
val1.set_origin_file(file);
}
All { orig, name: _, tipo, body } => {
*orig = orig.set_file(file);
tipo.set_origin_file(file);
body.set_origin_file(file);
}
Let { orig, name: _, expr, body } => {
*orig = orig.set_file(file);
expr.set_origin_file(file);
body.set_origin_file(file);
}
Sub {
orig,
name: _,
indx: _,
redx: _,
expr,
} => {
*orig = orig.set_file(file);
expr.set_origin_file(file);
}
Ctr { orig, name: _, args } => {
*orig = orig.set_file(file);
for arg in args {
arg.set_origin_file(file);
}
}
Fun { orig, name: _, args } => {
*orig = orig.set_file(file);
for arg in args {
arg.set_origin_file(file);
}
}
App { orig, func, argm } => {
*orig = orig.set_file(file);
func.set_origin_file(file);
argm.set_origin_file(file);
}
Mat { orig, expr, cses, moti, .. } => {
*orig = orig.set_file(file);
expr.set_origin_file(file);
for cse in cses {
cse.1.set_origin_file(file);
}
moti.set_origin_file(file);
}
Open { orig, expr, .. } => {
*orig = orig.set_file(file);
expr.set_origin_file(file);
}
}
}
}

View File

@ -1,949 +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.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)
// 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
// 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))
// 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 a 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)))))))))))))))))
// 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)
// Show : Type
(Show) = 0
// U60.if -(r: Type) (n: U60) (t: r) (f: r) : r
(U60.if 0 t f) = f
(U60.if x t f) = t
// 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.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.Term.eval_ann (orig: U60) (expr: (Kind.Term)) (type: (Kind.Term)) : (Kind.Term)
(Kind.Term.eval_ann orig expr type) = 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.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))
// 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_sub (orig: U60) (name: U60) (indx: U60) (redx: U60) (expr: (Kind.Term)) : (Kind.Term)
(Kind.Term.eval_sub orig name indx redx expr) = expr
// 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.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.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)) = "!="
// 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)
// 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)
// 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 "")
// Show.to_string (show: (Show)) : (String)
(Show.to_string show) = (show "")
// 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))
// 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))
// String.flatten (xs: (List (String))) : (String)
(String.flatten (List.nil)) = ""
(String.flatten (List.cons head tail)) = (String.concat head (String.flatten tail))
// 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)
// 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_)
// 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))))))
// 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
// 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)
// 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))
// U60.to_nat (x: U60) : (Nat)
(U60.to_nat 0) = (Nat.zero)
(U60.to_nat n) = (Nat.succ (U60.to_nat (- n 1)))
// 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)
// String.length (xs: (String)) : (Nat)
(String.length "") = (Nat.zero)
(String.length (String.cons x xs)) = (Nat.succ (String.length xs))
// 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.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))
// 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_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.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.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.set_right_hand_side (rhs: (Bool)) : (Kind.Checker (Unit))
(Kind.Checker.set_right_hand_side to_rhs) = @context @hole_depth @depth @rhs @subst @eqts @errs (Kind.Result.checked context hole_depth depth to_rhs subst eqts errs (Unit.new))
// Kind.Checker (a: Type) : Type
(Kind.Checker a) = 0
// 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_right_hand_side) @rhs (Kind.Checker.compare rhs (Kind.Term.lam orig name body) type))); (((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.get_depth : (Kind.Checker U60)
(Kind.Checker.get_depth) = @context @hole_depth @depth @rhs @subst @eqts @errs (Kind.Result.checked context hole_depth depth rhs subst eqts errs depth)
// Kind.Checker.get_context : (Kind.Checker (Kind.Context))
(Kind.Checker.get_context) = @context @hole_depth @depth @rhs @subst @eqts @errs (Kind.Result.checked context hole_depth depth rhs subst eqts errs context)
// 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.bind (Kind.Checker.new_hole orig) @arg (Kind.Checker.bind (Kind.Checker.new_hole orig) @ret let term = (Kind.Term.all orig name arg @_ ret); (Kind.Checker.bind (Kind.Checker.check (Kind.Term.lam orig name body) term) @_ (Kind.Checker.pure term)))))
(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.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.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 (Kind.Term.hol orig numb) then_fn else_val) = (Kind.Checker.bind (Kind.Checker.look numb) @got (Maybe.match got (Kind.Checker.bind (Kind.Checker.new_hole orig) @arg (Kind.Checker.bind (Kind.Checker.new_hole orig) @ret let term = (Kind.Term.all orig 0 arg @_ ret); (Kind.Checker.bind (Kind.Checker.fill numb term) @_ (Kind.Checker.infer.forall term then_fn else_val)))) @got.value (Kind.Checker.infer.forall got.value then_fn else_val)))
(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
// Kind.Checker.pure -(t: Type) (a: t) : (Kind.Checker t)
(Kind.Checker.pure res) = @context @hole_depth @depth @rhs @subst @eqts @errs (Kind.Result.checked context hole_depth depth rhs subst eqts errs res)
// Kind.Checker.fill (index: U60) (val: (Kind.Term)) : (Kind.Checker (Unit))
(Kind.Checker.fill index val) = @context @hole_depth @depth @rhs @subst @eqts @errs (Kind.Result.checked context hole_depth 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.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)
// Bool.or (a: (Bool)) (b: (Bool)) : (Bool)
(Bool.or (Bool.true) b) = (Bool.true)
(Bool.or (Bool.false) b) = b
// 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)
// 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.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.add_value (idx: U60) (val: (Kind.Term)) : (Kind.Checker (Unit))
(Kind.Checker.add_value idx val) = @context @hole_depth @depth @rhs @subst @eqts @errs (Kind.Result.checked (Kind.Context.add_value context idx val) hole_depth 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.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 @hole_depth @depth @rhs @subst @eqts @errs (Kind.Result.checked context hole_depth 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.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.extend (name: U60) (type: (Kind.Term)) (vals: (List (Kind.Term))) : (Kind.Checker (Unit))
(Kind.Checker.extend name type vals) = @context @hole_depth @depth @rhs @subst @eqts @errs (Kind.Result.checked (Kind.Context.extend context name type vals) hole_depth (+ 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.shrink : (Kind.Checker (Unit))
(Kind.Checker.shrink) = @context @hole_depth @depth @rhs @subst @eqts @errs (Kind.Result.checked (Kind.Context.shrink context) hole_depth (- 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.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 hole_depth depth rhs sub equations errs ret) then) = ((((((((then ret) context) hole_depth) 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 @hole_depth @depth @rhs @subst @eqts @errs (Kind.Checker.bind.result (((((((checker context) hole_depth) depth) rhs) subst) eqts) errs) then)
// Bool.and (a: (Bool)) (b: (Bool)) : (Bool)
(Bool.and (Bool.true) b) = b
(Bool.and (Bool.false) b) = (Bool.false)
// Kind.Checker.get_subst : (Kind.Checker (Kind.Subst))
(Kind.Checker.get_subst) = @context @hole_depth @depth @rhs @subst @eqts @errs (Kind.Result.checked context hole_depth depth rhs subst eqts errs subst)
// Kind.Checker.get_right_hand_side : (Kind.Checker (Bool))
(Kind.Checker.get_right_hand_side) = @context @hole_depth @depth @rhs @subst @eqts @errs (Kind.Result.checked context hole_depth depth rhs subst eqts errs rhs)
// Kind.Checker.look (index: U60) : (Kind.Checker (Maybe (Kind.Term)))
(Kind.Checker.look index) = @context @hole_depth @depth @rhs @subst @eqts @errs (Kind.Result.checked context hole_depth depth rhs subst eqts errs (Kind.Subst.look subst index))
// Kind.Checker.new_hole (origin: U60) : (Kind.Checker (Kind.Term))
(Kind.Checker.new_hole origin) = @context @hole_depth @depth @rhs @subst @eqts @errs (Kind.Result.checked context (+ hole_depth 1) depth rhs subst eqts errs (Kind.Term.hol origin hole_depth))
// 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 @hole_depth @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.Checker.error -(t: Type) (err: (Kind.Error)) (ret: t) : (Kind.Checker t)
(Kind.Checker.error err ret) = @context @hole_depth @depth @rhs @subst @eqts @errs (Kind.Result.checked context hole_depth depth rhs subst eqts (List.cons err errs) ret)
// 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 @hole_depth @depth @rhs @subst @eqts @errs (Kind.Result.checked context hole_depth 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)) (+ (HoleInit) 1)) 0) rhs) (Kind.Subst.end)) (List.nil)) (List.nil))
// 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.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.set_context (new_context: (Kind.Context)) : (Kind.Checker (Kind.Context))
(Kind.Checker.set_context new_context) = @old_context @hole_depth @depth @rhs @subst @eqts @errs (Kind.Result.checked new_context hole_depth depth rhs subst eqts errs old_context)
// Kind.Checker.get_equations : (Kind.Checker (List (Kind.Equation)))
(Kind.Checker.get_equations) = @context @hole_depth @depth @rhs @subst @eqts @errs (Kind.Result.checked context hole_depth depth rhs subst eqts errs eqts)
// String.is_nil (xs: (String)) : (Bool)
(String.is_nil "") = (Bool.true)
(String.is_nil (String.cons x xs)) = (Bool.false)
// 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)))))

View File

@ -1,383 +0,0 @@
use crate::book::name::Ident;
use crate::book::span::Span;
use crate::book::term::{Operator, Term};
use crate::book::{Argument, Book, Entry, Rule};
use std::fmt::Write;
pub fn to_checker_oper(oper: &Operator) -> String {
match oper {
Operator::Add => "Kind.Operator.add".to_string(),
Operator::Sub => "Kind.Operator.sub".to_string(),
Operator::Mul => "Kind.Operator.mul".to_string(),
Operator::Div => "Kind.Operator.div".to_string(),
Operator::Mod => "Kind.Operator.mod".to_string(),
Operator::And => "Kind.Operator.and".to_string(),
Operator::Or => "Kind.Operator.or".to_string(),
Operator::Xor => "Kind.Operator.xor".to_string(),
Operator::Shl => "Kind.Operator.shl".to_string(),
Operator::Shr => "Kind.Operator.shr".to_string(),
Operator::Ltn => "Kind.Operator.ltn".to_string(),
Operator::Lte => "Kind.Operator.lte".to_string(),
Operator::Eql => "Kind.Operator.eql".to_string(),
Operator::Gte => "Kind.Operator.gte".to_string(),
Operator::Gtn => "Kind.Operator.gtn".to_string(),
Operator::Neq => "Kind.Operator.neq".to_string(),
}
}
fn hide_orig(orig: &Span, lhs: bool) -> String {
if lhs {
"orig".to_string()
} else {
format!("{}", orig.encode())
}
}
pub fn to_checker_term(term: &Term, quote: bool, lhs: bool) -> String {
match term {
Term::Typ { orig } => {
format!("(Kind.Term.typ {})", hide_orig(orig, lhs))
}
Term::Var { orig, name } => {
if lhs {
format!("{}", name)
} else if quote {
format!("(Kind.Term.set_origin {} {})", orig.encode(), name.clone())
} else {
format!("{}", name.clone()) // spaces to align with quoted version
}
}
Term::All { orig, name, tipo, body } => {
format!(
"(Kind.Term.all {} {} {} λ{} {})",
hide_orig(orig, lhs),
name.encode(),
to_checker_term(tipo, quote, lhs),
name,
to_checker_term(body, quote, lhs)
)
}
Term::Lam { orig, name, body } => {
format!("(Kind.Term.lam {} {} λ{} {})", hide_orig(orig, lhs), name.encode(), name, to_checker_term(body, quote, lhs))
}
Term::App { orig, func, argm } => {
format!(
"({} {} {} {})",
if quote { "Kind.Term.app" } else { "Kind.Term.eval_app" },
hide_orig(orig, lhs),
to_checker_term(func, quote, lhs),
to_checker_term(argm, quote, lhs)
)
}
Term::Let { orig, name, expr, body } => {
format!(
"({} {} {} {} λ{} {})",
if quote { "Kind.Term.let" } else { "Kind.Term.eval_let" },
hide_orig(orig, lhs),
name.encode(),
to_checker_term(expr, quote, lhs),
name,
to_checker_term(body, quote, lhs)
)
}
Term::Ann { orig, expr, tipo } => {
format!(
"({} {} {} {})",
if quote { "Kind.Term.ann" } else { "Kind.Term.eval_ann" },
hide_orig(orig, lhs),
to_checker_term(expr, quote, lhs),
to_checker_term(tipo, quote, lhs)
)
}
Term::Sub { orig, expr, name, indx, redx } => {
format!(
"({} {} {} {} {} {})",
if quote { "Kind.Term.sub" } else { "Kind.Term.eval_sub" },
hide_orig(orig, lhs),
name.encode(),
indx,
redx,
to_checker_term(expr, quote, lhs)
)
}
Term::Ctr { orig, name, args } => {
let mut args_strs: Vec<String> = Vec::new();
for arg in args {
args_strs.push(format!(" {}", to_checker_term(arg, quote, lhs)));
}
if args.len() >= 15 {
format!(
"(Kind.Term.ct{} {}. {} (Kind.Term.args{}{}))",
args.len(),
name,
hide_orig(orig, lhs),
args.len(),
args_strs.join("")
)
} else {
format!("(Kind.Term.ct{} {}. {}{})", args.len(), name, hide_orig(orig, lhs), args_strs.join(""))
}
}
Term::Fun { orig, name, args } => {
let mut args_strs: Vec<String> = Vec::new();
for arg in args {
args_strs.push(format!(" {}", to_checker_term(arg, quote, lhs)));
}
if quote {
if args.len() >= 15 {
format!(
"(Kind.Term.fn{} {}. {}(Kind.Term.args{} {}))",
args.len(),
name,
hide_orig(orig, lhs),
args.len(),
args_strs.join("")
)
} else {
format!("(Kind.Term.fn{} {}. {}{})", args.len(), name, hide_orig(orig, lhs), args_strs.join(""))
}
} else {
format!("(F${} {}{})", name, hide_orig(orig, lhs), args_strs.join(""))
}
}
Term::Hlp { orig } => {
format!("(Kind.Term.hlp {})", hide_orig(orig, lhs))
}
Term::U60 { orig } => {
format!("(Kind.Term.u60 {})", hide_orig(orig, lhs))
}
Term::Num { orig, numb } => {
format!("(Kind.Term.num {} {})", hide_orig(orig, lhs), numb)
}
Term::Op2 { orig, oper, val0, val1 } => {
format!(
"({} {} {} {} {})",
if quote { "Kind.Term.op2" } else { "Kind.Term.eval_op" },
hide_orig(orig, lhs),
to_checker_oper(oper),
to_checker_term(val0, quote, lhs),
to_checker_term(val1, quote, lhs)
)
}
Term::Hol { orig, numb } => {
format!("(Kind.Term.hol {} {})", orig.encode(), numb)
}
Term::Mat { .. } => {
panic!("Internal error: Mat cannot be compiled to a checker because it should be removed in the adjust phase!");
}
Term::Open { .. } => {
panic!("Internal error: Open cannot be compiled to a checker because it should be removed in the adjust phase!");
}
}
}
fn to_checker_rule_chk(rule: &Rule, index: usize, vars: &mut u64, args: &mut Vec<String>) -> String {
if index < rule.pats.len() {
let (inp_patt_str, var_patt_str) = to_checker_patt_chk(&rule.pats[index], vars);
args.push(var_patt_str);
let head = inp_patt_str;
let tail = to_checker_rule_chk(rule, index + 1, vars, args);
format!("(Kind.Rule.lhs {} {})", head, tail)
} else {
format!(
"(Kind.Rule.rhs (QT{} {}. 0{}))",
index,
rule.name,
args.iter().map(|x| format!(" {}", x)).collect::<Vec<String>>().join("")
)
}
}
fn to_checker_patt_chk(patt: &Term, vars: &mut u64) -> (String, String) {
// FIXME: remove redundancy
match patt {
Term::Var { orig, name } => {
let inp = format!("(Kind.Term.var {} {} {})", orig.encode(), name.encode(), vars);
let var = format!("(Kind.Term.var {} {} {})", orig.encode(), name.encode(), vars);
*vars += 1;
(inp, var)
}
Term::Ctr { orig, name, args } => {
let mut inp_args_str = String::new();
let mut var_args_str = String::new();
for arg in args {
let (inp_arg_str, var_arg_str) = to_checker_patt_chk(arg, vars);
write!(inp_args_str, " {}", inp_arg_str).ok();
write!(var_args_str, " {}", var_arg_str).ok();
}
if args.len() >= 15 {
let inp_str = format!("(Kind.Term.ct{} {}. {} (Kind.Term.args{}{}))", args.len(), name, orig.encode(), args.len(), inp_args_str);
let var_str = format!("(Kind.Term.ct{} {}. {} (Kind.Term.args{}{}))", args.len(), name, orig.encode(), args.len(), var_args_str);
(inp_str, var_str)
} else {
let inp_str = format!("(Kind.Term.ct{} {}. {}{})", args.len(), name, orig.encode(), inp_args_str);
let var_str = format!("(Kind.Term.ct{} {}. {}{})", args.len(), name, orig.encode(), var_args_str);
(inp_str, var_str)
}
}
Term::Num { orig, numb } => {
let inp = format!("(Kind.Term.num {} {})", orig.encode(), numb);
let var = format!("(Kind.Term.num {} {})", orig.encode(), numb);
(inp, var)
}
_ => {
// TODO: This should return a proper error instead of panicking
panic!("Invalid left-hand side pattern: {}", patt);
}
}
}
fn to_checker_rule_end(name: &Ident, size: u64) -> String {
let mut vars = vec![];
for idx in 0..size {
vars.push(format!(" x{}", idx));
}
let mut text = String::new();
if size >= 15 {
writeln!(
text,
"(Q${} orig{}) = (Kind.Term.fn{} {}. orig (Kind.Term.args{}{}))",
name,
vars.join(""),
size,
name,
size,
vars.join("")
)
.ok();
writeln!(
text,
"(F${} orig{}) = (Kind.Term.fn{} {}. orig (Kind.Term.args{}{}))",
name,
vars.join(""),
size,
name,
size,
vars.join("")
)
.ok();
} else {
writeln!(text, "(Q${} orig{}) = (Kind.Term.fn{} {}. orig{})", name, vars.join(""), size, name, vars.join("")).ok();
writeln!(text, "(F${} orig{}) = (Kind.Term.fn{} {}. orig{})", name, vars.join(""), size, name, vars.join("")).ok();
}
text
}
fn to_checker_type(args: &Vec<Box<Argument>>, tipo: &Term, index: usize) -> String {
if index < args.len() {
let arg = &args[index];
format!(
"(Kind.Term.all {} {} {} λ{} {})",
0,
arg.name.encode(),
to_checker_term(&arg.tipo, true, false),
arg.name,
to_checker_type(args, tipo, index + 1)
)
} else {
to_checker_term(tipo, true, false)
}
}
fn to_checker_rule(rule: &Rule) -> String {
let mut pats = vec![];
for pat in &rule.pats {
pats.push(format!(" {}", to_checker_term(pat, false, true)));
}
let body_rhs = to_checker_term(&rule.body, true, false);
let rule_rhs = to_checker_term(&rule.body, false, false);
let mut text = String::new();
writeln!(text, "(Q${} orig{}) = {}", rule.name, pats.join(""), body_rhs).ok();
if rule.name.0 == "HVM.log" {
write!(text, "(F$HVM.log orig a r log ret) = (HVM.put (Kind.Term.show log) ret)").ok();
} else {
writeln!(text, "(F${} orig{}) = {}", rule.name, pats.join(""), rule_rhs).ok();
}
//for size in 0 .. 9 {
//let mut vars = vec![];
//for idx in 0 .. size {
//vars.push(format!(" x{}", idx));
//}
//write!(result,"(QT{} name orig{}) = (Fn{} name orig{})\n", size, vars.join(""), size, vars.join(""));
//write!(result,"(FN{} name orig{}) = (Fn{} name orig{})\n", size, vars.join(""), size, vars.join(""));
//}
text
}
pub fn to_checker_entry(entry: &Entry) -> String {
let mut result = String::new();
writeln!(result, "(NameOf {}.) = \"{}\"", entry.name, entry.name).ok();
writeln!(result, "(HashOf {}.) = %{}", entry.name, entry.name).ok();
writeln!(result, "(TypeOf {}.) = {}", entry.name, to_checker_type(&entry.args, &entry.tipo, 0)).ok();
let base_vars = (0..entry.args.len()).map(|x| format!(" x{}", x)).collect::<Vec<String>>().join("");
if entry.args.len() >= 15 {
writeln!(
result,
"(Kind.Term.FN{} {}. orig (Kind.Term.args{}{})) = (F${} orig{})",
entry.args.len(),
entry.name,
entry.args.len(),
base_vars,
entry.name,
base_vars
)
.ok();
} else {
writeln!(
result,
"(Kind.Term.FN{} {}. orig{}) = (F${} orig{})",
entry.args.len(),
entry.name,
base_vars,
entry.name,
base_vars
)
.ok();
}
writeln!(result, "(QT{} {}. orig{}) = (Q${} orig{})", entry.args.len(), entry.name, base_vars, entry.name, base_vars).ok();
for rule in &entry.rules {
write!(result, "{}", &to_checker_rule(rule)).ok();
}
if !entry.rules.is_empty() {
write!(result, "{}", &to_checker_rule_end(&entry.name, entry.rules[0].pats.len() as u64,)).ok();
}
write!(result, "(RuleOf {}.) =", entry.name).ok();
for rule in &entry.rules {
write!(result, " (List.cons {}", to_checker_rule_chk(rule, 0, &mut 0, &mut vec![])).ok();
}
write!(result, " List.nil{}", ")".repeat(entry.rules.len())).ok();
result
}
// Vendo oq da pra fazer pra
pub fn to_checker_book(book: &Book) -> String {
let mut result = String::new();
writeln!(result, "// NOTE: functions with names starting with 'F$' are evaluated differently by the").ok();
writeln!(result, "// HVM, as a specific optimization targetting Kind2. See 'HOAS_OPT' on HVM's code.\n").ok();
writeln!(result, "Functions =").ok();
writeln!(result, " let fns = List.nil").ok();
for name in &book.names {
let entry = book.entrs.get(&Ident(name.to_string())).unwrap();
writeln!(result, " let fns = (List.cons {}. fns)", entry.name).ok();
}
result.push_str(" fns\n\n");
for name in &book.names {
let entry = book.entrs.get(&Ident(name.to_string())).unwrap();
write!(result, "\n// {}", name).ok();
writeln!(result, "\n// {}", "-".repeat(name.len())).ok();
writeln!(result).ok();
write!(result, "{}", &to_checker_entry(entry)).ok();
writeln!(result).ok();
}
write!(result, "HoleInit = {}", book.holes).ok();
result
}

View File

@ -1,3 +0,0 @@
pub mod kdl;
pub mod hvm;

View File

@ -1,125 +0,0 @@
use crate::book::name::Ident;
use crate::book::term::{Operator, Term};
use crate::book::{Book, Entry, Rule};
pub fn to_hvm_term(book: &Book, term: &Term) -> String {
if let Some(as_string) = term.interpret_as_string() {
return format!("\"{}\"", as_string);
}
match term {
Term::Typ { .. } => "Type".to_string(),
Term::Var { orig: _, name } => name.to_string(),
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);
"0".to_string()
}
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: _ } => to_hvm_term(book, expr),
Term::Sub {
orig: _,
expr,
name: _,
indx: _,
redx: _,
} => to_hvm_term(book, 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: _ } => "0".to_string(),
Term::U60 { orig: _ } => "0".to_string(),
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!("({} {} {})", oper, val0, val1)
}
Term::Hol { orig: _, numb: _ } => "_".to_string(),
Term::Mat { .. } => panic!("Internal error: Term::Mat is removed after adjust"),
Term::Open { .. } => panic!("Internal error: Term::Open is removed after adjust")
}
}
pub fn to_hvm_oper(oper: &Operator) -> String {
match oper {
Operator::Add => "+".to_string(),
Operator::Sub => "-".to_string(),
Operator::Mul => "*".to_string(),
Operator::Div => "/".to_string(),
Operator::Mod => "%".to_string(),
Operator::And => "&".to_string(),
Operator::Or => "|".to_string(),
Operator::Xor => "^".to_string(),
Operator::Shl => "<<".to_string(),
Operator::Shr => ">>".to_string(),
Operator::Ltn => "<".to_string(),
Operator::Lte => "<=".to_string(),
Operator::Eql => "==".to_string(),
Operator::Gte => ">=".to_string(),
Operator::Gtn => ">".to_string(),
Operator::Neq => "!=".to_string(),
}
}
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 = entry.name.clone();
let hvm_name = &entry.name;
if hvm_name.0 == "HVM.log" {
return "".to_string();
}
let mut args = vec![];
for arg in &entry.args {
args.push(format!(" {}({}: {})", if arg.eras { "-" } else { "" }, arg.name, &arg.tipo));
}
if !entry.rules.is_empty() {
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(""), &entry.tipo, rules.join(""));
}
"".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(&Ident(name.to_string())).unwrap()));
}
lines.join("")
}

View File

@ -1,211 +0,0 @@
mod book;
use crate::book::name::Ident;
use crate::book::Book;
pub use crate::codegen::kdl::book::*;
use rand::Rng;
use std::collections::HashMap;
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 } => name.clone(),
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).unwrap_or_else(|| panic!("{}", 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).unwrap_or_else(|| panic!("{}", 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 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() {
_ => {
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(&Ident(entry.name.clone()));
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, &arg.tipo))
.collect::<String>();
format!("// {}{} : {}\n", entry.name, args_typed, &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![];
let mut run = String::new();
for name in &comp_book.names {
let entry = comp_book.entrs.get(name).unwrap();
// Functions with attribute "kdl_erase" are not compiled
// This is useful for not redefining things in the genesis block, or for creating aliases
if entry.get_attribute("kdl_erase").is_some() {
continue;
}
if entry.get_attribute("kdl_run").is_some() {
let stmnt = format!("run {{\n {}\n}}\n\n", to_kdl_term(kdl_names, &*entry.rules[0].body)?);
run.push_str(&stmnt);
continue;
}
lines.push(to_kdl_entry(book, kdl_names, entry)?);
}
Ok(lines.join("") + &run)
}
// 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, namespace: &Option<String>) -> 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.
fn rand_shorten(name: &String, ns: &str) -> String {
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 name = if name.len() > max_fn_name {
let n_rnd_chrs = usize::min(3, max_fn_name);
let name_cut = name[..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(encode_base64).collect::<String>();
format!("{}{}", name_cut, rnd_chrs)
} else {
name.clone()
};
format!("{}{}", ns, name)
}
fn get_kdl_name(entry: &CompEntry, ns: &str) -> Result<String, String> {
let kind_name = &entry.name;
// If the entry uses a kindelia name, use it
let kdln = if let Some(kdln_attr) = entry.get_attribute("kdl_name") {
let kdln = kdln_attr.value.unwrap().0;
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 {
let max_len = KDL_NAME_LEN - ns.len();
if kdln.len() > max_len {
let mut err = format!("Kindelia name \"{}\" for \"{}\" has more than {} characters.", kdln, kind_name, max_len);
if ns.len() > 0 {
err = format!("{} (Namespace \"{}\" has {})", err, ns, ns.len());
}
return Err(err);
}
format!("{}{}", ns, kdln)
} else {
// For entries created by the flattener, we shorten even the kindelia name
rand_shorten(&kdln, ns)
}
}
// Otherwise, try to fit the normal kind name
else {
rand_shorten(&kind_name.replace('.', "_"), ns)
};
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 errors = Vec::new();
let mut kdl_names = HashMap::new();
let ns = namespace.as_ref().map_or(String::new(), |ns| format!("{}.", ns));
for name in &book.names {
let entry = book.entrs.get(name).unwrap();
let kdln = get_kdl_name(entry, &ns);
match kdln {
Ok(kdln) => kdl_names.insert(name.clone(), kdln).map(|_| ()).unwrap_or(()),
Err(err) => errors.push(err),
}
}
if errors.is_empty() {
Ok(kdl_names)
} else {
Err(errors.join("\n"))
}
}

View File

@ -1,937 +0,0 @@
use crate::book::name::Ident;
use crate::book::term::{Operator, Term};
use crate::book::{Attribute, Entry, Rule};
use crate::codegen::kdl::Book;
use std::collections::HashMap;
use std::collections::HashSet;
#[derive(Clone, Debug)]
pub enum CompTerm {
Var {
name: String,
},
Lam {
name: String,
body: Box<CompTerm>,
},
App {
func: Box<CompTerm>,
argm: Box<CompTerm>,
},
Dup {
nam0: String,
nam1: String,
expr: Box<CompTerm>,
body: Box<CompTerm>,
},
Let {
name: String,
expr: Box<CompTerm>,
body: Box<CompTerm>,
},
Ctr {
name: String,
args: Vec<Box<CompTerm>>,
},
Fun {
name: String,
args: Vec<Box<CompTerm>>,
},
Num {
numb: u128,
},
Op2 {
oper: Operator,
val0: Box<CompTerm>,
val1: Box<CompTerm>,
},
Nil,
}
#[derive(Clone, Debug)]
pub struct CompRule {
pub name: String,
pub pats: Vec<Box<CompTerm>>,
pub body: Box<CompTerm>,
}
#[derive(Clone, Debug)]
pub struct CompEntry {
pub name: String,
pub args: Vec<String>,
pub rules: Vec<CompRule>,
pub attrs: Vec<Attribute>,
pub orig: bool,
}
#[derive(Clone, Debug)]
pub struct CompBook {
pub names: Vec<String>,
pub entrs: HashMap<String, CompEntry>,
}
impl CompEntry {
pub fn get_attribute(&self, name: &str) -> Option<Attribute> {
for attr in &self.attrs {
if attr.name.0 == name {
return Some(attr.clone());
}
}
None
}
}
pub fn compile_book(book: &Book) -> Result<CompBook, String> {
let mut comp_book = CompBook {
names: Vec::new(),
entrs: HashMap::new(),
};
for name in &book.names {
let entry = book.entrs.get(&Ident(name.clone())).unwrap();
// Don't compile primitive U120 operations
// TODO: If this compiler eventually gets used for other targets (like HVM), this will need to be separated.
// We could do passes of compiler features (like flattening, linearizing, etc) also separately.
if u120_to_oper(&entry.name.0).is_some() {
continue;
}
// Skip over useless entries
// TODO: This doesn't cover all cases. We need something like `erase` but for a Book.
// Also maybe there are functions of type Type that should be compiled?
if let Term::Typ { orig: _ } = &*entry.tipo {
continue;
}
let entrs = compile_entry(book, entry)?;
for entry in entrs {
comp_book.names.push(entry.name.clone());
comp_book.entrs.insert(entry.name.clone(), entry);
}
}
Ok(comp_book)
}
// Can become multiple entries after flatenning
pub fn compile_entry(book: &Book, entry: &Entry) -> Result<Vec<CompEntry>, String> {
fn compile_rule(book: &Book, entry: &Entry, rule: &Rule) -> CompRule {
let name = rule.name.0.clone();
let mut pats = Vec::new();
for (arg, pat) in entry.args.iter().zip(rule.pats.iter()) {
if !arg.eras {
let pat = erase(book, pat);
// TODO: Check if the pattern has some invalid term (anything other than num, ctr or var)
pats.push(pat);
}
}
let body = erase(book, &rule.body);
CompRule { name, pats, body }
}
fn make_u120_new(old_entry: &Entry) -> CompEntry {
// U120.new hi lo = (+ (<< hi 60) (>> (<< lo 60) 60))
CompEntry {
name: "U120.new".to_string(),
args: vec!["hi".to_string(), "lo".to_string()],
rules: vec![CompRule {
name: "U120.new".to_string(),
pats: vec![Box::new(CompTerm::Var { name: "hi".to_string() }), Box::new(CompTerm::Var { name: "lo".to_string() })],
body: Box::new(CompTerm::Op2 {
oper: Operator::Add,
val0: Box::new(CompTerm::Op2 {
oper: Operator::Shl,
val0: Box::new(CompTerm::Var { name: "hi".to_string() }),
val1: Box::new(CompTerm::Num { numb: 60 }),
}),
val1: Box::new(CompTerm::Op2 {
oper: Operator::Shr,
val0: Box::new(CompTerm::Op2 {
oper: Operator::Shl,
val0: Box::new(CompTerm::Var { name: "lo".to_string() }),
val1: Box::new(CompTerm::Num { numb: 60 }),
}),
val1: Box::new(CompTerm::Num { numb: 60 }),
}),
}),
}],
orig: true,
attrs: old_entry.attrs.clone(),
}
}
fn make_u120_low(old_entry: &Entry) -> CompEntry {
// U120.low n = (>> (<< n 60) 60))
CompEntry {
name: "U120.low".to_string(),
args: vec!["n".to_string()],
rules: vec![CompRule {
name: "U120.low".to_string(),
pats: vec![Box::new(CompTerm::Var { name: "n".to_string() })],
body: Box::new(CompTerm::Op2 {
oper: Operator::Shr,
val0: Box::new(CompTerm::Op2 {
oper: Operator::Shl,
val0: Box::new(CompTerm::Var { name: "n".to_string() }),
val1: Box::new(CompTerm::Num { numb: 60 }),
}),
val1: Box::new(CompTerm::Num { numb: 60 }),
}),
}],
orig: true,
attrs: old_entry.attrs.clone(),
}
}
fn make_u120_high(old_entry: &Entry) -> CompEntry {
// U120.high n = (>> n 60)
CompEntry {
name: "U120.high".to_string(),
args: vec!["n".to_string()],
rules: vec![CompRule {
name: "U120.high".to_string(),
pats: vec![Box::new(CompTerm::Var { name: "n".to_string() })],
body: Box::new(CompTerm::Op2 {
oper: Operator::Shr,
val0: Box::new(CompTerm::Var { name: "n".to_string() }),
val1: Box::new(CompTerm::Num { numb: 60 }),
}),
}],
orig: true,
attrs: old_entry.attrs.clone(),
}
}
match entry.name.0.as_str() {
// Some U120 functions should have a special compilation
"U120.new" => Ok(vec![make_u120_new(&entry)]),
// U120.new becomes a special function that joins two numbers as if they were U60s
// TODO: We could rewrite these both to not need this workaround, but it would become rather slow on normal HVM (~100 rewrites instead of 1)
"U120.high" => Ok(vec![make_u120_high(&entry)]),
// high and low are used for type compatibility with u60
"U120.low" => Ok(vec![make_u120_low(&entry)]),
_ => {
let new_entry = CompEntry {
name: entry.name.0.clone(),
args: entry.args.iter().filter(|x| !x.eras).map(|x| x.name.0.clone()).collect(),
rules: entry.rules.iter().map(|rule| compile_rule(book, entry, rule)).collect(),
attrs: entry.attrs.clone(),
orig: true,
};
// TODO: We probably need to handle U60 separately as well.
// Since they compile to U120, it wont overflow as expected and conversion to signed will fail.
let new_entry = convert_u120_entry(new_entry)?;
let mut new_entrs = flatten(new_entry);
for entry in &mut new_entrs {
for rule in &mut entry.rules {
linearize_rule(rule);
}
}
Ok(new_entrs)
}
}
}
// Splits an entry with rules with nested cases into multiple entries with flattened rules.
pub fn flatten(entry: CompEntry) -> Vec<CompEntry> {
fn post_inc(n: &mut u64) -> u64 {
let old_n = *n;
*n += 1;
old_n
}
fn must_split(rule: &CompRule) -> bool {
for pat in &rule.pats {
if let CompTerm::Ctr { args, .. } = &**pat {
for arg in args {
if matches!(&**arg, CompTerm::Ctr { .. } | CompTerm::Num { .. }) {
return true;
}
}
}
}
false
}
// return true on the first if both rules always match together
fn matches_together(a: &CompRule, b: &CompRule) -> (bool, bool) {
let mut same_shape = true;
for (a_pat, b_pat) in a.pats.iter().zip(&b.pats) {
match (&**a_pat, &**b_pat) {
(CompTerm::Ctr { name: a_name, .. }, CompTerm::Ctr { name: b_name, .. }) => {
if a_name != b_name {
return (false, false);
}
}
(CompTerm::Num { numb: a_numb }, CompTerm::Num { numb: b_numb }) => {
if a_numb != b_numb {
return (false, false);
}
}
(CompTerm::Ctr { .. }, CompTerm::Num { .. }) => {
return (false, false);
}
(CompTerm::Num { .. }, CompTerm::Ctr { .. }) => {
return (false, false);
}
(CompTerm::Ctr { .. }, CompTerm::Var { .. }) => {
same_shape = false;
}
(CompTerm::Num { .. }, CompTerm::Var { .. }) => {
same_shape = false;
}
_ => {}
}
}
(true, same_shape)
}
fn split_rule(rule: &CompRule, entry: &CompEntry, i: usize, name_count: &mut u64, skip: &mut HashSet<usize>) -> (CompRule, Vec<CompEntry>) {
// Each rule that must be split creates a new entry that inspects one layer of Ctrs
// The old rule is rewritten to be flat and call the new entry
let n = post_inc(name_count);
let new_entry_name = format!("{}{}_", entry.name, n);
let mut new_entry_attrs = entry.attrs.clone();
// If the old rule had a kdl name, create a new kdl name for the split entry
for attr in &mut new_entry_attrs {
if attr.name.0 == "kdl_name" {
let old_kdln = attr.value.as_ref().unwrap(); // Checked before in adjust step
let new_kdln = Ident(format!("{}{}_", old_kdln, n));
attr.value = Some(new_kdln);
break;
}
}
let mut new_entry_rules: Vec<CompRule> = Vec::new();
// Rewrite the old rule to be flat and point to the new entry
let mut old_rule_pats: Vec<Box<CompTerm>> = Vec::new();
let mut old_rule_body_args: Vec<Box<CompTerm>> = Vec::new();
let mut var_count = 0;
for pat in &rule.pats {
match &**pat {
CompTerm::Ctr { name: pat_name, args: pat_args } => {
let mut new_pat_args = Vec::new();
for field in pat_args {
let arg = match &**field {
CompTerm::Ctr { .. } | CompTerm::Num { .. } => {
let name = format!(".{}", post_inc(&mut var_count));
Box::new(CompTerm::Var { name })
}
CompTerm::Var { .. } => field.clone(),
_ => {
panic!("?");
}
};
new_pat_args.push(arg.clone());
old_rule_body_args.push(arg);
}
old_rule_pats.push(Box::new(CompTerm::Ctr {
name: pat_name.clone(),
args: new_pat_args,
}));
}
CompTerm::Var { name } => {
old_rule_pats.push(pat.clone());
old_rule_body_args.push(Box::new(CompTerm::Var { name: name.clone() }));
}
CompTerm::Num { .. } => {
old_rule_pats.push(pat.clone());
}
_ => {
panic!("Found invalid pattern \"{:?}\" while flattening entry \"{}\".", pat, entry.name);
}
}
}
let old_rule_body = Box::new(CompTerm::Fun {
name: new_entry_name.clone(),
args: old_rule_body_args,
});
let old_rule = CompRule {
name: entry.name.clone(),
pats: old_rule_pats,
body: old_rule_body,
};
//(Foo Tic (Bar a b) (Haz c d)) = A
//(Foo Tic x y) = B
//---------------------------------
//(Foo Tic (Bar a b) (Haz c d)) = B[x <- (Bar a b), y <- (Haz c d)]
//
//(Foo.0 a b c d) = ...
// Check the rules to see if there's any that will be covered by the new entry, including the rule itself.
// Skips previously checked rules to avoid duplication.
// For each unique matching rule, creates a new flattening rule for the entry.
// Ex: (Fun (Ctr1 (Ctr2))) and (Fun (Ctr1 (Ctr3))) will both flatten to (Fun (Ctr1 .0)) and can be merged
for (j, other) in entry.rules.iter().enumerate().skip(i) {
let (compatible, same_shape) = matches_together(rule, other);
if compatible {
// (Foo a (B x P) (C y0 y1)) = F
// (Foo (A k) (B x Q) y ) = G
// -----------------------------
// (Foo a (B x u) (C y0 y1)) = (Foo.0 a x u y0 y1)
// (Foo.0 a x P y0 y1) = F
// (Foo.0 (A k) x Q f0 f1) = G [y <- (C f0 f1)] // f0 and f1 are fresh
// Skip identical rules
if same_shape {
skip.insert(j);
}
let mut new_rule_pats = Vec::new();
let mut new_rule_body = other.body.clone();
for (rule_pat, other_pat) in rule.pats.iter().zip(&other.pats) {
match (&**rule_pat, &**other_pat) {
(CompTerm::Ctr { .. }, CompTerm::Ctr { args: other_pat_args, .. }) => {
// Bring the arguments of a constructor outside
new_rule_pats.extend(other_pat_args.clone());
}
(
CompTerm::Ctr {
name: rule_pat_name,
args: rule_pat_args,
},
CompTerm::Var { name: other_pat_name },
) => {
let mut new_ctr_args = vec![];
for _ in 0..rule_pat_args.len() {
let new_arg = CompTerm::Var {
name: format!(".{}", post_inc(&mut var_count)),
};
new_ctr_args.push(Box::new(new_arg.clone()));
new_rule_pats.push(Box::new(new_arg));
}
let new_ctr = CompTerm::Ctr {
name: rule_pat_name.clone(),
args: new_ctr_args,
};
subst(&mut new_rule_body, other_pat_name, &new_ctr);
}
(CompTerm::Var { .. }, _) => {
new_rule_pats.push(other_pat.clone());
}
// Nums are like Ctr with no args, so nothing to bring out
(CompTerm::Num { .. }, CompTerm::Num { .. }) => (),
(CompTerm::Num { .. }, CompTerm::Var { name: other_pat_name }) => {
subst(&mut new_rule_body, other_pat_name, rule_pat);
}
_ => {
panic!("Internal error. Please report."); // not possible since it matches
}
}
}
let new_rule = CompRule {
name: new_entry_name.clone(),
pats: new_rule_pats,
body: new_rule_body,
};
new_entry_rules.push(new_rule);
}
}
assert!(!new_entry_rules.is_empty()); // There's at least one rule, since rules always match with themselves
let new_entry_args = (0..new_entry_rules[0].pats.len()).map(|n| format!("x{}", n)).collect();
let new_entry = CompEntry {
name: new_entry_name,
args: new_entry_args,
rules: new_entry_rules,
attrs: new_entry_attrs,
orig: false,
};
let new_split_entries = flatten(new_entry);
(old_rule, new_split_entries)
}
let mut name_count = 0;
let mut skip: HashSet<usize> = HashSet::new();
let mut new_entries: Vec<CompEntry> = Vec::new();
let mut old_entry_rules: Vec<CompRule> = Vec::new();
let old_entry_args: Vec<String> = entry.args.clone();
for i in 0..entry.rules.len() {
if !skip.contains(&i) {
let rule = &entry.rules[i];
if must_split(rule) {
let (old_rule, split_entries) = split_rule(rule, &entry, i, &mut name_count, &mut skip);
old_entry_rules.push(old_rule);
new_entries.extend(split_entries);
} else {
old_entry_rules.push(entry.rules[i].clone());
}
}
}
let old_entry = CompEntry {
name: entry.name,
args: old_entry_args,
rules: old_entry_rules,
orig: entry.orig,
attrs: entry.attrs,
};
new_entries.push(old_entry);
new_entries
}
// Substitute all instances of a variable in a term with another term
pub fn subst(term: &mut CompTerm, sub_name: &str, value: &CompTerm) {
match term {
CompTerm::Var { name } => {
if sub_name == name {
*term = value.clone();
}
}
CompTerm::Dup { nam0, nam1, expr, body } => {
subst(&mut *expr, sub_name, value);
if nam0 != sub_name && nam1 != sub_name {
subst(&mut *body, sub_name, value);
}
}
CompTerm::Let { name, expr, body } => {
subst(&mut *expr, sub_name, value);
if name != sub_name {
subst(&mut *body, sub_name, value);
}
}
CompTerm::Lam { name, body } => {
if name != sub_name {
subst(&mut *body, sub_name, value);
}
}
CompTerm::App { func, argm } => {
subst(&mut *func, sub_name, value);
subst(&mut *argm, sub_name, value);
}
CompTerm::Ctr { args, .. } => {
for arg in args {
subst(&mut *arg, sub_name, value);
}
}
CompTerm::Fun { args, .. } => {
for arg in args {
subst(&mut *arg, sub_name, value);
}
}
CompTerm::Num { .. } => {}
CompTerm::Op2 { val0, val1, .. } => {
subst(&mut *val0, sub_name, value);
subst(&mut *val1, sub_name, value);
}
CompTerm::Nil => {}
}
}
// Removes proof-irrelevant parts of the term
pub fn erase(book: &Book, term: &Term) -> Box<CompTerm> {
match term {
Term::Typ { .. } => Box::new(CompTerm::Nil),
Term::Var { orig: _, name } => {
let name = name.0.clone();
Box::new(CompTerm::Var { name })
}
Term::Lam { orig: _, name, body } => {
let name = name.0.clone();
let body = erase(book, body);
Box::new(CompTerm::Lam { name, body })
}
Term::App { orig: _, func, argm } => {
let func = erase(book, func);
let argm = erase(book, argm);
Box::new(CompTerm::App { func, argm })
}
Term::All {
orig: _,
name: _,
tipo: _,
body: _,
} => Box::new(CompTerm::Nil),
Term::Let { orig: _, name, expr, body } => {
let name = name.0.clone();
let expr = erase(book, expr);
let body = erase(book, body);
Box::new(CompTerm::Let { name, expr, body })
}
Term::Ann { orig: _, expr, tipo: _ } => erase(book, expr),
Term::Sub {
orig: _,
expr,
name: _,
indx: _,
redx: _,
} => erase(book, expr),
Term::Ctr { orig: _, name, args: term_args } => {
let name = name.0.clone();
let entr = book.entrs.get(&Ident(name.clone())).unwrap();
let mut args = vec![];
for (idx, arg) in term_args.iter().enumerate() {
if !entr.args[idx].eras {
args.push(erase(book, arg));
}
}
Box::new(CompTerm::Ctr { name, args })
}
Term::Fun { orig: _, name, args: term_args } => {
let name = name.0.clone();
let entr = book.entrs.get(&Ident(name.clone())).unwrap();
let mut args = vec![];
for (idx, arg) in term_args.iter().enumerate() {
if !entr.args[idx].eras {
args.push(erase(book, arg));
}
}
Box::new(CompTerm::Fun { name, args })
}
Term::Hlp { orig: _ } => Box::new(CompTerm::Nil),
Term::U60 { orig: _ } => Box::new(CompTerm::Nil),
Term::Num { orig: _, numb } => {
let numb = *numb as u128;
Box::new(CompTerm::Num { numb })
}
Term::Op2 { orig: _, oper, val0, val1 } => {
let oper = *oper;
let val0 = erase(book, val0);
let val1 = erase(book, val1);
Box::new(CompTerm::Op2 { oper, val0, val1 })
}
Term::Hol { orig: _, numb: _ } => Box::new(CompTerm::Nil),
Term::Mat { .. } => Box::new(CompTerm::Nil),
Term::Open { .. } => Box::new(CompTerm::Nil),
}
}
// Counts usages of a name in an erased term
pub fn count_uses(term: &CompTerm, count_name: &str) -> usize {
match term {
CompTerm::Var { name } => {
if name == count_name {
1
} else {
0
}
}
CompTerm::Lam { name, body } => {
if name == count_name {
0
} else {
count_uses(body, count_name)
}
}
CompTerm::App { func, argm } => count_uses(func, count_name) + count_uses(argm, count_name),
CompTerm::Dup { nam0, nam1, expr, body } => {
let expr_count = count_uses(expr, count_name);
let body_count = if nam0 == count_name || nam1 == count_name { 0 } else { count_uses(body, count_name) };
expr_count + body_count
}
CompTerm::Let { name, expr, body } => {
let expr_count = count_uses(expr, count_name);
let body_count = if name == count_name { 0 } else { count_uses(body, count_name) };
expr_count + body_count
}
CompTerm::Ctr { name: _, args } => {
let mut sum = 0;
for arg in args {
sum += count_uses(arg, count_name);
}
sum
}
CompTerm::Fun { name: _, args } => {
let mut sum = 0;
for arg in args {
sum += count_uses(arg, count_name);
}
sum
}
CompTerm::Op2 { oper: _, val0, val1 } => count_uses(val0, count_name) + count_uses(val1, count_name),
CompTerm::Num { .. } => 0,
CompTerm::Nil => 0,
}
}
// Renames a target variable using the fresh names in a vector
pub fn rename_clones(term: &mut CompTerm, target: &str, names: &mut Vec<String>) {
match term {
CompTerm::Var { name } => {
if name == target {
*name = names.pop().unwrap();
}
}
CompTerm::Lam { name, body } => {
if name != target {
rename_clones(body, target, names);
}
}
CompTerm::App { func, argm } => {
rename_clones(func, target, names);
rename_clones(argm, target, names);
}
CompTerm::Dup { nam0, nam1, expr, body } => {
rename_clones(expr, target, names);
if nam0 != target && nam1 != target {
rename_clones(body, target, names);
}
}
CompTerm::Let { name, expr, body } => {
rename_clones(expr, target, names);
if name != target {
rename_clones(body, target, names);
}
}
CompTerm::Ctr { name: _, args } => {
for arg in args {
rename_clones(arg, target, names);
}
}
CompTerm::Fun { name: _, args } => {
for arg in args {
rename_clones(arg, target, names);
}
}
CompTerm::Op2 { oper: _, val0, val1 } => {
rename_clones(val0, target, names);
rename_clones(val1, target, names);
}
CompTerm::Num { .. } => {}
CompTerm::Nil => {}
}
}
pub fn linearize_rule(rule: &mut CompRule) {
// Returns left-hand side variables
fn collect_lhs_vars<'a>(term: &'a mut CompTerm, vars: &mut HashMap<String, &'a mut CompTerm>) {
match term {
CompTerm::Var { name } => {
vars.insert(name.clone(), term);
}
CompTerm::App { func, argm } => {
collect_lhs_vars(func, vars);
collect_lhs_vars(argm, vars);
}
CompTerm::Ctr { args, .. } => {
for arg in args {
collect_lhs_vars(arg, vars);
}
}
CompTerm::Num { .. } => {}
_ => {
panic!("Invalid left-hand side.");
}
}
}
// linearize_name (Foo x x x x) 'x' 0
// ----------------------------------------------------------------
// dup x0 x1 = x; dup x2 x3 = x0; dup x4 x5 = x1; (Foo x2 x3 x4 x5)
// Returns the number of times the variable was used in the body.
pub fn linearize_name(body: &mut CompTerm, name: &mut String, fresh: &mut u64) -> usize {
fn fresh_name(fresh: &mut u64) -> String {
let name = format!("_{}", fresh);
*fresh += 1;
name
}
let uses = count_uses(body, name);
if uses > 1 {
let mut names = vec![];
for _ in 0..(uses - 1) * 2 {
names.push(fresh_name(fresh));
}
//println!("-> uses is {}, names is {:?}", uses, names);
let mut renames = vec![];
for rename in names[names.len() - uses..].iter().rev() {
renames.push(rename.clone());
}
rename_clones(body, name, &mut renames);
for i in (0..uses - 1).rev() {
let nam0 = names[i * 2].clone();
let nam1 = names[i * 2 + 1].clone();
let expr = Box::new(CompTerm::Var {
name: if i == 0 { name.to_string() } else { names[i - 1].clone() },
});
let new_body = CompTerm::Dup {
nam0,
nam1,
expr,
body: Box::new(CompTerm::Nil),
};
let old_body = std::mem::replace(body, new_body);
if let CompTerm::Dup { ref mut body, .. } = body {
let _ = std::mem::replace(body, Box::new(old_body));
}
}
} else if uses == 0 {
*name = String::from("~")
}
uses
}
// Linearies an erased term, replacing cloned variables by dups
pub fn linearize_term(term: &mut CompTerm, fresh: &mut u64) {
//println!("Linearizing: {:?}", term);
match term {
CompTerm::Var { name: _ } => {}
CompTerm::Lam { ref mut name, body } => {
linearize_term(body, fresh);
linearize_name(body, name, fresh);
}
CompTerm::App { func, argm } => {
linearize_term(func, fresh);
linearize_term(argm, fresh);
}
CompTerm::Let { ref mut name, expr, body } => {
linearize_term(expr, fresh);
linearize_term(body, fresh);
linearize_name(body, name, fresh);
}
CompTerm::Ctr { name: _, args } => {
for arg in args {
linearize_term(arg, fresh);
}
}
CompTerm::Fun { name: _, args } => {
for arg in args {
linearize_term(arg, fresh);
}
}
CompTerm::Op2 { oper: _, val0, val1 } => {
linearize_term(val0, fresh);
linearize_term(val1, fresh);
}
CompTerm::Dup {
ref mut nam0,
ref mut nam1,
expr,
body,
..
} => {
// should be unreachable under normal usage, but I made it anyway
linearize_term(expr, fresh);
linearize_term(body, fresh);
linearize_name(body, nam0, fresh);
linearize_name(body, nam1, fresh);
}
CompTerm::Num { .. } => {}
CompTerm::Nil => {}
}
}
let mut vars = HashMap::new(); // rule pattern vars
for pat in &mut rule.pats {
collect_lhs_vars(&mut **pat, &mut vars);
}
let mut fresh = 0;
for (mut name, var) in vars.drain() {
// linearizes rule pattern vars
// The &mut here doesn't do anything because we're dropping var immediately afterwards.
// To linearize rule variables, we'll have to replace all LHS occurrences by ~ if the amount of uses is zero
let uses = linearize_name(&mut rule.body, &mut name, &mut fresh);
if uses == 0 {
if let CompTerm::Var { name } = var {
*name = String::from("~");
}
}
// The reason why we don't simply pass a real mutable reference to our variable
// (instead of a mutable reference of a clone)
// to linearize_name is because since `var` is in `body`, we would
// be borrowing `var` mutably twice, which is not allowed.
// The reason why linearize_name takes in a mutable reference is
// to replace unused vars by ~. This is useful, for example, in
// lambdas. (@x0 #0 should be linearized to @~ #0)
}
linearize_term(&mut rule.body, &mut fresh); // linearizes internal bound vars
}
// Swaps u120 numbers and functions for primitive operations for kindelia compilation
pub fn convert_u120_entry(entry: CompEntry) -> Result<CompEntry, String> {
let mut new_rules = Vec::new();
for CompRule { name, pats, body } in entry.rules {
let body = convert_u120_term(&body, true)?;
let mut new_pats = Vec::new();
for pat in pats {
new_pats.push(convert_u120_term(&pat, false)?);
}
new_rules.push(CompRule { name, pats: new_pats, body });
}
Ok(CompEntry { rules: new_rules, ..entry })
}
pub fn convert_u120_term(term: &CompTerm, rhs: bool) -> Result<Box<CompTerm>, String> {
let term = Box::new(match term {
// Swap U120.new by a number
CompTerm::Ctr { name, args } => {
if name == "U120.new" {
if let (CompTerm::Num { numb: num1 }, CompTerm::Num { numb: num2 }) = (&*args[0], &*args[1]) {
CompTerm::Num { numb: (num1 << 60) + num2 }
} else if rhs {
let args = args.iter().map(|x| convert_u120_term(x, rhs)).collect::<Result<Vec<Box<CompTerm>>, String>>()?;
CompTerm::Fun { name: name.clone(), args }
} else {
return Err("Can't compile pattern match on U120 to kindelia".to_string());
}
} else {
let args = args.iter().map(|x| convert_u120_term(x, rhs)).collect::<Result<Vec<Box<CompTerm>>, String>>()?;
CompTerm::Ctr { name: name.clone(), args }
}
}
// Swap U120 functions by primitive operations
CompTerm::Fun { name, args } => {
if let Some(oper) = u120_to_oper(name) {
let val0 = convert_u120_term(&*args[0], rhs)?;
let val1 = convert_u120_term(&*args[1], rhs)?;
CompTerm::Op2 { oper, val0, val1 }
} else {
let args = args.iter().map(|x| convert_u120_term(x, rhs)).collect::<Result<Vec<Box<CompTerm>>, String>>()?;
CompTerm::Fun { name: name.clone(), args }
}
}
CompTerm::Var { name: _ } => term.clone(),
CompTerm::Lam { name, body } => {
let body = convert_u120_term(body, rhs)?;
CompTerm::Lam { name: name.clone(), body }
}
CompTerm::App { func, argm } => {
let func = convert_u120_term(func, rhs)?;
let argm = convert_u120_term(argm, rhs)?;
CompTerm::App { func, argm }
}
CompTerm::Dup { nam0, nam1, expr, body } => {
let expr = convert_u120_term(expr, rhs)?;
let body = convert_u120_term(body, rhs)?;
CompTerm::Dup {
nam0: nam0.clone(),
nam1: nam1.clone(),
expr,
body,
}
}
CompTerm::Let { name, expr, body } => {
let expr = convert_u120_term(expr, rhs)?;
let body = convert_u120_term(body, rhs)?;
CompTerm::Let { name: name.clone(), expr, body }
}
CompTerm::Num { numb: _ } => term.clone(),
CompTerm::Op2 { oper, val0, val1 } => {
let val0 = convert_u120_term(val0, rhs)?;
let val1 = convert_u120_term(val1, rhs)?;
CompTerm::Op2 { oper: *oper, val0, val1 }
}
CompTerm::Nil => {
return Err("Found nil term during compilation".to_string());
}
});
Ok(term)
}
// Converts a U120 function name to the corresponding primitive operation
// None if the name is not of an operation
pub fn u120_to_oper(name: &str) -> Option<Operator> {
match name {
"U120.add" => Some(Operator::Add),
"U120.sub" => Some(Operator::Sub),
"U120.mul" => Some(Operator::Mul),
"U120.div" => Some(Operator::Div),
"U120.mod" => Some(Operator::Mod),
"U120.bitwise_and" => Some(Operator::And),
"U120.bitwise_or" => Some(Operator::Or),
"U120.bitwise_xor" => Some(Operator::Xor),
"U120.shift_left" => Some(Operator::Shl),
"U120.shift_right" => Some(Operator::Shr),
"U120.num_less_than" => Some(Operator::Ltn),
"U120.num_less_equal" => Some(Operator::Lte),
"U120.num_greater_than" => Some(Operator::Gtn),
"U120.num_greater_equal" => Some(Operator::Gte),
"U120.num_equal" => Some(Operator::Eql),
"U120.num_not_equal" => Some(Operator::Neq),
_ => None,
}
}

View File

@ -1,5 +0,0 @@
pub mod sum_type;
pub mod prod_type;
pub use sum_type::*;
pub use prod_type::*;

View File

@ -1,181 +0,0 @@
use std::path::{Path, PathBuf};
use crate::book::{Entry, new_type::{ProdType, Derived, SumType, Constructor}, Argument, name::Ident, term::Term, span::Span, Rule};
use super::derive_match;
fn args_to_vars(vec: &[Box<Argument>]) -> Vec<Box<Term>> {
vec
.iter()
.map(|x| {
Box::new(Term::Var {
orig: Span::Generated,
name: x.name.clone(),
})
})
.collect()
}
pub fn derive_prod_type(path: &str, tipo: &ProdType) -> Derived {
let root = Path::new(path).join(tipo.name.to_path());
let path = root.join("_.kind2");
let name = tipo.name.clone();
Derived {
path,
entr: Entry::new_type_signature(name, tipo.pars.clone())
}
}
pub fn derive_prod_constructor(prod: &ProdType) -> Derived {
let name = Ident::new_path(&prod.name.0, "new");
let path = format!("{}/new.kind2", prod.name.0.replace('.', "/"));
let mut args = prod.pars.clone();
for field in &prod.fields {
args.push(field.clone())
}
let tipo = Box::new(Term::Ctr {
orig: Span::Generated,
name: prod.name.clone(),
args: args_to_vars(&prod.pars)
});
Derived {
path: PathBuf::from(path),
entr: Entry {
name,
orig: Span::Generated,
args: args.clone(),
tipo,
rules: vec![],
attrs: vec![]
}
}
}
pub fn derive_getters(prod: &ProdType) -> Vec<Derived> {
let mut args = prod.pars.clone();
let name_lower = prod.name.0.split('.').collect::<Vec<&str>>().pop().unwrap().to_lowercase();
let tipo = Box::new(Term::Ctr {
orig: Span::Generated,
name: prod.name.clone(),
args: args_to_vars(&prod.pars)
});
args.push(Box::new(Argument::new_accessible(Ident(name_lower), tipo)));
let mut derived = Vec::new();
for field in &prod.fields {
let name = Ident::new_path(&prod.name.0, &format!("get.{}", &field.name.0));
let path = format!("{}/get/{}.kind2", prod.name.0.replace('.', "/"), &field.name.0);
let pat = Box::new(Term::Ctr {
orig: Span::Generated,
name: Ident::new_path(&prod.name.0, "new"),
args: args_to_vars(&prod.fields)
});
let body = Box::new(Term::Var {
orig: Span::Generated,
name: field.name.clone(),
});
derived.push(Derived {
path: PathBuf::from(path),
entr: Entry {
name: name.clone(),
orig: Span::Generated,
args: args.clone(),
tipo: field.tipo.clone(),
rules: vec![Box::new(Rule { orig: Span::Generated, name, pats: vec![pat], body })],
attrs: vec![]
}
})
}
derived
}
pub fn derive_setters(prod: &ProdType) -> Vec<Derived> {
let mut args = prod.pars.clone();
let tipo = Box::new(Term::Ctr {
orig: Span::Generated,
name: prod.name.clone(),
args: args_to_vars(&prod.pars)
});
let name_lower = prod.name.0.split('.').collect::<Vec<&str>>().pop().unwrap().to_lowercase();
args.push(Box::new(Argument {
hide: false,
orig: Span::Generated,
name: Ident(name_lower),
eras: false,
tipo: tipo.clone()
}));
let mut derived = Vec::new();
for i in 0..prod.fields.len() {
let field = &prod.fields[i];
let name = Ident::new_path(&prod.name.0, &format!("set.{}", &field.name.0));
let path = format!("{}/set/{}.kind2", prod.name.0.replace('.', "/"), &field.name.0);
let new_name = Ident(format!("new_{}", field.name.clone()));
let mut args = args.clone();
args.push(Box::new(Argument { hide: false, orig: Span::Generated, eras: false, name: new_name.clone(), tipo: field.tipo.clone()}));
let pat = Box::new(Term::Ctr {
orig: Span::Generated,
name: Ident::new_path(&prod.name.0, "new"),
args: args_to_vars(&prod.fields)
});
let new_pat = Box::new(Term::Var { orig: Span::Generated, name: new_name });
let mut new_args = args_to_vars(&prod.fields);
new_args[i] = new_pat.clone();
let body = Box::new(Term::Ctr {
orig: Span::Generated,
name: Ident::new_path(&prod.name.0, "new"),
args: new_args
});
derived.push(Derived {
path: PathBuf::from(path),
entr: Entry {
name: name.clone(),
orig: Span::Generated,
args: args.clone(),
tipo: tipo.clone(),
rules: vec![Box::new(Rule { orig: Span::Generated, name, pats: vec![pat, new_pat], body })],
attrs: vec![]
}
})
}
derived
}
pub fn derive_prod_match(prod: &ProdType) -> Derived {
// We just use the same generator as the sum type.
let sum_type = SumType {
name: prod.name.clone(),
pars: prod.pars.clone(),
ctrs: vec![Box::new(Constructor {
name: Ident("new".to_string()),
args: prod.fields.clone()
})],
};
derive_match(&sum_type)
}

View File

@ -1,237 +0,0 @@
use std::path::{Path, PathBuf};
use crate::book::name::Ident;
use crate::book::new_type::{Constructor, Derived, SumType};
use crate::book::span::Span;
use crate::book::term::Term;
use crate::book::{Argument, Entry, Rule};
pub fn derive_sum_type(path: &str, tipo: &SumType) -> Derived {
let root = Path::new(path).join(tipo.name.to_path());
let path = root.join("_.kind2");
let mut args = vec![];
for par in &tipo.pars {
args.push(Box::new(Argument {
hide: false,
orig: Span::Generated,
eras: false,
name: par.name.clone(),
tipo: par.tipo.clone(),
}));
}
let entr = Entry::new_type_signature(tipo.name.clone(), args);
Derived {
path,
entr,
}
}
fn args_to_vars(vec: &[Box<Argument>]) -> Vec<Box<Term>> {
vec
.iter()
.map(|x| {
Box::new(Term::Var {
orig: Span::Generated,
name: x.name.clone(),
})
})
.collect()
}
pub fn derive_ctr(tipo: &SumType, index: usize) -> Derived {
if let Some(ctr) = tipo.ctrs.get(index) {
let path = format!("{}/{}.kind2", tipo.name.to_path(), ctr.name);
let name = format!("{}.{}", tipo.name, ctr.name);
let mut args = vec![];
for arg in &tipo.pars {
args.push(arg.clone());
}
for arg in &ctr.args {
args.push(arg.clone());
}
let tipo = Box::new(Term::Ctr {
orig: Span::Generated,
name: tipo.name.clone(),
args: tipo
.pars
.iter()
.map(|x| {
Box::new(Term::Var {
orig: Span::Generated,
name: x.name.clone(),
})
})
.collect(),
});
let rules = vec![];
let entr = Entry {
name: Ident(name),
orig: Span::Generated,
args,
tipo,
rules,
attrs: vec![]
};
Derived { path: Path::new(&path).to_owned(), entr }
} else {
panic!("Constructor out of bounds.");
}
}
pub fn derive_match(ntyp: &SumType) -> Derived {
let path = format!("{}/match.kind2", ntyp.name.0.replace('.', "/"));
fn gen_type_ctr(ntyp: &SumType) -> Box<Term> {
Box::new(Term::Ctr {
orig: Span::Generated,
name: ntyp.name.clone(),
args: args_to_vars(&ntyp.pars),
})
}
fn gen_ctr_value(ntyp: &SumType, ctr: &Constructor, _: usize, suffix: &str) -> Box<Term> {
let mut ctr_value_args = vec![];
for par in &ntyp.pars {
ctr_value_args.push(Box::new(Term::new_var(Ident(format!("{}{}", par.name, suffix)))));
}
for fld in &ctr.args {
ctr_value_args.push(Box::new(Term::new_var(Ident(format!("{}{}", fld.name, suffix)))));
}
Box::new(Term::Ctr {
orig: Span::Generated,
name: Ident::new_path(&ntyp.name.0, &ctr.name.0),
args: ctr_value_args,
})
}
// List.match
let name = Ident::new_path(&ntyp.name.0, "match");
let mut args = vec![];
// <t: Type>
for par in &ntyp.pars {
args.push(Box::new(Argument::new_hidden(par.name.clone(), par.tipo.clone())));
}
// (x: (List t))
args.push(Box::new(Argument::new_accessible(Ident("x".to_string()), gen_type_ctr(ntyp))));
let motive_type = Box::new(Term::All {
orig: Span::Generated,
name: Ident("x".to_string()),
tipo: gen_type_ctr(ntyp),
body: Box::new(Term::Typ { orig: Span::Generated }),
});
// -(p: (List t) -> Type)
args.push(Box::new(Argument::new_erased(Ident("p".to_string()), motive_type)));
// (nil: (p (List.nil t)))
// (cons: (head t) (tail: (List t)) (p (List.cons t head tail)))
for ctr in &ntyp.ctrs {
fn ctr_case_type(ntyp: &SumType, ctr: &Constructor, index: usize) -> Box<Term> {
if index < ctr.args.len() {
// for nil = ...
// for cons = (head: t) (tail: (List t))
let arg = ctr.args.get(index).unwrap();
Box::new(Term::All {
orig: Span::Generated,
name: arg.name.clone(),
tipo: arg.tipo.clone(),
body: ctr_case_type(ntyp, ctr, index + 1),
})
} else {
// for nil = (p (List.nil t))
// for cons = (p (List.cons t head tail))
Box::new(Term::App {
orig: Span::Generated,
func: Box::new(Term::Var {
orig: Span::Generated,
name: Ident("p".to_string()),
}),
argm: gen_ctr_value(ntyp, ctr, index, ""),
})
}
}
args.push(Box::new(Argument {
eras: false,
orig: Span::Generated,
hide: false,
name: ctr.name.clone(),
tipo: ctr_case_type(ntyp, ctr, 0),
}));
}
// : (p x)
let tipo = Box::new(Term::App {
orig: Span::Generated,
func: Box::new(Term::Var {
orig: Span::Generated,
name: Ident("p".to_string()),
}),
argm: Box::new(Term::Var {
orig: Span::Generated,
name: Ident("x".to_string()),
}),
});
// List.match t (List.nil t) p nil cons = nil
// List.match t (List.cons t head tail) p nil cons = (cons head tail)
let mut rules = vec![];
for idx in 0..ntyp.ctrs.len() {
let ctr = &ntyp.ctrs[idx];
let orig = Span::Generated;
let name = format!("{}.match", ntyp.name);
let mut pats = vec![];
for par in &ntyp.pars {
pats.push(Box::new(Term::Var {
orig: Span::Generated,
name: par.name.clone(),
}));
}
pats.push(gen_ctr_value(ntyp, ctr, idx, "_"));
pats.push(Box::new(Term::Var {
orig: Span::Generated,
name: Ident("p".to_string()),
}));
for ctr in &ntyp.ctrs {
pats.push(Box::new(Term::Var {
orig: Span::Generated,
name: ctr.name.clone(),
}));
}
let mut body_args = vec![];
for arg in &ctr.args {
body_args.push(Box::new(Term::Var {
orig: Span::Generated,
name: Ident(format!("{}_", arg.name)),
}));
}
let body = Box::new(Term::Ctr {
orig: Span::Generated,
name: ctr.name.clone(),
args: body_args,
});
rules.push(Box::new(Rule {
orig,
name: Ident(name),
pats,
body,
}));
}
let entr = Entry {
name,
orig: Span::Generated,
args,
tipo,
rules,
attrs: vec![]
};
Derived { path: PathBuf::from(path), entr }
}

View File

@ -1,231 +0,0 @@
pub mod config;
pub mod loader;
use crate::book::name::Ident;
use crate::book::new_type::{Derived, NewType};
use crate::book::Book;
use crate::checker::to_checker_book;
use crate::codegen;
use crate::derive;
use crate::driver::loader::{load, File};
use crate::parser::new_type;
use crate::codegen::kdl::KDL_NAME_LEN;
use crate::driver::config::Config;
const CHECKER_HVM: &str = include_str!("checker.hvm");
pub struct RunResult {
pub output: String,
pub rewrites: u64,
}
pub fn highlight(should: bool, text: &str) -> String {
if should {
format!("\x1b[4m{}\x1b[0m", text)
} else {
text.to_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));
}
text
}
fn inject_highlights(file: &[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);
code
}
// Generates a .hvm checker for a Book
pub 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);
check_code
}
pub 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);
Ok(RunResult {
output: if read_string { readback_string(&rt, main) } else { rt.show(main) },
rewrites: rt.get_rewrites(),
})
}
pub fn cmd_to_hvm(config: &Config, path: &str) -> Result<(), String> {
let loaded = load(config, path)?;
let result = codegen::hvm::to_hvm_book(&loaded.book);
print!("{}", result);
Ok(())
}
pub fn cmd_show(config: &Config, path: &str) -> Result<(), String> {
let loaded = load(config, path)?;
println!("{}", loaded.book);
Ok(())
}
pub fn cmd_gen_checker(config: &Config, path: &str) -> Result<(), String> {
let loaded = load(config, 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(())
}
pub fn cmd_derive(config: &Config, path: &str) -> Result<(), String> {
let color = config.color_output;
let newcode = match std::fs::read_to_string(&path) {
Err(_) => {
return Err(format!("File not found: '{}'.", path));
}
Ok(code) => code,
};
let newtype = match new_type::read_newtype(&newcode) {
Err(err) => {
return Err(format!("[{}]\n{}", highlight(color, path), err));
}
Ok(book) => book,
};
fn save_derived(color: bool, path: &str, derived: &Derived) {
let dir = &derived.path;
let txt = format!("// Automatically derived from {}\n{}", path, derived.entr);
println!("Derived '{}':", highlight(color, derived.path.to_str().unwrap()));
println!("{}\n", txt);
std::fs::create_dir_all(dir.parent().unwrap()).unwrap();
std::fs::write(dir, txt).ok();
}
match *newtype {
NewType::Sum(sum) => {
// TODO: Remove this kind2_path because it's wrong.
save_derived(color, path, &derive::derive_sum_type(&config.kind2_path, &sum));
for i in 0..sum.ctrs.len() {
save_derived(color, path, &derive::derive_ctr(&sum, i));
}
save_derived(color, path, &derive::derive_match(&sum));
},
NewType::Prod(prod) => {
save_derived(color, path, &derive::derive_prod_type(&config.kind2_path, &prod));
save_derived(color, path, &derive::derive_prod_constructor(&prod));
save_derived(color, path, &derive::derive_prod_match(&prod));
let getters = derive::derive_getters(&prod);
for getter in getters {
save_derived(color, path, &getter);
}
let setters = derive::derive_setters(&prod);
for setter in setters {
save_derived(color, path, &setter);
}
}
}
Ok(())
}
pub fn cmd_check_all(config: &Config, path: &str) -> Result<(), String> {
let loaded = load(config, 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
pub fn cmd_eval_main(config: &Config, path: &str) -> Result<(), String> {
let loaded = load(config, path)?;
if loaded.book.entrs.contains_key(&Ident("Main".to_string())) {
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())
}
}
pub fn cmd_run_main(config: &Config, path: &str) -> Result<(), String> {
let loaded = load(config, path)?;
if loaded.book.entrs.contains_key(&Ident("Main".to_string())) {
let result = codegen::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())
}
}
pub fn cmd_to_kdl(config: &Config, path: &str, namespace: &Option<String>) -> Result<(), String> {
if let Some(ns) = namespace {
if ns.len() > KDL_NAME_LEN - 2 {
return Err(format!("Given namespace \"{}\"has more than {} characters.", ns, KDL_NAME_LEN - 2));
}
}
let loaded = load(config, path)?;
let comp_book = codegen::kdl::compile_book(&loaded.book)?;
let kdl_names = codegen::kdl::get_kdl_names(&comp_book, namespace)?;
let result = codegen::kdl::to_kdl_book(&loaded.book, &kdl_names, &comp_book)?;
print!("{}", result);
Ok(())
}

View File

@ -1,30 +0,0 @@
use std::fmt::Display;
#[derive(Clone, Debug, PartialEq)]
pub enum Target {
Kdl,
Hvm,
// It's useful for some operations that doesnt really
// care about attributes at all.
All,
}
impl Display for Target {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Target::Kdl => write!(f, "kdl"),
Target::Hvm => write!(f, "hvm"),
Target::All => write!(f, "all"),
}
}
}
// The configuration needed to customize
// the compiler experience
#[derive(Clone, Debug)]
pub struct Config {
pub no_high_line: bool,
pub color_output: bool,
pub kind2_path: String,
pub target: Target,
}

View File

@ -1,150 +0,0 @@
use std::path::{Path, PathBuf};
use crate::lowering::adjust::{AdjustErrorKind, AdjustError};
use crate::lowering::attributes::check_attributes;
use crate::lowering::resolve::Resolve;
use crate::parser::read_book;
use crate::book::name::Ident;
use crate::book::span::{FileOffset, Span, SpanData};
use crate::book::Book;
use super::config::Config;
#[derive(Debug, Clone)]
pub struct File {
pub path: String,
pub code: String,
}
pub struct Load {
pub file: Vec<File>,
pub book: Book,
}
impl Load {
pub fn new_empty() -> Load {
Load {
file: Vec::new(),
book: Book::default(),
}
}
}
pub fn render_error(config: &Config, files: &[File], err: AdjustError) -> String {
let high_line = match err.orig {
Span::Localized(SpanData { file, start, end }) if !config.no_high_line => format!(
"On '{}'\n{}",
files[file.0 as usize].path,
highlight_error::highlight_error(start.0 as usize, end.0 as usize, &files[file.0 as usize].code)
),
_ if !config.no_high_line => "Cannot find the source of the error.".to_string(),
_ => "".to_string(),
};
return match err.kind {
AdjustErrorKind::IncorrectArity => format!("Incorrect arity.\n{}", high_line),
AdjustErrorKind::UnboundVariable { name } => format!("Unbound variable '{}'.\n{}", name, high_line),
AdjustErrorKind::RepeatedVariable => format!("Repeated variable.\n{}", high_line),
AdjustErrorKind::CantLoadType => format!("Can't load type.\n{}", high_line),
AdjustErrorKind::NoCoverage => format!("Incomplete constructor coverage.\n{}", high_line),
AdjustErrorKind::UseOpenInstead => format!("You should use `open` instead of `match` on record types.\n{}", high_line),
AdjustErrorKind::UseMatchInstead => format!("You should use `match` instead of `open` on sum types.\n{}", high_line),
AdjustErrorKind::CannotFindAlias { name } => format!("Cannot find alias '{}' try to add an 'use' statement.\n{}", name,high_line),
AdjustErrorKind::InvalidAttribute { name } => format!("You cannot use the attribute '{}'.\n{}", name, high_line),
AdjustErrorKind::AttributeWithoutArgs { name } => format!("You should not put arguments on the attribute '{}'.\n{}", name, high_line),
AdjustErrorKind::AttributeMissingArg { name } => format!("Attribute '{}' needs to be given a value.\n{}", name, high_line),
AdjustErrorKind::WrongTargetAttribute { name, target } => format!("The attribute '{}' only works in the target '{}'.\n{}", name, target, high_line),
};
}
pub fn to_current_namespace(config: &Config, path: &PathBuf) -> String {
let base = Path::new(&config.kind2_path);
let mut cur = path.clone();
cur.set_extension("");
let cur_path = cur.strip_prefix(base);
cur_path.map(| x | {
let mut arr = x.into_iter().map(|x| x.to_str().unwrap()).collect::<Vec<&str>>();
arr.pop();
arr.join(".")
}).unwrap_or("".to_string())
}
pub fn load_entry(config: &Config, name: &str, load: &mut Load) -> Result<(), String> {
if !load.book.entrs.contains_key(&Ident(name.to_string())) {
let path: PathBuf;
let base = Path::new(&config.kind2_path);
if name.ends_with(".kind2") {
path = PathBuf::from(&name.to_string());
} else {
let mut normal_path = base.join(&name.replace('.', "/"));
let inside_path = normal_path.clone().join("_.kind2"); // path ending with 'Name/_.kind'
normal_path.set_extension("kind2");
if inside_path.is_file() {
if normal_path.is_file() {
return Err(format!(
"The following files can't exist simultaneously:\n- {}\n- {}\nPlease delete one and try again.",
inside_path.display(),
normal_path.display()
));
}
path = inside_path;
} else {
path = normal_path;
}
};
let newcode = match std::fs::read_to_string(&path) {
Err(_) => {
return Ok(());
}
Ok(code) => code,
};
let (mut new_book, uses) = match read_book(&newcode) {
Err(err) => {
return Err(format!("\x1b[1m[{}]\x1b[0m\n{}", path.display(), err));
}
Ok(book) => book,
};
let file = File {
path: path.to_str().unwrap().into(),
code: newcode,
};
let cur_mod = to_current_namespace(config, &path.clone());
new_book.resolve(&cur_mod, &uses).map_err(|err| render_error(config, &vec![file.clone()], err))?;
new_book.set_origin_file(FileOffset(load.file.len() as u32));
load.file.push(file);
for name in &new_book.names {
load.book.names.push(name.clone());
load.book.entrs.insert(Ident(name.clone()), new_book.entrs.get(&Ident(name.to_string())).unwrap().clone());
}
for unbound in &new_book.get_unbounds(config) {
load_entry(config, &unbound.0, load)?;
}
}
Ok(())
}
pub fn load(config: &Config, name: &str) -> Result<Load, String> {
let mut load = Load::new_empty();
if !std::path::Path::new(name).is_file() {
return Err(format!("File not found: '{}'", name));
}
load_entry(config, name, &mut load)?;
let res = check_attributes(config, &load.book).and_then(|_| load.book.adjust(config));
match res {
Ok(book) => {
load.book = book;
Ok(load)
}
Err(err) => Err(render_error(config, &load.file, err))
}
}

View File

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

View File

@ -0,0 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}

8
src/kind-cli/Cargo.toml Normal file
View File

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

14
src/kind-cli/src/lib.rs Normal file
View File

@ -0,0 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}

View File

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

View File

@ -0,0 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}

8
src/kind-lint/Cargo.toml Normal file
View File

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

14
src/kind-lint/src/lib.rs Normal file
View File

@ -0,0 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}

View File

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

View File

@ -0,0 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}

View File

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

View File

@ -0,0 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}

8
src/kind-pass/Cargo.toml Normal file
View File

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

14
src/kind-pass/src/lib.rs Normal file
View File

@ -0,0 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}

View File

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

14
src/kind-query/src/lib.rs Normal file
View File

@ -0,0 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}

View File

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

View File

@ -0,0 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}

8
src/kind-span/Cargo.toml Normal file
View File

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

126
src/kind-span/src/lib.rs Normal file
View File

@ -0,0 +1,126 @@
// Position in a syntax context.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)]
pub struct Pos(pub u32);
// A syntax context index.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)]
pub struct SyntaxCtxIndex(pub u32);
// A span in the encoded format that is required by
// kind2.
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)]
pub struct EncodedSpan(pub u64);
/// Describes a position in a source code (syntax context). It's useful
/// to generate error messages.
#[derive(Clone, Debug, Copy)]
pub struct Range {
pub start: Pos,
pub end: Pos,
pub ctx: SyntaxCtxIndex,
}
#[derive(Clone, Debug, Copy)]
pub enum Span {
Generated,
Locatable(Range),
}
pub trait Locatable {
fn locate(&self) -> Span;
fn set_location(&mut self, location: Span);
}
impl Range {
#[inline]
pub fn new(start: Pos, end: Pos, ctx: SyntaxCtxIndex) -> Range {
Range { start, end, ctx }
}
/// Joins two ranges. It keeps the syntax context
/// of the first one.
#[inline]
pub fn mix(&self, next: Range) -> Range {
Range {
start: self.start,
end: next.end,
ctx: self.ctx,
}
}
/// Sets the context of the range,
#[inline]
pub fn set_ctx(&self, ctx: SyntaxCtxIndex) -> Range {
Range {
start: self.start,
end: self.end,
ctx: ctx,
}
}
#[inline]
pub fn encode(&self) -> EncodedSpan {
EncodedSpan(((self.ctx.0 as u64) << 48) | ((self.start.0 as u64) & 0xFFFFFF) | (((self.end.0 as u64) & 0xFFFFFF) << 24))
}
}
impl Span {
#[inline]
pub fn new(range: Range) -> Span {
Span::Locatable(range)
}
#[inline]
pub fn generate() -> Span {
Span::Generated
}
/// Join two spans and keeps the syntax context of the
/// first locatable range. If it's generated then it
/// will be ignored and the other span will be the canonical
/// position.
pub fn mix(&self, other: Span) -> Span {
match (self, &other) {
(Span::Generated, e) | (e, Span::Generated) => *e,
(Span::Locatable(start), Span::Locatable(end)) => Span::Locatable(start.mix(*end)),
}
}
/// Set the syntax context of the span.
pub fn set_ctx(&mut self, ctx: SyntaxCtxIndex) {
match self {
Span::Generated => (),
Span::Locatable(span) => {
*span = span.set_ctx(ctx)
},
}
}
// Serialize the span into a single u64.
pub fn encode(&self) -> EncodedSpan {
match self {
Span::Generated => EncodedSpan(0),
Span::Locatable(data) => data.encode(),
}
}
}
impl EncodedSpan {
/// Transforms a encoded span back into a range.
pub fn to_range(&self) -> Range {
Range {
ctx: SyntaxCtxIndex((self.0 >> 48) as u32),
start: Pos((self.0 & 0xFFFFFF) as u32),
end: Pos(((self.0 >> 24) & 0xFFFFFF) as u32),
}
}
/// Transforms a encoded span back into a span.
pub fn to_span(&self) -> Span {
if self.0 == 0 {
Span::Generated
} else {
Span::Locatable(self.to_range())
}
}
}

View File

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

View File

@ -0,0 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}

View File

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

View File

@ -0,0 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}

9
src/kind-tree/Cargo.toml Normal file
View File

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

239
src/kind-tree/src/expr.rs Normal file
View File

@ -0,0 +1,239 @@
use crate::symbol::Ident;
use kind_span::{Locatable, Span};
use core::ascii;
use std::fmt::{Display, Error, Formatter};
/// Enum of binary operators.
#[derive(Copy, Clone, Debug)]
pub enum Operator {
Add,
Sub,
Mul,
Div,
Mod,
And,
Or,
Xor,
Shl,
Shr,
Ltn,
Lte,
Eql,
Gte,
Gtn,
Neq,
}
pub type Spine = Vec<Box<Expr>>;
/// A match block that will be translated
/// into an eliminator of a datatype.
#[derive(Clone, Debug)]
pub struct Match {
pub tipo: Ident,
pub name: Ident,
pub expr: Box<Expr>,
pub cases: Vec<(Ident, Box<Expr>)>,
pub motive: Box<Expr>,
}
/// A open statement that will be trnaslated
/// into the eliminator of a record datatype.
#[derive(Clone, Debug)]
pub struct Open {
pub tipo: Ident,
pub name: Ident,
pub expr: Box<Expr>,
pub body: Box<Expr>,
pub motive: Box<Expr>,
}
/// Substitution
#[derive(Clone, Debug)]
pub struct Substution {
pub name: Ident,
pub redx: u64,
pub indx: u64,
pub expr: Box<Expr>
}
#[derive(Clone, Debug)]
pub enum Literal {
/// The universe of types (e.g. Type)
Type,
/// The help operator that prints the context
/// and the goal (e.g. ?)
Help,
/// The type of 60 bits numberss (e.g. 2 : U60)
U60,
/// A number literal of 60 bits (e.g 32132)
Number(u64),
// A String literal
String(String)
}
#[derive(Clone, Debug)]
pub enum ExprKind {
/// Name of a variable
Var(Ident),
/// The dependent function space (e.g. (x : Int) -> y)
All(Option<Ident>, Box<Expr>, Box<Expr>),
/// A anonymous function that receives one argument
Lambda(Ident, Box<Expr>),
/// Application of a expression to a spine of expressions
App(Box<Expr>, Spine),
/// Declaration of a local variable
Let(Ident, Box<Expr>, Box<Expr>),
/// Type ascription (x : y)
Ann(Box<Expr>, Box<Expr>),
/// A constructor application
Ctr(Ident, Spine),
/// A function application
Fun(Ident, Spine),
/// Literal
Lit(Literal),
/// Binary operation (e.g. 2 + 3)
Binary(Operator, Box<Expr>, Box<Expr>),
/// A expression open to unification (e.g. _)
Hole(u64),
/// Substituion
Subst(Substution),
/// A match block that will be translated
/// into an eliminator of a datatype.
Match(Match),
/// A open statement that will be trnaslated
/// into the eliminator of a record datatype.
Open(Open),
}
#[derive(Clone, Debug)]
pub struct Expr {
pub data: ExprKind,
pub span: Span,
}
impl Locatable for Expr {
fn locate(&self) -> Span {
self.span
}
fn set_location(&mut self, location: Span) {
self.span = location;
}
}
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 Expr {
pub fn new_var(name: Ident) -> Expr {
Expr {
span: Span::Generated,
data: ExprKind::Var(name)
}
}
pub fn traverse_pi_types<'a>(&'a self) -> String {
match &self.data {
ExprKind::All(binder, typ, body) => {
match binder {
None => format!("{} -> {}", typ, body.traverse_pi_types()),
Some(binder) => format!("({} : {}) -> {}", binder, typ, body.traverse_pi_types()),
}
}
_ => format!("{}", self)
}
}
pub fn interpret_as_string(&self) -> Option<String> {
let mut text = String::new();
let mut term = &self.data;
let string_nil = Ident::new_path("String", "nil");
let string_cons = Ident::new_path("String", "cons");
loop {
if let ExprKind::Ctr (name, args) = term {
if name.data == string_cons.data && args.len() == 2 {
// TODO: Change it to support escaped chars.
if let ExprKind::Lit (Literal::Number(numb)) = args[0].data {
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].data;
continue;
}
} else {
return None;
}
} else if name.data == string_nil.data && args.is_empty() {
return Some(text);
}
}
return None;
}
}
}
impl Display for Literal {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
match self {
Literal::Help => write!(f, "?"),
Literal::Type => write!(f, "Type"),
Literal::U60 => write!(f, "U60"),
Literal::Number(numb) => write!(f, "{}", numb),
Literal::String(str) => write!(f, "\"{}\"", str),
}
}
}
impl Display for Expr {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
if let Some(str) = self.interpret_as_string() {
write!(f, "\"{}\"", str)
} else {
use ExprKind::*;
match &self.data {
All(_, __, _) => write!(f, "({}", self.traverse_pi_types()),
Lit(lit) => write!(f, "{}", lit),
Var(name) => write!(f, "{}", name),
Lambda(binder, body) => write!(f, "({} => {})", binder, body),
App(head, spine) => write!(f, "({}{})", head, spine.iter().map(|x| format!(" {}", x)).collect::<String>()),
Let(name, expr, body) => write!(f, "(let {} = {}; {})", name, expr, body),
Ann(expr, typ) => write!(f, "({} : {})", expr, typ),
Ctr(head, spine) => write!(f, "({}{})", head, spine.iter().map(|x| format!(" {}", x)).collect::<String>()),
Fun(head, spine) => write!(f, "({}{})", head, spine.iter().map(|x| format!(" {}", x)).collect::<String>()),
Binary(op, expr, typ) => write!(f, "({} {} {})", op, expr, typ),
Subst(Substution { name, redx, expr, .. }) => write!(f, "({} ## {}/{})", expr, name, redx),
Hole(_) => todo!(),
Match(_) => todo!(),
Open(_) => todo!(),
}
}
}
}

144
src/kind-tree/src/lib.rs Normal file
View File

@ -0,0 +1,144 @@
use std::{collections::HashMap, fmt::{Formatter, Display, Error}};
use expr::Expr;
use kind_span::{Span, SyntaxCtxIndex};
use symbol::Ident;
use visitor::Visitor;
pub mod expr;
pub mod symbol;
pub mod visitor;
/// A value of a attribute
#[derive(Clone, Debug)]
pub enum AttributeStyle {
Ident(Ident),
String(String),
Number(Span, u64)
}
/// A attribute is a kind of declaration
/// that usually is on the top of a declaration
/// and can be attached to a function declaration
/// it express some compiler properties
#[derive(Clone, Debug)]
pub struct Attribute {
pub name: Ident,
pub value: Option<AttributeStyle>,
pub span: Span
}
/// An argument is a 'binding' of a name to a type
/// it has some other options like
/// eras: that express the erasure of this type when
/// compiled.
/// hide: that express a implicit argument (that will
/// be discovered through unification).
#[derive(Clone, Debug)]
pub struct Argument {
pub hidden: bool,
pub erased: bool,
pub name: Ident,
pub tipo: Box<Expr>,
pub span: Span,
}
/// A rule is a equation that in the left-hand-side
/// contains a list of patterns @pats@ and on the
/// right hand side a value.
#[derive(Clone, Debug)]
pub struct Rule {
pub name: Ident,
pub pats: Vec<Box<Expr>>,
pub body: Box<Expr>,
pub span: Span,
}
/// An entry describes a function that is typed
/// and has rules. The type of the function
/// consists of the arguments @args@ and the
/// return type @tipo@.
#[derive(Clone, Debug)]
pub struct Entry {
pub name: Ident,
pub args: Vec<Box<Argument>>,
pub tipo: Box<Expr>,
pub rules: Vec<Box<Rule>>,
pub attrs: Vec<Attribute>,
pub span: Span,
}
// A book is a collection of entries.
#[derive(Clone, Debug, Default)]
pub struct Book {
pub names: Vec<Ident>,
pub entrs: HashMap<String, Box<Entry>>,
pub holes: u64,
}
// Set the syntax context of a file
struct SetCtxFileVisitor(SyntaxCtxIndex);
impl Visitor for SetCtxFileVisitor {
fn visit_span(&mut self, span: &mut Span) {
span.set_ctx(self.0)
}
}
impl Book {
pub fn set_ctx_file(&mut self, ctx: SyntaxCtxIndex) {
SetCtxFileVisitor(ctx).visit_book(self)
}
}
impl Display for Book {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
for name in &self.names {
writeln!(f, "{}\n", self.entrs.get(&name.data.0).unwrap())?;
}
Ok(())
}
}
// Display
impl Display for Argument {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
let (open, close) = match (self.erased, self.hidden) {
(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> {
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 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)
}
}

View File

@ -0,0 +1,50 @@
use std::fmt::Display;
use kind_span::{SyntaxCtxIndex, Span};
// Stores the name of a variable or constructor
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Symbol(pub String);
// Identifier inside a syntax context.
#[derive(Clone, Debug)]
pub struct Ident {
pub data: Symbol,
pub ctx: SyntaxCtxIndex,
pub span: Span,
}
impl Ident {
pub fn new(data: Symbol, ctx: SyntaxCtxIndex, span: Span) -> Ident {
Ident {
data,
ctx,
span,
}
}
pub fn new_path(data: &str, id: &str) -> Ident {
Ident {
data: Symbol(format!("{}.{}", data, id)),
ctx: SyntaxCtxIndex(0),
span: Span::Generated,
}
}
/// Changes the syntax context of the span and of the ident
pub fn set_ctx(&self, ctx: SyntaxCtxIndex) -> Ident {
let mut span = self.span.clone();
span.set_ctx(ctx);
Ident {
data: self.data.clone(),
ctx,
span
}
}
}
impl Display for Ident {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.data.0)
}
}

View File

@ -0,0 +1,160 @@
use kind_span::Span;
use crate::expr::{ExprKind, Literal, Open, Substution, Match};
use crate::symbol::*;
use crate::*;
/// A visitor trait following the visitor pattern
/// because it's easier to walk the entire tree
/// just by some nodes without writing some functions
/// to walk through everything (yeah i really hate
/// OOP patterns but this time it's really useful.)
///
/// All of these functions are implemented so we can easily
/// change these default implementations.
pub trait Visitor {
fn visit_span(&mut self, _: &mut Span) { }
fn visit_syntax_ctx(&mut self, _: &mut SyntaxCtxIndex) { }
fn visit_operator(&mut self, _: &mut expr::Operator) { }
fn visit_literal(&mut self, _: &mut Literal) { }
fn visit_ident(&mut self, ident: &mut Ident) {
self.visit_span(&mut ident.span);
self.visit_syntax_ctx(&mut ident.ctx);
}
fn visit_open(&mut self, open: &mut Open) {
self.visit_expr(&mut open.body);
self.visit_expr(&mut open.expr);
self.visit_expr(&mut open.motive);
self.visit_ident(&mut open.tipo);
self.visit_ident(&mut open.name);
}
fn visit_match(&mut self, matcher: &mut Match) {
self.visit_expr(&mut matcher.expr);
self.visit_expr(&mut matcher.motive);
self.visit_ident(&mut matcher.tipo);
self.visit_ident(&mut matcher.name);
for (name, body) in &mut matcher.cases {
self.visit_expr(body);
self.visit_ident(name);
}
}
fn visit_argument(&mut self, argument: &mut Argument) {
self.visit_ident(&mut argument.name);
self.visit_expr(&mut argument.tipo);
self.visit_span(&mut argument.span);
}
fn visit_entry(&mut self, entry: &mut Entry) {
self.visit_ident(&mut entry.name);
for arg in &mut entry.args {
self.visit_argument(arg)
}
self.visit_expr(&mut entry.tipo);
for rule in &mut entry.rules {
self.visit_rule(rule)
}
for attr in &mut entry.attrs {
self.visit_attr(attr);
}
self.visit_span(&mut entry.span);
}
fn visit_attr(&mut self, attr: &mut Attribute) {
self.visit_ident(&mut attr.name);
self.visit_span(&mut attr.span);
// TODO: Visit inner side of the attribute
}
fn visit_rule(&mut self, rule: &mut Rule) {
self.visit_ident(&mut rule.name);
for pat in &mut rule.pats {
self.visit_expr(pat);
}
self.visit_expr(&mut rule.body);
self.visit_span(&mut rule.span);
}
fn visit_book(&mut self, book: &mut Book) {
for entr in book.entrs.values_mut() {
self.visit_entry(entr);
}
}
fn visit_substitution(&mut self, subst: &mut Substution) {
self.visit_expr(&mut subst.expr);
self.visit_ident(&mut subst.name);
}
fn visit_expr(&mut self, expr: &mut Expr) {
self.visit_span(&mut expr.span);
match &mut expr.data {
ExprKind::Var(ident) => self.visit_ident(ident),
ExprKind::All(None, typ, body) => {
self.visit_expr(typ);
self.visit_expr(body);
},
ExprKind::All(Some(ident), typ, body) => {
self.visit_ident(ident);
self.visit_expr(typ);
self.visit_expr(body);
},
ExprKind::Lambda(ident, body) => {
self.visit_ident(ident);
self.visit_expr(body);
},
ExprKind::App(expr, spine) => {
self.visit_expr(expr);
for arg in spine {
self.visit_expr(arg);
}
},
ExprKind::Let(ident, val, body) => {
self.visit_ident(ident);
self.visit_expr(val);
self.visit_expr(body);
},
ExprKind::Ann(val, ty) => {
self.visit_expr(val);
self.visit_expr(ty);
},
ExprKind::Ctr(ident, spine) => {
self.visit_ident(ident);
for arg in spine {
self.visit_expr(arg);
}
},
ExprKind::Fun(ident, spine) => {
self.visit_ident(ident);
for arg in spine {
self.visit_expr(arg);
}
},
ExprKind::Lit(lit) => {
self.visit_literal(lit);
},
ExprKind::Binary(op, a, b) => {
self.visit_operator(op);
self.visit_expr(a);
self.visit_expr(b);
},
ExprKind::Hole(_) => { },
ExprKind::Subst(subst) => {
self.visit_substitution(subst)
},
ExprKind::Match(matcher) => {
self.visit_match(matcher)
},
ExprKind::Open(open) => {
self.visit_open(open)
},
}
}
}

View File

@ -1,7 +0,0 @@
pub mod book;
pub mod checker;
pub mod codegen;
pub mod derive;
pub mod driver;
pub mod lowering;
pub mod parser;

View File

@ -1,214 +0,0 @@
pub mod resolve;
pub mod adjust;
pub mod load;
pub mod attributes;
use crate::book::name::Ident;
use crate::book::new_type::{NewType, SumType, ProdType};
use crate::book::term::Term;
use crate::book::{Argument, Book, Entry, Rule};
use crate::driver::config::Config;
use crate::lowering::load::load_newtype_cached;
use std::collections::{HashMap, HashSet};
use std::rc::Rc;
// The state that adjusts uses and update a term, book, rule or entry.
pub struct UnboundState<'a> {
// All the vars that are bound in the context.
vars: Vec<Ident>,
// TODO: Describe
unbound: HashSet<Ident>,
// Definitions of types that are useful to the
// "match" expression.
types: HashMap<Ident, Rc<NewType>>,
config: &'a Config,
}
impl<'a> UnboundState<'a> {
pub fn new(types: HashMap<Ident, Rc<NewType>>, config: &'a Config) -> UnboundState<'a> {
UnboundState {
vars: Vec::new(),
unbound: HashSet::new(),
types,
config,
}
}
}
pub trait Unbound {
fn fill_unbound(&self, rhs: bool, state: &mut UnboundState);
fn get_unbounds(&self, types: HashMap<Ident, Rc<NewType>>, config: &Config) -> HashSet<Ident> {
let mut state = UnboundState::new(types, config);
self.fill_unbound(false, &mut state);
state.unbound
}
}
impl Unbound for Term {
fn fill_unbound<'a>(&self, rhs: bool, state: &mut UnboundState) {
match self {
Term::Typ { .. } => {}
Term::Var { ref name, .. } => {
// Is constructor name
if ('A'..='Z').contains(&name.0.chars().next().unwrap_or(' ')) {
state.unbound.insert(name.clone());
// Is unbound variable
} else if !state.vars.iter().any(|x| x == name) {
if rhs {
state.unbound.insert(name.clone());
} else {
state.vars.push(name.clone());
}
}
}
Term::Let { ref name, ref expr, ref body, .. } => {
expr.fill_unbound(rhs, state);
state.vars.push(name.clone());
body.fill_unbound(rhs, state);
state.vars.pop();
}
Term::Ann { ref expr, ref tipo, .. } => {
expr.fill_unbound(rhs, state);
tipo.fill_unbound(rhs, state);
}
Term::Sub { name: _, ref expr, .. } => {
expr.fill_unbound(rhs, state);
}
Term::All { ref name, ref tipo, ref body, .. } => {
tipo.fill_unbound(rhs, state);
state.vars.push(name.clone());
body.fill_unbound(rhs, state);
state.vars.pop();
}
Term::Lam { ref name, ref body, .. } => {
state.vars.push(name.clone());
body.fill_unbound(rhs, state);
state.vars.pop();
}
Term::App { ref func, ref argm, .. } => {
func.fill_unbound(rhs, state);
argm.fill_unbound(rhs, state);
}
// not reached normally
Term::Ctr { ref name, ref args, .. } => {
state.unbound.insert(Ident(name.to_string()));
for arg in args {
arg.fill_unbound(rhs, state);
}
}
// not reached normally
Term::Fun { ref name, ref args, .. } => {
state.unbound.insert(Ident(name.to_string()));
for arg in args {
arg.fill_unbound(rhs, state);
}
}
Term::Op2 { ref val0, ref val1, .. } => {
val0.fill_unbound(rhs, state);
val1.fill_unbound(rhs, state);
}
Term::Hlp { .. } => {}
Term::U60 { .. } => {}
Term::Num { .. } => {}
Term::Hol { .. } => {}
Term::Mat {
ref tipo,
ref name,
ref expr,
ref cses,
ref moti,
..
} => {
//println!("finding unbounds of match {} {}", tipo, name);
if let Ok(newtype) = load_newtype_cached(state.config, &mut state.types, tipo) {
state.unbound.insert(Ident(format!("{}.match", tipo.clone())));
// Expr
expr.fill_unbound(rhs, state);
// Motive
state.vars.push(name.clone());
moti.fill_unbound(rhs, state);
state.vars.pop();
// Cases
if let NewType::Sum(SumType { name: _, ctrs, pars: _ }) = &*newtype {
for ctr in ctrs {
if let Some(cse) = cses.iter().find(|x| x.0 == ctr.name) {
for arg in ctr.args.iter().rev() {
state.vars.push(arg.name.clone());
}
cse.1.fill_unbound(rhs, state);
for _ in ctr.args.iter().rev() {
state.vars.pop();
}
}
}
}
}
},
Term::Open { orig: _, tipo, name, expr, moti, body } => {
if let Ok(newtype) = load_newtype_cached(state.config, &mut state.types, tipo) {
state.unbound.insert(Ident(format!("{}.match", tipo.clone())));
expr.fill_unbound(rhs, state);
state.vars.push(name.clone());
moti.fill_unbound(rhs, state);
state.vars.pop();
if let NewType::Prod(ProdType { name: _, fields, .. }) = &*newtype {
for arg in fields.iter().rev() {
state.vars.push(arg.name.clone());
}
body.fill_unbound(rhs, state);
for _ in fields.iter().rev() {
state.vars.pop();
}
}
}
}
}
}
}
impl Unbound for Rule {
fn fill_unbound<'a>(&self, _rhs: bool, state: &mut UnboundState) {
for pat in &self.pats {
pat.fill_unbound(false, state);
}
self.body.fill_unbound(true, state);
}
}
impl Unbound for Entry {
fn fill_unbound<'a>(&self, _rhs: bool, state: &mut UnboundState) {
state.vars = Vec::new();
for arg in &self.args {
arg.fill_unbound(true, state);
state.vars.push(arg.name.clone());
}
self.tipo.fill_unbound(true, state);
for rule in &self.rules {
state.vars = Vec::new();
rule.fill_unbound(true, state);
}
}
}
impl Unbound for Argument {
fn fill_unbound<'a>(&self, _rhs: bool, state: &mut UnboundState) {
self.tipo.fill_unbound(true, state);
}
}
impl Book {
pub fn get_unbounds(&self, config: &Config) -> HashSet<Ident> {
let mut state = UnboundState::new(HashMap::new(), config);
for name in &self.names {
let entry = self.entrs.get(&Ident(name.clone())).unwrap();
entry.fill_unbound(false, &mut state);
}
state.unbound
}
}

View File

@ -1,572 +0,0 @@
use crate::book::name::Ident;
use crate::book::new_type::NewType;
use crate::book::span::{Localized, Span};
use crate::book::term::Term;
use crate::book::{Argument, Book, Entry, Rule};
use crate::driver::config::{Config, Target};
use crate::lowering::load::load_newtype_cached;
use std::collections::HashMap;
use std::rc::Rc;
#[derive(Clone, Debug)]
pub struct AdjustError {
pub orig: Span,
pub kind: AdjustErrorKind,
}
#[derive(Clone, Debug)]
pub enum AdjustErrorKind {
IncorrectArity,
UnboundVariable { name: String },
CannotFindAlias { name: String },
InvalidAttribute { name: String },
AttributeWithoutArgs { name: String },
AttributeMissingArg { name: String },
WrongTargetAttribute { name: String, target: Target },
UseOpenInstead,
UseMatchInstead,
RepeatedVariable,
CantLoadType,
NoCoverage,
}
// The state that adjusts uses and update a term, book, rule or entry.
pub struct AdjustState<'a> {
// The book that we are adjusting now.
book: &'a Book,
// TODO:
eras: u64,
// How much holes we created
holes: u64,
// All the vars that are bound in the context.
vars: Vec<Ident>,
// Definitions of types that are useful to the
// "match" expression.
types: HashMap<Ident, Rc<NewType>>,
// Configuration provided by the user. It's useful
// to load paths correctly.
config: &'a Config,
}
impl<'a> AdjustState<'a> {
pub fn new(book: &'a Book, config: &'a Config) -> AdjustState<'a> {
AdjustState {
book,
eras: 0,
holes: 0,
vars: Vec::new(),
types: HashMap::new(),
config,
}
}
}
pub trait Adjust {
fn adjust<'a>(&self, rhs: bool, state: &mut AdjustState<'a>) -> Result<Self, AdjustError>
where
Self: Sized;
fn adjust_with_book(&self, book: &Book, config: &Config) -> Result<Self, AdjustError>
where
Self: Sized,
{
self.adjust(
false,
&mut AdjustState {
book,
eras: 0,
holes: 0,
vars: Vec::new(),
types: HashMap::new(),
config,
},
)
}
}
fn convert_apps_to_ctr(term: &Term) -> Option<Term> {
let mut term = term;
let ctr_name;
let mut ctr_orig = term.get_origin();
let mut ctr_args = vec![];
loop {
match term {
Term::App { ref orig, ref func, ref argm } => {
ctr_args.push(argm);
if ctr_orig == Span::Generated {
ctr_orig = *orig;
}
term = func;
}
Term::Var { ref name, .. } => {
if !name.0.chars().next().unwrap_or(' ').is_uppercase() {
return None;
} else {
ctr_name = name.clone();
break;
}
}
_ => {
return None;
}
}
}
if ctr_name.to_string() == "Type" {
Some(Term::Typ { orig: ctr_orig })
} else if ctr_name.0 == "U60" {
Some(Term::U60 { orig: ctr_orig })
} else {
Some(Term::Ctr {
orig: ctr_orig,
name: ctr_name,
args: ctr_args.iter().rev().map(|x| (*x).clone()).collect(),
})
}
}
impl Adjust for Term {
fn adjust<'a>(&self, rhs: bool, state: &mut AdjustState<'a>) -> Result<Self, AdjustError> {
if let Some(new_term) = convert_apps_to_ctr(self) {
return new_term.adjust(rhs, state);
}
match *self {
Term::Typ { orig } => Ok(Term::Typ { orig }),
Term::Var { ref orig, ref name } => {
let orig = *orig;
if rhs && !state.vars.iter().any(|x| x == name) {
return Err(AdjustError {
orig,
kind: AdjustErrorKind::UnboundVariable { name: name.to_string() },
});
} else if !rhs && state.vars.iter().any(|x| x == name) {
return Err(AdjustError {
orig,
kind: AdjustErrorKind::RepeatedVariable,
});
} else if !rhs {
state.vars.push(name.clone());
}
Ok(Term::Var { orig, name: name.clone() })
}
Term::Let {
ref orig,
ref name,
ref expr,
ref body,
} => {
let orig = *orig;
let expr = Box::new(expr.adjust(rhs, state)?);
state.vars.push(name.clone());
let body = Box::new(body.adjust(rhs, state)?);
state.vars.pop();
Ok(Term::Let {
orig,
name: name.clone(),
expr,
body,
})
}
Term::Ann { ref orig, ref expr, ref tipo } => {
let orig = *orig;
let expr = Box::new(expr.adjust(rhs, state)?);
let tipo = Box::new(tipo.adjust(rhs, state)?);
Ok(Term::Ann { orig, expr, tipo })
}
Term::Sub {
ref orig,
ref name,
indx: _,
ref redx,
ref expr,
} => {
let orig = *orig;
let expr = Box::new(expr.adjust(rhs, state)?);
match state.vars.iter().position(|x| x == name) {
None => Err(AdjustError {
orig,
kind: AdjustErrorKind::UnboundVariable { name: name.to_string() },
}),
Some(indx) => {
let name = name.clone();
let indx = indx as u64;
let redx = *redx;
Ok(Term::Sub { orig, name, indx, redx, expr })
}
}
}
Term::All {
ref orig,
ref name,
ref tipo,
ref body,
} => {
let orig = *orig;
let tipo = Box::new(tipo.adjust(rhs, state)?);
state.vars.push(name.clone());
let body = Box::new(body.adjust(rhs, state)?);
state.vars.pop();
Ok(Term::All {
orig,
name: name.clone(),
tipo,
body,
})
}
Term::Lam { ref orig, ref name, ref body } => {
let orig = *orig;
state.vars.push(name.clone());
let body = Box::new(body.adjust(rhs, state)?);
state.vars.pop();
Ok(Term::Lam { orig, name: name.clone(), body })
}
Term::App { ref orig, ref func, ref argm } => {
let orig = *orig;
let func = Box::new(func.adjust(rhs, state)?);
let argm = Box::new(argm.adjust(rhs, state)?);
Ok(Term::App { orig, func, argm })
}
Term::Ctr { ref orig, ref name, ref args } => {
let orig = *orig;
if let Some(entry) = state.book.entrs.get(name) {
let mut new_args = Vec::new();
for arg in args {
// On lhs, switch holes for vars
if let (false, Term::Hol { orig, numb: _ }) = (rhs, &**arg) {
let name = format!("x{}_", state.eras);
state.eras += 1;
let arg = Box::new(Term::Var { orig: *orig, name: Ident(name) });
new_args.push(Box::new(arg.adjust(rhs, state)?));
} else {
new_args.push(Box::new(arg.adjust(rhs, state)?));
}
}
let (hiddens, eraseds) = entry.count_implicits();
// Fill implicit arguments (on rhs)
if rhs && args.len() == entry.args.len() - hiddens {
new_args.reverse();
let mut aux_args = Vec::new();
for arg in &entry.args {
if arg.hide {
let numb = state.holes;
state.holes += 1;
aux_args.push(Box::new(Term::Hol { orig, numb }));
} else {
aux_args.push(new_args.pop().unwrap());
}
}
new_args = aux_args;
}
// Fill erased arguments (on lhs)
if !rhs && args.len() == entry.args.len() - eraseds {
new_args.reverse();
let mut aux_args = Vec::new();
for arg in &entry.args {
if arg.eras {
let name = format!("{}{}_", arg.name, state.eras);
state.eras += 1;
let arg = Term::Var { orig, name: Ident(name) };
aux_args.push(Box::new(arg.adjust(rhs, state)?));
} else {
aux_args.push(new_args.pop().unwrap());
}
}
new_args = aux_args;
}
if new_args.len() != entry.args.len() {
Err(AdjustError {
orig,
kind: AdjustErrorKind::IncorrectArity,
})
} else if !entry.rules.is_empty() {
Ok(Term::Fun {
orig,
name: name.clone(),
args: new_args,
})
} else {
Ok(Term::Ctr {
orig,
name: name.clone(),
args: new_args,
})
}
} else {
Err(AdjustError {
orig,
kind: AdjustErrorKind::UnboundVariable { name: name.to_string() },
})
}
}
Term::Fun { .. } => {
panic!("Internal error."); // shouldn't happen since we can't parse Fun{}
}
Term::Hol { ref orig, numb: _ } => {
let orig = *orig;
let numb = state.holes;
state.holes += 1;
Ok(Term::Hol { orig, numb })
}
Term::Hlp { ref orig } => {
let orig = *orig;
Ok(Term::Hlp { orig })
}
Term::U60 { ref orig } => {
let orig = *orig;
Ok(Term::U60 { orig })
}
Term::Num { ref orig, ref numb } => {
let orig = *orig;
let numb = *numb;
Ok(Term::Num { orig, numb })
}
Term::Op2 {
ref orig,
ref oper,
ref val0,
ref val1,
} => {
let orig = *orig;
let oper = *oper;
let val0 = Box::new(val0.adjust(rhs, state)?);
let val1 = Box::new(val1.adjust(rhs, state)?);
Ok(Term::Op2 { orig, oper, val0, val1 })
}
Term::Mat {
ref orig,
ref name,
ref tipo,
ref expr,
ref cses,
ref moti,
} => {
let orig = *orig;
if let Ok(res) = load_newtype_cached(state.config, &mut state.types, tipo) {
match &*res {
NewType::Sum(newtype) => {
let mut args = vec![];
args.push(expr.clone());
args.push(Box::new(Term::Lam {
orig: moti.get_origin(),
name: name.clone(),
body: moti.clone(),
}));
if newtype.ctrs.len() != cses.len() {
return Err(AdjustError {
orig,
kind: AdjustErrorKind::NoCoverage,
});
}
for ctr in &newtype.ctrs {
if let Some(cse) = cses.iter().find(|x| x.0 == ctr.name) {
let mut case_term = cse.1.clone();
for arg in ctr.args.iter().rev() {
case_term = Box::new(Term::Lam {
orig: case_term.get_origin(),
name: Ident(format!("{}.{}", name, arg.name)),
body: case_term,
});
}
args.push(case_term);
} else {
return Err(AdjustError {
orig,
kind: AdjustErrorKind::NoCoverage,
});
}
}
let result = Term::Ctr {
orig,
name: Ident::new_path(&tipo.to_string(), "match"),
args,
};
result.adjust(rhs, state)
}
_ => Err(AdjustError {
orig,
kind: AdjustErrorKind::UseOpenInstead,
}),
}
} else {
Err(AdjustError {
orig,
kind: AdjustErrorKind::CantLoadType,
})
}
}
Term::Open {
ref orig,
ref name,
ref tipo,
ref expr,
ref body,
ref moti,
} => {
let orig = *orig;
if let Ok(res) = load_newtype_cached(state.config, &mut state.types, tipo) {
match &*res {
NewType::Prod(prod) => {
let mut args = vec![];
args.push(expr.clone());
args.push(Box::new(Term::Lam {
orig: moti.get_origin(),
name: name.clone(),
body: moti.clone(),
}));
let mut case_term = body.clone();
for arg in prod.fields.iter().rev() {
case_term = Box::new(Term::Lam {
orig: case_term.get_origin(),
name: Ident(format!("{}.{}", name, arg.name)),
body: case_term,
});
}
args.push(case_term);
let result = Term::Ctr {
orig,
name: Ident::new_path(&tipo.to_string(), "match"),
args,
};
result.adjust(rhs, state)
}
_ => Err(AdjustError {
orig,
kind: AdjustErrorKind::UseMatchInstead,
}),
}
} else {
Err(AdjustError {
orig,
kind: AdjustErrorKind::CantLoadType,
})
}
}
}
}
}
impl Adjust for Rule {
fn adjust<'a>(&self, _rhs: bool, state: &mut AdjustState<'a>) -> Result<Self, AdjustError> {
let name = self.name.clone();
let orig = self.orig;
// shouldn't panic, because we only parse rules after the type annotation
let entry = state.book.entrs.get(&self.name).expect("Untyped rule.");
let mut pats = Vec::new();
for pat in &self.pats {
if let Term::Hol { orig, numb: _ } = &**pat {
// On lhs, switch holes for vars
// TODO: This duplicates of adjust_term because the lhs of a rule is not a term
let name = Ident(format!("x{}_", state.eras));
state.eras += 1;
let pat = Term::Var { orig: *orig, name };
pats.push(Box::new(pat.adjust(false, state)?));
} else {
pats.push(Box::new(pat.adjust(false, state)?));
}
}
// Fill erased arguments
let (_, eraseds) = entry.count_implicits();
if self.pats.len() == entry.args.len() - eraseds {
pats.reverse();
let mut aux_pats = Vec::new();
for arg in &entry.args {
if arg.eras {
let name = Ident(format!("{}{}_", arg.name, state.eras));
state.eras += 1;
let pat = Box::new(Term::Var { orig, name });
aux_pats.push(Box::new(pat.adjust(false, state)?));
} else {
aux_pats.push(pats.pop().unwrap());
}
}
pats = aux_pats;
}
if pats.len() != entry.args.len() {
return Err(AdjustError {
orig,
kind: AdjustErrorKind::IncorrectArity,
});
}
let body = Box::new(self.body.adjust(true, state)?);
Ok(Rule { orig, name, pats, body })
}
}
impl Adjust for Argument {
fn adjust<'a>(&self, _rhs: bool, state: &mut AdjustState<'a>) -> Result<Self, AdjustError> {
state.eras = 0;
let tipo = Box::new(self.tipo.adjust(true, state)?);
Ok(Argument {
orig: self.orig,
hide: self.hide,
eras: self.eras,
name: self.name.clone(),
tipo,
})
}
}
impl Adjust for Entry {
fn adjust<'a>(&self, rhs: bool, state: &mut AdjustState<'a>) -> Result<Self, AdjustError> {
let name = self.name.clone();
let mut args = Vec::new();
state.vars = Vec::new();
for arg in &self.args {
args.push(Box::new(arg.adjust(rhs, state)?));
state.vars.push(arg.name.clone());
}
state.eras = 0;
let tipo = Box::new(self.tipo.adjust(true, state)?);
let mut rules = Vec::new();
for rule in &self.rules {
state.vars = Vec::new();
rules.push(Box::new(rule.adjust(rhs, state)?));
}
Ok(Entry {
name,
orig: self.orig,
args,
tipo,
rules,
attrs: self.attrs.clone(),
})
}
}
impl Book {
pub fn adjust(&mut self, config: &Config) -> Result<Self, AdjustError> {
let mut names = Vec::new();
let mut entrs = HashMap::new();
let mut state = AdjustState::new(self, config);
for name in &self.names {
let ident = Ident(name.clone());
let entry = self.entrs.get(&ident).unwrap();
names.push(name.clone());
entrs.insert(ident, Box::new(entry.adjust(false, &mut state)?));
}
Ok(Book { names, entrs, holes: state.holes })
}
}

View File

@ -1,64 +0,0 @@
use crate::book::{span::Span, Attribute, Book, Entry};
use crate::driver::config::{Config, Target};
use super::adjust::{AdjustError, AdjustErrorKind};
// Helper functions.
pub fn adjust_err<T>(orig: Span, kind: AdjustErrorKind) -> Result<T, AdjustError> {
Err(AdjustError { orig, kind })
}
pub fn without_args(attr: &Attribute) -> Result<(), AdjustError> {
match &attr.value {
Some(_) => adjust_err(attr.orig, AdjustErrorKind::AttributeWithoutArgs { name: attr.name.0.clone() }),
None => Ok(()),
}
}
pub fn with_args(attr: &Attribute) -> Result<(), AdjustError> {
match &attr.value {
Some(_) => Ok(()),
None => adjust_err(attr.orig, AdjustErrorKind::AttributeMissingArg { name: attr.name.0.clone() }),
}
}
pub fn only_target(config: &Config, attr: &Attribute, target: Target) -> Result<(), AdjustError> {
if config.target == target || config.target == Target::All {
Ok(())
} else {
adjust_err(attr.orig, AdjustErrorKind::WrongTargetAttribute { name: attr.name.0.clone(), target })
}
}
// Main functions
// Attributes are just for compiler magic so
// they have no specification so we should check then.
pub fn check_attribute(config: &Config, attr: &Attribute) -> Result<(), AdjustError> {
match attr.name.0.as_str() {
"kdl_erase" => without_args(attr),
"kdl_run" => {
without_args(attr)?;
only_target(config, attr, Target::Kdl)
}
"kdl_name" => with_args(attr),
_ => adjust_err(attr.orig, AdjustErrorKind::InvalidAttribute { name: attr.name.0.clone() }),
}
}
// Just checks all the attributes before they're expanded
// in the other parts of the code.
pub fn check_entry_attributes(config: &Config, entry: &Entry) -> Result<(), AdjustError> {
for attr in &entry.attrs {
check_attribute(config, attr)?
}
Ok(())
}
pub fn check_attributes(config: &Config, book: &Book) -> Result<(), AdjustError> {
for entry in book.entrs.values() {
check_entry_attributes(config, entry)?;
}
Ok(())
}

View File

@ -1,38 +0,0 @@
use crate::book::name::Ident;
use crate::book::new_type::NewType;
use crate::driver::config::Config;
use crate::parser::new_type::read_newtype;
use std::collections::HashMap;
use std::path::Path;
use std::rc::Rc;
// TODO: Remove this from the adjust layer. I think that we need to move it
// to the driver.
fn load_newtype(config: &Config, name: &Ident) -> Result<Box<NewType>, String> {
let path = config.kind2_path.clone();
let root = Path::new(&path).join(name.to_string().replace('.', "/"));
let path = root.join("_.type");
let newcode = match std::fs::read_to_string(&path) {
Err(_) => {
return Err(format!("File not found: '{}'.", path.display()));
}
Ok(code) => code,
};
let newtype = match read_newtype(&newcode) {
Err(err) => {
return Err(format!("\x1b[1m[{}]\x1b[0m\n{}", path.display(), err));
}
Ok(book) => book,
};
Ok(newtype)
}
pub fn load_newtype_cached(config: &Config, cache: &mut HashMap<Ident, Rc<NewType>>, name: &Ident) -> Result<Rc<NewType>, String> {
if !cache.contains_key(name) {
let newtype = Rc::new(*load_newtype(config, name)?);
cache.insert(name.clone(), newtype);
}
return Ok(cache.get(name).unwrap().clone());
}

View File

@ -1,179 +0,0 @@
use std::collections::HashMap;
use crate::book::term::Term;
use crate::book::name::Ident;
use crate::book::span::Span;
use crate::book::{Rule, Entry, Book};
use super::adjust::AdjustError;
pub trait Resolve {
fn resolve(&mut self, current: &str, map: &HashMap<String, String>) -> Result<(), AdjustError>;
}
pub fn find_alias(orig: Span, path: &str, map: &HashMap<String, String>) -> Result<String, AdjustError> {
if let Some(path) = map.get(path) {
Ok(path.clone())
} else {
Err(AdjustError {
orig,
kind: super::adjust::AdjustErrorKind::CannotFindAlias { name: path.to_string() },
})
}
}
impl Ident {
fn resolve(&mut self, current: &str, orig: Span, map: &HashMap<String, String>) -> Result<(), AdjustError> {
if self.is_ctr() {
let mut iter = self.0.split("/");
let path = iter.next().unwrap();
match (path, iter.next()) {
("", Some(id)) => {
*self = if current == "" {
Ident(id.to_string())
} else {
Ident(format!("{}.{}", current, id).to_string())
};
}
(path, Some("")) => {
let alias = find_alias(orig, path, map)?;
*self = Ident(alias);
}
(path, Some(id)) => {
let alias = find_alias(orig, path, map)?;
*self = Ident(format!("{}.{}", alias, id).to_string());
}
_ => ()
}
}
Ok(())
}
}
// Todo: Put a better orig inside each ident
impl Resolve for Term {
fn resolve(&mut self, current: &str, map: &HashMap<String, String>) -> Result<(), AdjustError> {
match self {
Term::Num { .. } => Ok(()),
Term::Hol { .. } => Ok(()),
Term::Hlp { .. } => Ok(()),
Term::U60 { .. } => Ok(()),
Term::Typ { .. } => Ok(()),
Term::Var { name, orig } => name.resolve(current, *orig, map),
Term::Let { expr, body,.. } => {
body.resolve(current, map)?;
expr.resolve(current, map)
},
Term::Ann { expr, tipo, .. } => {
expr.resolve(current, map)?;
tipo.resolve(current, map)
},
Term::Sub { expr, .. } => {
// TODO: Not sure.
expr.resolve(current, map)
},
Term::All { tipo, body, .. } => {
body.resolve(current, map)?;
tipo.resolve(current, map)
},
Term::Lam { body, .. } => {
body.resolve(current, map)
},
Term::App { func, argm, .. } => {
func.resolve(current, map)?;
argm.resolve(current, map)
},
Term::Ctr { args, name, orig, .. } => {
name.resolve(current, *orig, map)?;
for arg in args {
arg.resolve(current, map)?;
}
Ok(())
},
Term::Fun { args, name, orig, .. } => {
name.resolve(current, *orig, map)?;
for arg in args {
arg.resolve(current, map)?;
}
Ok(())
},
Term::Op2 { val0, val1, .. } => {
val0.resolve(current, map)?;
val1.resolve(current, map)
},
Term::Mat {
tipo,
expr,
cses,
moti,
orig,
..
} => {
tipo.resolve(current, *orig, map)?;
moti.resolve(current, map)?;
expr.resolve(current, map)?;
for (_, arg) in cses {
arg.resolve(current, map)?;
}
Ok(())
},
Term::Open {
tipo,
expr,
body,
moti,
orig,
..
} => {
tipo.resolve(current, *orig, map)?;
moti.resolve(current, map)?;
body.resolve(current, map)?;
expr.resolve(current, map)
},
}
}
}
impl Resolve for Rule {
fn resolve(&mut self, current: &str, map: &HashMap<String, String>) -> Result<(), AdjustError> {
self.body.resolve(current, map)?;
self.name.resolve(current, self.orig, map)?;
for pat in self.pats.as_mut_slice() {
pat.resolve(current, map)?;
}
Ok(())
}
}
impl Resolve for Entry {
fn resolve(&mut self, current: &str, map: &HashMap<String, String>) -> Result<(), AdjustError> {
self.tipo.resolve(current, map)?;
self.name.resolve(current, self.orig, map)?;
for rule in self.rules.as_mut_slice() {
rule.resolve(current, map)?;
}
Ok(())
}
}
impl Resolve for Book {
fn resolve(&mut self, current: &str, map: &HashMap<String, String>) -> Result<(), AdjustError> {
let mut new_entrs = HashMap::new();
let mut new_names = Vec::new();
for (name, entr) in self.entrs.iter_mut() {
entr.resolve(current, map)?;
let mut new_name = name.clone();
new_name.resolve(current, entr.orig, map)?;
new_entrs.insert(new_name.clone(), entr.clone());
}
// Just to change the order of each name.
for name in &self.names {
let mut new_name = Ident(name.clone());
new_name.resolve(current, Span::Generated, map)?;
new_names.push(new_name.0);
}
self.entrs = new_entrs;
self.names = new_names;
Ok(())
}
}

View File

@ -1,99 +0,0 @@
pub mod book;
pub mod checker;
pub mod codegen;
pub mod derive;
pub mod driver;
pub mod lowering;
pub mod parser;
use std::env;
use crate::driver::config::{Config, Target};
use crate::driver::*;
use clap::{Parser, Subcommand};
#[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 = &["e"])]
Eval { file: String },
/// Runs Main on the HVM
#[clap(aliases = &["r"])]
Run { file: String },
/// Derives .kind2 files from a .type file
#[clap(aliases = &["der"])]
Derive { file: String },
/// Generates a checker (.hvm) for a file
#[clap(aliases = &["gc"])]
GenChecker { file: String },
/// Stringifies a file
#[clap(aliases = &["show"])]
Show { file: String },
/// Compiles a file to Kindelia (.kdl)
#[clap(aliases = &["kdl"])]
ToKDL {
file: String,
/// If given, a namespace that goes before each compiled name. Can be at most 10 charaters long.
#[clap(long, aliases = &["ns"])]
namespace: Option<String>,
},
/// Compiles a file to HVM (.hvm)
#[clap(aliases = &["hvm"])]
ToHVM { file: String },
}
fn run_cli() -> Result<(), String> {
let cli_matches = Cli::parse();
let mut config = Config {
no_high_line: false,
color_output: true,
kind2_path: env::var_os("KIND2_PATH").map(|x| x.into_string().unwrap()).unwrap_or_else(|| "".to_string()),
target: Target::All
};
match cli_matches.command {
Command::Eval { file: path } => cmd_eval_main(&config, &path),
Command::Run { file: path } => cmd_run_main(&config, &path),
Command::Check { file: path } => cmd_check_all(&config, &path),
Command::Derive { file: path } => cmd_derive(&config, &path),
Command::GenChecker { file: path } => cmd_gen_checker(&config, &path),
Command::Show { file: path } => cmd_show(&config, &path),
Command::ToKDL { file: path, namespace } => {
config.target = Target::Kdl;
cmd_to_kdl(&config, &path, &namespace)
},
Command::ToHVM { file: path } => {
config.target = Target::Hvm;
cmd_to_hvm(&config, &path)
}
}
}
fn main() {
match run_cli() {
Ok(..) => {}
Err(err) => {
eprintln!("{}", err);
}
};
}

View File

@ -1,226 +0,0 @@
pub mod new_type;
pub mod term;
pub mod utils;
pub mod name;
use crate::book::name::Ident;
use crate::book::span::{ByteOffset, Span};
use crate::book::term::Term;
use crate::book::{Argument, Attribute, Book, Entry, Rule};
use crate::parser::term::{parse_apps, parse_term};
use crate::parser::utils::{get_init_index, get_last_index};
use hvm::parser;
use std::collections::HashMap;
use self::name::parse_path_str;
pub fn parse_use<'a>(state: parser::State<'a>, map: &mut HashMap<String, String>) -> Result<parser::State<'a>, String> {
let (state, val) = parser::name1(state)?;
let (state, _) = parser::consume("as", state)?;
let (state, name) = parser::name1(state)?;
map.insert(name, val);
Ok(state)
}
pub fn parse_uses<'a>(state: parser::State<'a>, map: &mut HashMap<String, String>) -> Result<parser::State<'a>, String> {
let mut vec = Vec::new();
let mut state = state;
loop {
let (state_i, attr) = parser::text("use ", state)?;
if attr {
let state_i = parse_use(state_i, map)?;
vec.push(attr);
state = state_i;
} else {
return Ok(state);
}
}
}
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)?;
Ok((
state,
Box::new(Rule {
orig,
name: Ident(name),
pats,
body,
}),
))
}
pub fn parse_attr(state: parser::State) -> parser::Answer<Attribute> {
let (state, init) = get_init_index(state)?;
let (state, name) = parser::name1(state)?;
let (state, has_value) = parser::text("=", state)?;
let (state, value) = if has_value {
let (state, name) = parser::name1(state)?;
(state, Some(Ident(name)))
} else {
(state, None)
};
let (state, last) = get_last_index(state)?;
let orig = Span::new_off(init, last);
Ok((state, Attribute { name: Ident(name), value, orig }))
}
pub fn parse_attrs(state: parser::State) -> parser::Answer<Vec<Attribute>> {
let mut vec = Vec::new();
let mut state = state;
loop {
let (state_i, attr) = parser::text("#", state)?;
if attr {
let (state_i, attr) = parse_attr(state_i)?;
vec.push(attr);
state = state_i;
} else {
return Ok((state, vec));
}
}
}
pub fn parse_entry(state: parser::State) -> parser::Answer<Box<Entry>> {
let (state, attrs) = parse_attrs(state)?;
let (state, init) = get_init_index(state)?;
let (state, name) = parse_path_str(state)?;
let (state, last) = get_last_index(state)?;
let name_orig = Span::new_off(init, last);
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)?;
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: arg.orig,
name: arg.name.clone(),
}));
// TODO: set orig
}
let rules = vec![Box::new(Rule {
orig: name_orig,
name: Ident(name.clone()),
pats,
body,
})];
Ok((
state,
Box::new(Entry {
name: Ident(name),
args,
tipo,
rules,
orig: name_orig,
attrs,
}),
))
} 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: Ident(name),
args,
tipo,
rules,
orig: name_orig,
attrs,
});
Ok((state, entry))
}
}
pub fn parse_argument(state: parser::State) -> parser::Answer<Box<Argument>> {
let (state, init) = get_init_index(state)?;
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, last) = get_last_index(state)?;
let (state, anno) = parser::text(":", state)?;
let (state, tipo) = if anno {
parse_apps(state)?
} else {
(state, Box::new(Term::Typ { orig: Span::new_off(init, last) }))
};
let (state, _) = parser::consume(close, state)?;
let hide = open == "<";
let eras = if hide { !keep } else { eras };
let (state, last) = get_last_index(state)?;
let orig = Span::new_off(init, last);
Ok((
state,
Box::new(Argument {
hide,
orig,
eras,
name: Ident(name),
tipo,
}),
))
}
pub fn parse_book(state: parser::State) -> parser::Answer<(Box<Book>, HashMap<String, String>)> {
let mut map = HashMap::new();
let state = parse_uses(state, &mut map)?;
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);
}
}
Ok((state, (Box::new(Book { holes: 0, names, entrs }), map)))
}
pub fn read_book(code: &str) -> Result<(Box<Book>, HashMap<String, String>), String> {
parser::read(Box::new(parse_book), code)
}

View File

@ -1,41 +0,0 @@
use hvm::parser;
fn is_letter(chr: char) -> bool {
chr.is_ascii_alphanumeric() || chr == '_' || chr == '.' || chr == '$'
}
/// Parses a name right after the parsing cursor.
fn name_here(state: parser::State) -> parser::Answer<String> {
let mut name: String = String::new();
let mut state = state;
let mut already_seen_slash = false;
while let Some(got) = parser::head(state) {
if is_letter(got) || (got == '/' && !already_seen_slash) {
if got == '/' {
already_seen_slash = true;
}
name.push(got);
state = parser::tail(state);
} else {
if got == '/' {
return parser::expected("name", 1, state);
}
break;
}
}
Ok((state, name))
}
/// Parses a name after skipping comments and whitespace.
fn name(state: parser::State) -> parser::Answer<String> {
let (state, _) = parser::skip(state)?;
name_here(state)
}
pub fn parse_path_str(state: parser::State) -> parser::Answer<String> {
let (state, name1) = name(state)?;
if !name1.is_empty() || name1 == "/" {
Ok((state, name1))
} else {
parser::expected("name", 1, state)
}
}

View File

@ -1,98 +0,0 @@
use crate::book::name::Ident;
use crate::book::new_type::{Constructor, NewType, ProdType, SumType};
use crate::parser::*;
pub fn parse_sum_type(state: parser::State) -> parser::Answer<Option<Box<NewType>>> {
parser::guard(
parser::text_parser("type "),
Box::new(|state| {
let (state, _) = parser::consume("type", state)?;
let (state, name) = parser::name1(state)?;
let (state, pars) = parser::until(parser::text_parser("{"), Box::new(parse_argument), state)?;
let mut ctrs = vec![];
let mut state = state;
loop {
let state_i = state;
let (state_i, ctr_name) = parser::name(state_i)?;
if ctr_name.is_empty() {
break;
}
let mut ctr_args = vec![];
let mut state_i = state_i;
loop {
let state_j = state_i;
let (state_j, head) = parser::peek_char(state_j)?;
if head != '(' {
break;
}
let (state_j, ctr_arg) = parse_argument(state_j)?;
ctr_args.push(ctr_arg);
state_i = state_j;
}
ctrs.push(Box::new(Constructor {
name: Ident(ctr_name),
args: ctr_args,
}));
state = state_i;
}
Ok((state, Box::new(NewType::Sum(SumType { name: Ident(name), pars, ctrs }))))
}),
state,
)
}
pub fn parse_prod_type(state: parser::State) -> parser::Answer<Option<Box<NewType>>> {
parser::guard(
parser::text_parser("record "),
Box::new(|state| {
let (state, _) = parser::consume("record", state)?;
let (state, name) = parser::name1(state)?;
let (state, pars) = parser::until(parser::text_parser("{"), Box::new(parse_argument), state)?;
let mut state = state;
let mut fields = Vec::new();
loop {
let state_i = state;
let (state_i, init) = get_init_index(state_i)?;
let (state_i, ctr_name) = parser::name(state_i)?;
let (state_i, _) = parser::consume(":", state_i)?;
let (state_i, tipo) = parse_apps(state_i)?;
let (state_i, last) = get_last_index(state_i)?;
let orig = Span::new_off(init, last);
fields.push(Box::new(Argument {
hide: false,
eras: false,
orig,
name: Ident(ctr_name),
tipo,
}));
let (state_i, head) = parser::peek_char(state_i)?;
state = state_i;
if head == '}' {
break;
}
}
Ok((state, Box::new(NewType::Prod(ProdType { name: Ident(name), pars, fields }))))
}),
state,
)
}
pub fn parse_newtype(state: parser::State) -> parser::Answer<Box<NewType>> {
parser::grammar(
"Newtype",
&[
Box::new(parse_sum_type), // `type `
Box::new(parse_prod_type), // `record `
Box::new(|state| Ok((state, None))),
],
state,
)
}
pub fn read_newtype(code: &str) -> Result<Box<NewType>, String> {
parser::read(Box::new(parse_newtype), code)
}

View File

@ -1,885 +0,0 @@
use crate::book::name::Ident;
use crate::book::span::{ByteOffset, Span};
use crate::book::term::{Operator, Term};
use crate::parser::utils::{get_init_index, get_last_index, is_ctr_head};
use hvm::parser;
use hvm::parser::{Answer, State};
use super::name::parse_path_str;
type TermPrefix = Box<dyn Fn(ByteOffset, Box<Term>) -> Box<Term>>;
type TermComplete = Box<dyn Fn(&str) -> Box<Term>>;
pub fn parse_var(state: State) -> 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) = parse_path_str(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: State) -> 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: State) -> 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: State) -> 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: Ident::new_path("String", "nil"),
args: Vec::new(),
};
let list = Box::new(chars.iter().rfold(empty, |t, h| Term::Ctr {
orig,
name: Ident::new_path("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: State) -> 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: State) -> 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;
}
}
Ok((state, term))
}
pub fn parse_ann(state: State) -> Answer<Option<TermPrefix>> {
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;
let tipo = tipo.clone();
Box::new(Term::Ann { orig, expr, tipo })
}),
))
}),
state,
);
}
pub fn parse_term_prefix(state: State) -> 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_open), // `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: State) -> Answer<TermPrefix> {
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: State) -> Answer<Option<TermPrefix>> {
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: State) -> Answer<Option<TermPrefix>> {
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;
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: State) -> Answer<Option<TermComplete>> {
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: State) -> Answer<Option<TermComplete>> {
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);
Ok((
state,
Box::new(move |monad| {
Box::new(Term::Ctr {
orig,
name: Ident::new_path(monad, "pure"),
args: vec![term.clone()],
})
}),
))
}),
state,
);
}
pub fn parse_ask_named_st(state: State) -> Answer<Option<TermComplete>> {
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.is_empty() && 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);
Ok((
state,
Box::new(move |monad| {
Box::new(Term::Ctr {
orig,
name: Ident::new_path(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: State) -> Answer<Option<TermComplete>> {
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);
Ok((
state,
Box::new(move |monad| {
Box::new(Term::Ctr {
orig,
name: Ident::new_path(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: State) -> Answer<TermComplete> {
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_apps(state)?;
Ok((state, Some(Box::new(move |_| term.clone()))))
}),
],
state,
)
}
pub fn parse_term(state: State) -> Answer<Box<Term>> {
let (state, init) = get_init_index(state)?;
let (state, prefix) = parse_term_prefix(state)?;
let (state, suffix) = parse_term_suffix(state)?;
Ok((state, suffix(init, prefix)))
}
pub fn parse_do(state: State) -> Answer<Option<Box<Term>>> {
parser::guard(
parser::text_parser("do "),
Box::new(|state| {
let (state, _) = parser::text("do", state)?;
let (state, name) = parse_path_str(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: State) -> 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) = parse_path_str(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)?;
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);
Ok((
state,
Box::new(Term::Mat {
orig,
tipo: Ident(tipo),
name: Ident(name),
expr,
cses,
moti,
}),
))
}),
state,
);
}
pub fn parse_open(state: State) -> Answer<Option<Box<Term>>> {
return parser::guard(
parser::text_parser("open "),
Box::new(|state| {
let (state, init) = get_init_index(state)?;
let (state, _) = parser::consume("open ", state)?;
let (state, tipo) = parse_path_str(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, 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);
let (state, body) = parse_apps(state)?;
Ok((
state,
Box::new(Term::Open {
orig,
tipo: Ident(tipo),
name: Ident(name),
expr,
moti,
body,
}),
))
}),
state,
);
}
pub fn peek_char_local(state: State) -> Answer<char> {
let (state, _) = parser::skip_while(state, Box::new(|x| *x == ' '))?;
if let Some(got) = parser::head(state) {
Ok((state, got))
} else {
Ok((state, '\0'))
}
}
pub fn parse_all(state: State) -> 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.is_empty()))
//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),
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: State) -> 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: Ident::new_path("Bool", "if"),
args: vec![moti, cond, if_t, if_f],
}),
))
}),
state,
);
}
pub fn parse_let(state: State) -> 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: State) -> Answer<Option<Box<Term>>> {
parser::guard(
Box::new(|state| {
let (state, name) = parser::name(state)?;
let (state, arro) = parser::text("=>", state)?;
Ok((state, !name.is_empty() && 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: State) -> 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: Ident::new_path("List", "nil"),
args: Vec::new(),
};
let list = Box::new(elems.iter().rfold(empty, |t, h| Term::Ctr {
orig,
name: Ident::new_path("List", "cons"),
args: vec![h.clone(), Box::new(t)],
}));
Ok((state, list))
}),
state,
)
}
pub fn parse_new(state: State) -> 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: Ident::new_path("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: State) -> 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) = parse_path_str(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: Ident(name), args })))
}),
state,
)
}
pub fn parse_chr(state: State) -> 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: State) -> Answer<Option<Box<Term>>> {
fn is_op_char(chr: char) -> bool {
matches!(chr, '+' | '-' | '*' | '/' | '%' | '&' | '|' | '^' | '<' | '>' | '=' | '!')
}
fn parse_oper(state: State) -> 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: State) -> 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.is_empty()))
//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: Ident("Sigma".to_string()),
args: vec![tipo, Box::new(Term::Lam { orig, name: Ident(name), body })],
}),
))
}),
state,
)
}

View File

@ -1,16 +0,0 @@
use crate::book::span::ByteOffset;
use hvm::parser;
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)))
}

View File

@ -1,111 +0,0 @@
use driver::config::Target;
use ntest::timeout;
use pretty_assertions::assert_eq;
use std::{
fs::{self, File},
io::Write,
path::Path,
};
use walkdir::{Error, WalkDir};
use kind2::codegen;
use kind2::driver::{self, config::Config};
fn golden_test(path: &Path, run: fn(&Path) -> String) {
let result = run(path);
let golden_path = path.with_extension("golden");
if let Ok(to_check) = fs::read_to_string(golden_path.clone()) {
assert_eq!(result, to_check, "Testing file '{}'", path.display());
} else {
let mut file = File::create(golden_path).unwrap();
file.write_all(result.as_bytes()).unwrap();
}
}
fn test_kind2(path: &Path, run: fn(&Path) -> String) -> Result<(), Error> {
for entry in WalkDir::new(path).follow_links(true) {
let entry = entry?;
let path = entry.path();
if path.is_file() && path.extension().map(|x| x == "kind2").unwrap_or(false) {
golden_test(path, run);
}
}
Ok(())
}
fn compile_kdl(config: &Config, path: &str) -> Result<String, String> {
let loaded = driver::loader::load(&config, path)?;
let comp_book = codegen::kdl::compile_book(&loaded.book)?;
let kdl_names = codegen::kdl::get_kdl_names(&comp_book, &None)?;
let result = codegen::kdl::to_kdl_book(&loaded.book, &kdl_names, &comp_book)?;
Ok(result)
}
#[test]
#[timeout(15000)]
fn test_checker() -> Result<(), Error> {
test_kind2(Path::new("./tests/suite/checker"), |path| {
let config = Config {
no_high_line: true,
color_output: false,
kind2_path: ".".to_string(),
target: Target::All,
};
let result = driver::loader::load(&config, path.to_str().unwrap());
let result = result.and_then(|x| driver::run_with_hvm(&driver::gen_checker(&x.book), "Kind.API.check_all", true));
result.map_or_else(|d| d, |e| e.output)
})?;
Ok(())
}
#[test]
#[timeout(10000)]
fn test_to_hvm() -> Result<(), Error> {
test_kind2(Path::new("./tests/suite/to_hvm"), |path| {
let config = Config {
no_high_line: true,
color_output: false,
kind2_path: "./tests/suite/lib".to_string(),
target: Target::Hvm,
};
let result = driver::loader::load(&config, path.to_str().unwrap());
let result = result.map(|loaded| codegen::hvm::to_hvm_book(&loaded.book));
result.map_or_else(|d| d, |e| e)
})?;
Ok(())
}
#[test]
#[timeout(10000)]
fn test_to_kdl() -> Result<(), Error> {
test_kind2(Path::new("./tests/suite/to_kdl"), |path| {
let config = Config {
no_high_line: true,
color_output: false,
kind2_path: ".".to_string(),
target: Target::Kdl,
};
let result = compile_kdl(&config, path.to_str().unwrap());
result.map_or_else(|d| d, |e| e)
})?;
Ok(())
}
#[test]
#[timeout(10000)]
fn test_run_hvm() -> Result<(), Error> {
test_kind2(Path::new("./tests/suite/eval"), |path| {
let config = Config {
no_high_line: true,
color_output: false,
kind2_path: "./tests/suite/lib".to_string(),
target: Target::Hvm,
};
let result = driver::loader::load(&config, path.to_str().unwrap());
let result = result.and_then(|x| driver::run_with_hvm(&driver::gen_checker(&x.book), "Kind.API.eval_main", true));
result.map_or_else(|d| d, |e| e.output)
})?;
Ok(())
}

View File

@ -1,2 +0,0 @@
All terms check.

View File

@ -1,45 +0,0 @@
Algebra.Group.concat <t: Type> (group: (Algebra.Group t)) : (_: t) (_: t) t
Algebra.Group.concat t (Algebra.Group.new t_ monoid inverse inverse_proof) = (Algebra.Monoid.concat _ monoid)
Algebra.Group.new <t: Type> (monoid: (Algebra.Monoid t)) (invert: (_: t) t) (inverse: (Algebra.Laws.Inverse t (Algebra.Monoid.concat _ monoid) invert (Algebra.Monoid.empty _ monoid))) : (Algebra.Group t)
Algebra.Group (t: Type) : Type
Algebra.Monoid.concat <t: Type> (monoid: (Algebra.Monoid t)) : (_: t) (_: t) t
Algebra.Monoid.concat t (Algebra.Monoid.new t_ sg empty id) = (Algebra.Semigroup.concat _ sg)
Algebra.Monoid.new <t: Type> (sg: (Algebra.Semigroup t)) (empty: t) (identity: (Algebra.Laws.Identity t (Algebra.Semigroup.concat _ sg) empty)) : (Algebra.Monoid t)
Algebra.Semigroup (t: Type) : Type
Algebra.Laws.Identity (t: Type) (concat: (_: t) (_: t) t) (empty: t) : Type
Algebra.Monoid (t: Type) : Type
Algebra.Semigroup.concat <t: Type> (semigroup: (Algebra.Semigroup t)) : (_: t) (_: t) t
Algebra.Semigroup.concat t (Algebra.Semigroup.new t_ magma assoc) = (Algebra.Magma.concat _ magma)
Algebra.Semigroup.new <t: Type> (magma: (Algebra.Magma t)) (associativity: (Algebra.Laws.associativity.eta _ (Algebra.Magma.concat _ magma))) : (Algebra.Semigroup t)
Algebra.Magma (t: Type) : Type
Algebra.Laws.associativity.eta <t: Type> (concat: (_: t) (_: t) t) : Type
Algebra.Laws.associativity.eta t concat = (a: t) (b: t) (c: t) (Equal _ (concat (concat a b) c) (concat a (concat b c)))
Equal <t: Type> (a: t) (b: t) : Type
Algebra.Magma.concat <t: Type> (magma: (Algebra.Magma t)) : (_: t) (_: t) t
Algebra.Magma.concat t (Algebra.Magma.new t_ concat) = concat
Algebra.Magma.new <t: Type> (concat: (_: t) (_: t) t) : (Algebra.Magma t)
Algebra.Monoid.empty <t: Type> (monoid: (Algebra.Monoid t)) : t
Algebra.Monoid.empty t (Algebra.Monoid.new t_ sg empty id) = empty
Algebra.Laws.Inverse (t: Type) (concat: (_: t) (_: t) t) (inverse: (_: t) t) (empty: t) : Type

View File

@ -1,2 +0,0 @@
All terms check.

View File

@ -1,7 +0,0 @@
// We should open an issue for this?
Arity3 -(e: U60) -(f: U60) <g> <h> <i> (d: U60) : U60
Arity3 e f g h i d = d
Main : U60
Main = Arity3 1 2 3

View File

@ -1,2 +0,0 @@
All terms check.

View File

@ -1,2 +0,0 @@
All terms check.

View File

@ -1,243 +0,0 @@
// From https://github.com/Kindelia/Functional-Benchmarks/blob/master/Checker/Base.kind2
//
// Types
// =====
// Equality
// --------
Base.Equal <t: Type> (a: t) (b: t) : Type
Base.refl <t: Type> <a: t> : Base.Equal t a a
// Boolean
// -------
Base.Bool : Type
Base.true : Base.Bool
Base.false : Base.Bool
// Natural Number
// --------------
Base.Nat : Type
Base.zero : Base.Nat
Base.succ (pred: Base.Nat) : Base.Nat
// Binary Tree
// -----------
Base.Tree : Type
Base.leaf : Base.Tree
Base.node (l: Base.Tree) (r: Base.Tree) : Base.Tree
// Vector
// ------
Base.Vector (t: Type) (len: Base.Nat) : Type
Base.cons <t: Type> <len: Base.Nat> (head: t) (tail: Base.Vector t len) : Base.Vector t (Base.succ len)
Base.nil <t: Type> : Base.Vector t Base.zero
// Church Boolean
// --------------
Base.Church.Bool : Type
Base.Church.Bool = (p: Type) -> (t: p) -> (f: p) -> p
Base.Church.true : Base.Church.Bool
Base.Church.true = p => t => f => t
Base.Church.false : Base.Church.Bool
Base.Church.false = p => t => f => f
// Church Natural Number
// ---------------------
Base.Church.Nat : Type
Base.Church.Nat = (p: Type) -> (f: p -> p) -> (z: p) -> p
Base.Church.zero : Base.Church.Nat
Base.Church.zero = p => f => z => z
Base.Church.succ (n: Base.Church.Nat) : Base.Church.Nat
Base.Church.succ n = p => f => z => f (n p f z)
// Church Tree
// -----------
Base.Church.Tree : Type
Base.Church.Tree = (p: Type) -> (n: p -> p -> p) -> (l: p) -> p
Base.Church.leaf : Base.Church.Tree
Base.Church.leaf = p => n => l => l
Base.Church.node (a: Base.Church.Tree) (b: Base.Church.Tree) : Base.Church.Tree
Base.Church.node a b = p => n => l => n (a p n l) (b p n l)
// Church Vector
// -------------
Base.Church.Vector (t: Type) (len: Base.Nat) : Type
Base.Church.Vector t n = (p: Base.Nat -> Type) -> (cons: (len: Base.Nat) -> (head: t) -> (tail: p len) -> p (Base.succ len)) -> (nil: p Base.zero) -> p n
Base.Church.nil <t: Type> : Base.Church.Vector t Base.zero
Base.Church.nil t = p => cons => nil => nil
Base.Church.cons <t: Type> <len: Base.Nat> (head: t) (tail: Base.Church.Vector t len) : Base.Church.Vector t (Base.succ len)
Base.Church.cons t len head tail = p => cons => nil => cons len head (tail p cons nil)
// Functions
// =========
Base.not (b: Base.Bool) : Base.Bool
Base.not Base.false = Base.true
Base.not Base.true = Base.false
Base.and (a: Base.Bool) (b: Base.Bool) : Base.Bool
Base.and Base.false Base.false = Base.false
Base.and Base.false Base.true = Base.false
Base.and Base.true Base.false = Base.false
Base.and Base.true Base.true = Base.true
Base.add (a: Base.Nat) (b: Base.Nat) : Base.Nat
Base.add x Base.zero = x
Base.add x (Base.succ y) = Base.succ (Base.add x y)
Base.mul (a: Base.Nat) (b: Base.Nat) : Base.Nat
Base.mul a Base.zero = Base.zero
Base.mul a (Base.succ b) = Base.add a (Base.mul a b)
Base.exp (a: Base.Nat) (b: Base.Nat) : Base.Nat
Base.exp a Base.zero = Base.succ Base.zero
Base.exp a (Base.succ b) = Base.mul a (Base.exp a b)
Base.is_even (a: Base.Nat) : Base.Bool
Base.is_even Base.zero = Base.true
Base.is_even (Base.succ a) = Base.not (Base.is_even a)
Base.full_tree (d: Base.Nat) : Base.Tree
Base.full_tree Base.zero = Base.leaf
Base.full_tree (Base.succ d) = let branch = Base.full_tree d; Base.node branch branch
Base.tree_fold (a: Base.Tree) (p: Type) (n: p -> p -> p) (l: p) : p
Base.tree_fold Base.leaf p n l = l
Base.tree_fold (Base.node a b) p n l = n (Base.tree_fold a p n l) (Base.tree_fold b p n l)
Base.force_tree (a: Base.Tree) : Base.Bool
Base.force_tree t = Base.tree_fold t Base.Bool (a => b => Base.and a b) Base.true
Base.Church.not (b: Base.Church.Bool) : Base.Church.Bool
Base.Church.not b = p => t => f => b p f t
Base.Church.and (a: Base.Church.Bool) (b: Base.Church.Bool) : Base.Church.Bool
Base.Church.and a b = p => t => f => a p (b p t f) f
Base.Church.add (a: Base.Church.Nat) (b: Base.Church.Nat) : Base.Church.Nat
Base.Church.add a b = p => f => z => a p f (b p f z)
Base.Church.mul (a: Base.Church.Nat) (b: Base.Church.Nat) : Base.Church.Nat
Base.Church.mul a b = p => f => a p (b p f)
Base.Church.exp (a: Base.Church.Nat) (b: Base.Church.Nat) : Base.Church.Nat
Base.Church.exp a b = p => b (p -> p) (a p)
Base.Church.is_even (a: Base.Church.Nat) : Base.Church.Bool
Base.Church.is_even a = a Base.Church.Bool (x => Base.Church.not x) Base.Church.true
Base.Church.full_tree (d: Base.Church.Nat) : Base.Church.Tree
Base.Church.full_tree d = p => n => l => d p (t => n t t) l
Base.Church.tree_fold (a: Base.Church.Tree) (p: Type) (n: p -> p -> p) (l: p) : p
Base.Church.tree_fold t p n l = t p n l
Base.Church.force_tree (a: Base.Church.Tree) : Base.Church.Bool
Base.Church.force_tree t = Base.Church.tree_fold t Base.Church.Bool (a => b => Base.Church.and a b) Base.Church.true
// Elaboration
// ===========
//Id : (t : Type) -> t -> t
//Id = t => x => x
//Bad : (t : Type) -> t -> t
//Bad = ((Id) _ Id) _ Id
// Constants
// =========
Base.N0 : Base.Nat { Base.zero }
Base.N1 : Base.Nat { Base.succ Base.N0 }
Base.N2 : Base.Nat { Base.succ Base.N1 }
Base.N3 : Base.Nat { Base.succ Base.N2 }
Base.N4 : Base.Nat { Base.succ Base.N3 }
Base.N5 : Base.Nat { Base.succ Base.N4 }
Base.N6 : Base.Nat { Base.succ Base.N5 }
Base.N7 : Base.Nat { Base.succ Base.N6 }
Base.N8 : Base.Nat { Base.succ Base.N7 }
Base.N9 : Base.Nat { Base.succ Base.N8 }
Base.N10 : Base.Nat { Base.succ Base.N9 }
Base.N11 : Base.Nat { Base.succ Base.N10 }
Base.N12 : Base.Nat { Base.succ Base.N11 }
Base.N13 : Base.Nat { Base.succ Base.N12 }
Base.N14 : Base.Nat { Base.succ Base.N13 }
Base.N15 : Base.Nat { Base.succ Base.N14 }
Base.N16 : Base.Nat { Base.succ Base.N15 }
Base.N17 : Base.Nat { Base.succ Base.N16 }
Base.N18 : Base.Nat { Base.succ Base.N17 }
Base.N19 : Base.Nat { Base.succ Base.N18 }
Base.N20 : Base.Nat { Base.succ Base.N19 }
Base.N21 : Base.Nat { Base.succ Base.N20 }
Base.N22 : Base.Nat { Base.succ Base.N21 }
Base.N23 : Base.Nat { Base.succ Base.N22 }
Base.N24 : Base.Nat { Base.succ Base.N23 }
Base.N25 : Base.Nat { Base.succ Base.N24 }
Base.N26 : Base.Nat { Base.succ Base.N25 }
Base.N27 : Base.Nat { Base.succ Base.N26 }
Base.N28 : Base.Nat { Base.succ Base.N27 }
Base.N29 : Base.Nat { Base.succ Base.N28 }
Base.N30 : Base.Nat { Base.succ Base.N29 }
Base.N31 : Base.Nat { Base.succ Base.N30 }
Base.N32 : Base.Nat { Base.succ Base.N31 }
Base.Church.N0 : Base.Church.Nat { Base.Church.zero }
Base.Church.N1 : Base.Church.Nat { Base.Church.succ Base.Church.N0 }
Base.Church.N2 : Base.Church.Nat { Base.Church.succ Base.Church.N1 }
Base.Church.N3 : Base.Church.Nat { Base.Church.succ Base.Church.N2 }
Base.Church.N4 : Base.Church.Nat { Base.Church.succ Base.Church.N3 }
Base.Church.N5 : Base.Church.Nat { Base.Church.succ Base.Church.N4 }
Base.Church.N6 : Base.Church.Nat { Base.Church.succ Base.Church.N5 }
Base.Church.N7 : Base.Church.Nat { Base.Church.succ Base.Church.N6 }
Base.Church.N8 : Base.Church.Nat { Base.Church.succ Base.Church.N7 }
Base.Church.N9 : Base.Church.Nat { Base.Church.succ Base.Church.N8 }
Base.Church.N10 : Base.Church.Nat { Base.Church.succ Base.Church.N9 }
Base.Church.N11 : Base.Church.Nat { Base.Church.succ Base.Church.N10 }
Base.Church.N12 : Base.Church.Nat { Base.Church.succ Base.Church.N11 }
Base.Church.N13 : Base.Church.Nat { Base.Church.succ Base.Church.N12 }
Base.Church.N14 : Base.Church.Nat { Base.Church.succ Base.Church.N13 }
Base.Church.N15 : Base.Church.Nat { Base.Church.succ Base.Church.N14 }
Base.Church.N16 : Base.Church.Nat { Base.Church.succ Base.Church.N15 }
Base.Church.N17 : Base.Church.Nat { Base.Church.succ Base.Church.N16 }
Base.Church.N18 : Base.Church.Nat { Base.Church.succ Base.Church.N17 }
Base.Church.N19 : Base.Church.Nat { Base.Church.succ Base.Church.N18 }
Base.Church.N20 : Base.Church.Nat { Base.Church.succ Base.Church.N19 }
Base.Church.N21 : Base.Church.Nat { Base.Church.succ Base.Church.N20 }
Base.Church.N22 : Base.Church.Nat { Base.Church.succ Base.Church.N21 }
Base.Church.N23 : Base.Church.Nat { Base.Church.succ Base.Church.N22 }
Base.Church.N24 : Base.Church.Nat { Base.Church.succ Base.Church.N23 }
Base.Church.N25 : Base.Church.Nat { Base.Church.succ Base.Church.N24 }
Base.Church.N26 : Base.Church.Nat { Base.Church.succ Base.Church.N25 }
Base.Church.N27 : Base.Church.Nat { Base.Church.succ Base.Church.N26 }
Base.Church.N28 : Base.Church.Nat { Base.Church.succ Base.Church.N27 }
Base.Church.N29 : Base.Church.Nat { Base.Church.succ Base.Church.N28 }
Base.Church.N30 : Base.Church.Nat { Base.Church.succ Base.Church.N29 }
Base.Church.N31 : Base.Church.Nat { Base.Church.succ Base.Church.N30 }
Base.Church.N32 : Base.Church.Nat { Base.Church.succ Base.Church.N31 }
Test {
(Base.cons Type (Base.cons Type (Base.cons Type (Base.cons Type (Base.cons Type (Base.cons Type
Base.nil
))))))
}
Base { 0 }

View File

@ -1,2 +0,0 @@
All terms check.

File diff suppressed because it is too large Load Diff

View File

@ -1,2 +0,0 @@
All terms check.

View File

@ -1 +0,0 @@
Can't load type.

View File

@ -1,6 +0,0 @@
Main : U60
Main =
let k = 2
match U60 k {
s => ?
}

View File

@ -1 +0,0 @@
Incorrect arity.

View File

@ -1,2 +0,0 @@
Arity <a> <b> <c> (d: U60) : U60
Arity a b d = d

View File

@ -1 +0,0 @@
Repeated variable.

View File

@ -1,6 +0,0 @@
List <a> : Type
List.nil <a> : List a
List.cons <a> (head: a) (tail: List a) : List a
Main (x: List U60) (x: List U60) : List U60
Main (List.cons x (List.cons y (List.cons z a))) (List.cons b (List.cons c (List.cons d x))) = List.nil

View File

@ -1,46 +0,0 @@
Type mismatch
- Expected: Type
- Detected: t
Kind.Context:
- t : Type
- g : t
- h : t
On '{{#F0F#}}':
{{#R0:1364:1365R#}}
Type mismatch
- Expected: ((concat a) b)
- Detected: a
Kind.Context:
- t : Type
- concat : ((g: t) -> ((h: t) -> g))
- a : t
- b : t
- c : t
On '{{#F0F#}}':
{{#R0:1471:1492R#}}
Type mismatch
- Expected: t
- Detected: b
Kind.Context:
- t : Type
- concat : ((g: t) -> ((h: t) -> g))
- a : t
- b : t
- c : t
On '{{#F0F#}}':
{{#R0:1481:1491R#}}
Type mismatch
- Expected: t
- Detected: a
Kind.Context:
- t : Type
- concat : ((g: t) -> ((h: t) -> g))
- a : t
- b : t
- c : t
On '{{#F0F#}}':
{{#R0:1455:1465R#}}

View File

@ -1,45 +0,0 @@
Algebra.Group.concat <t: Type> (group: (Algebra.Group t)) : (_: t) (_: t) t
Algebra.Group.concat t (Algebra.Group.new t_ monoid inverse inverse_proof) = (Algebra.Monoid.concat _ monoid)
Algebra.Group.new <t: Type> (monoid: (Algebra.Monoid t)) (invert: (_: t) t) (inverse: (Algebra.Laws.Inverse t (Algebra.Monoid.concat _ monoid) invert (Algebra.Monoid.empty _ monoid))) : (Algebra.Group t)
Algebra.Group (t: Type) : Type
Algebra.Monoid.concat <t: Type> (monoid: (Algebra.Monoid t)) : (_: t) (_: t) t
Algebra.Monoid.concat t (Algebra.Monoid.new t_ sg empty id) = (Algebra.Semigroup.concat _ sg)
Algebra.Monoid.new <t: Type> (sg: (Algebra.Semigroup t)) (empty: t) (identity: (Algebra.Laws.Identity t (Algebra.Semigroup.concat _ sg) empty)) : (Algebra.Monoid t)
Algebra.Semigroup (t: Type) : Type
Algebra.Laws.Identity (t: Type) (concat: (_: t) (_: t) t) (empty: t) : Type
Algebra.Monoid (t: Type) : Type
Algebra.Semigroup.concat <t: Type> (semigroup: (Algebra.Semigroup t)) : (_: t) (_: t) t
Algebra.Semigroup.concat t (Algebra.Semigroup.new t_ magma assoc) = (Algebra.Magma.concat _ magma)
Algebra.Semigroup.new <t: Type> (magma: (Algebra.Magma t)) (associativity: (Algebra.Laws.associativity.eta _ (Algebra.Magma.concat _ magma))) : (Algebra.Semigroup t)
Algebra.Magma (t: Type) : Type
Algebra.Laws.associativity.eta <t: Type> (concat: (g: t) (h: t) g) : Type
Algebra.Laws.associativity.eta t concat = (a: t) (b: t) (c: t) (Equal _ (concat (concat a b) c) (concat a (concat b c)))
Equal <t: Type> (a: t) (b: t) : Type
Algebra.Magma.concat <t: Type> (magma: (Algebra.Magma t)) : (_: t) (_: t) t
Algebra.Magma.concat t (Algebra.Magma.new t_ concat) = concat
Algebra.Magma.new <t: Type> (concat: (_: t) (_: t) t) : (Algebra.Magma t)
Algebra.Monoid.empty <t: Type> (monoid: (Algebra.Monoid t)) : t
Algebra.Monoid.empty t (Algebra.Monoid.new t_ sg empty id) = empty
Algebra.Laws.Inverse (t: Type) (concat: (_: t) (_: t) t) (inverse: (_: t) t) (empty: t) : Type

View File

@ -1,2 +0,0 @@
All terms check.

View File

@ -1 +0,0 @@
Unbound variable 'c'.

View File

@ -1,2 +0,0 @@
Main (a: U60): U60 -> U60
Main a = (b => (+ (+ a c) b))

View File

@ -1 +0,0 @@
Unbound variable 'b'.

View File

@ -1,2 +0,0 @@
Main (a: U60): U60
Main a = (+ a b)

View File

@ -1,2 +0,0 @@
All terms check.

View File

@ -1,254 +0,0 @@
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_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 : Type
Kind.Term.typ (orig: U60) : (Kind.Term)
Kind.Term.hol (orig: U60) (number: U60) : (Kind.Term)
Kind.Term.var (orig: U60) (name: U60) (index: U60) : (Kind.Term)
Kind.Term.all (orig: U60) (name: U60) (typ: (Kind.Term)) (body: ((_: (Kind.Term)) (Kind.Term))) : (Kind.Term)
Kind.Term.lam (orig: U60) (name: U60) (body: ((_: (Kind.Term)) (Kind.Term))) : (Kind.Term)
Kind.Term.app (orig: U60) (func: (Kind.Term)) (arg: (Kind.Term)) : (Kind.Term)
Kind.Term.let (orig: U60) (name: U60) (expr: (Kind.Term)) (body: ((_: (Kind.Term)) (Kind.Term))) : (Kind.Term)
Kind.Term.ann (orig: U60) (expr: (Kind.Term)) (typ: (Kind.Term)) : (Kind.Term)
Kind.Term.sub (orig: U60) (name: U60) (indx: U60) (redx: U60) (expr: (Kind.Term)) : (Kind.Term)
Kind.Term.ct0 (ctid: U60) (orig: U60) : (Kind.Term)
Kind.Term.ct1 (ctid: U60) (orig: U60) (x0: (Kind.Term)) : (Kind.Term)
Kind.Term.ct2 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) : (Kind.Term)
Kind.Term.ct3 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) : (Kind.Term)
Kind.Term.ct4 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) : (Kind.Term)
Kind.Term.ct5 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) : (Kind.Term)
Kind.Term.ct6 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) : (Kind.Term)
Kind.Term.ct7 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) : (Kind.Term)
Kind.Term.ct8 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) : (Kind.Term)
Kind.Term.ct9 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) : (Kind.Term)
Kind.Term.ct10 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) : (Kind.Term)
Kind.Term.ct11 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) : (Kind.Term)
Kind.Term.ct12 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) (x11: (Kind.Term)) : (Kind.Term)
Kind.Term.ct13 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) (x11: (Kind.Term)) (x12: (Kind.Term)) : (Kind.Term)
Kind.Term.ct14 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) (x11: (Kind.Term)) (x12: (Kind.Term)) (x13: (Kind.Term)) : (Kind.Term)
Kind.Term.ct15 (ctid: U60) (orig: U60) (args: (Kind.Term)) : (Kind.Term)
Kind.Term.ct16 (ctid: U60) (orig: U60) (args: (Kind.Term)) : (Kind.Term)
Kind.Term.fn0 (fnid: U60) (orig: U60) : (Kind.Term)
Kind.Term.fn1 (fnid: U60) (orig: U60) (x0: (Kind.Term)) : (Kind.Term)
Kind.Term.fn2 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) : (Kind.Term)
Kind.Term.fn3 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) : (Kind.Term)
Kind.Term.fn4 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) : (Kind.Term)
Kind.Term.fn5 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) : (Kind.Term)
Kind.Term.fn6 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) : (Kind.Term)
Kind.Term.fn7 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) : (Kind.Term)
Kind.Term.fn8 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) : (Kind.Term)
Kind.Term.fn9 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) : (Kind.Term)
Kind.Term.fn10 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) : (Kind.Term)
Kind.Term.fn11 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) : (Kind.Term)
Kind.Term.fn12 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) (x11: (Kind.Term)) : (Kind.Term)
Kind.Term.fn13 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) (x11: (Kind.Term)) (x12: (Kind.Term)) : (Kind.Term)
Kind.Term.fn14 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) (x11: (Kind.Term)) (x12: (Kind.Term)) (x13: (Kind.Term)) : (Kind.Term)
Kind.Term.fn15 (fnid: U60) (orig: U60) (args: (Kind.Term)) : (Kind.Term)
Kind.Term.fn16 (fnid: U60) (orig: U60) (args: (Kind.Term)) : (Kind.Term)
Kind.Term.FN0 (fnid: U60) (orig: U60) : (Kind.Term)
Kind.Term.FN1 (fnid: U60) (orig: U60) (x0: (Kind.Term)) : (Kind.Term)
Kind.Term.FN2 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) : (Kind.Term)
Kind.Term.FN3 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) : (Kind.Term)
Kind.Term.FN4 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) : (Kind.Term)
Kind.Term.FN5 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) : (Kind.Term)
Kind.Term.FN6 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) : (Kind.Term)
Kind.Term.FN7 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) : (Kind.Term)
Kind.Term.FN8 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) : (Kind.Term)
Kind.Term.FN9 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) : (Kind.Term)
Kind.Term.FN10 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) : (Kind.Term)
Kind.Term.FN11 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) : (Kind.Term)
Kind.Term.FN12 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) (x11: (Kind.Term)) : (Kind.Term)
Kind.Term.FN13 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) (x11: (Kind.Term)) (x12: (Kind.Term)) : (Kind.Term)
Kind.Term.FN14 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) (x11: (Kind.Term)) (x12: (Kind.Term)) (x13: (Kind.Term)) : (Kind.Term)
Kind.Term.FN15 (fnid: U60) (orig: U60) (args: (Kind.Term)) : (Kind.Term)
Kind.Term.FN16 (fnid: U60) (orig: U60) (args: (Kind.Term)) : (Kind.Term)
Kind.Term.hlp (orig: U60) : (Kind.Term)
Kind.Term.u60 (orig: U60) : (Kind.Term)
Kind.Term.num (orig: U60) (num: U60) : (Kind.Term)
Kind.Term.op2 (orig: U60) (operator: (Kind.Operator)) (left: (Kind.Term)) (right: (Kind.Term)) : (Kind.Term)
Kind.Term.args15 (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) (x11: (Kind.Term)) (x12: (Kind.Term)) (x13: (Kind.Term)) (x14: (Kind.Term)) : (Kind.Term)
Kind.Term.args16 (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) (x11: (Kind.Term)) (x12: (Kind.Term)) (x13: (Kind.Term)) (x14: (Kind.Term)) (x15: (Kind.Term)) : (Kind.Term)
Kind.Operator : Type
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_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.Operator.mod : (Kind.Operator)
Kind.Operator.lte : (Kind.Operator)
Kind.Operator.eql : (Kind.Operator)
Kind.Operator.xor : (Kind.Operator)
Kind.Operator.gte : (Kind.Operator)
Kind.Operator.shl : (Kind.Operator)
Kind.Operator.shr : (Kind.Operator)
Kind.Operator.div : (Kind.Operator)
Kind.Operator.neq : (Kind.Operator)
Kind.Operator.add : (Kind.Operator)
Kind.Operator.sub : (Kind.Operator)
Kind.Operator.ltn : (Kind.Operator)
Kind.Operator.mul : (Kind.Operator)
Kind.Operator.gtn : (Kind.Operator)
Kind.Operator.and : (Kind.Operator)
Kind.Operator.or : (Kind.Operator)

View File

@ -1,2 +0,0 @@
All terms check.

View File

@ -1,247 +0,0 @@
// From: https://github.com/Kindelia/Functional-Benchmarks/blob/master/Checker/nat_exp_church.kind2
// Types
// =====
// Equality
// --------
Base.Equal <t: Type> (a: t) (b: t) : Type
Base.refl <t: Type> <a: t> : Base.Equal t a a
// Boolean
// -------
Base.Bool : Type
Base.true : Base.Bool
Base.false : Base.Bool
// Natural Number
// --------------
Base.Nat : Type
Base.zero : Base.Nat
Base.succ (pred: Base.Nat) : Base.Nat
// Binary Tree
// -----------
Base.Tree : Type
Base.leaf : Base.Tree
Base.node (l: Base.Tree) (r: Base.Tree) : Base.Tree
// Vector
// ------
Base.Vector (t: Type) (len: Base.Nat) : Type
Base.cons <t: Type> <len: Base.Nat> (head: t) (tail: Base.Vector t len) : Base.Vector t (Base.succ len)
Base.nil <t: Type> : Base.Vector t Base.zero
// Church Boolean
// --------------
Base.Church.Bool : Type
Base.Church.Bool = (p: Type) -> (t: p) -> (f: p) -> p
Base.Church.true : Base.Church.Bool
Base.Church.true = p => t => f => t
Base.Church.false : Base.Church.Bool
Base.Church.false = p => t => f => f
// Church Natural Number
// ---------------------
Base.Church.Nat : Type
Base.Church.Nat = (p: Type) -> (f: p -> p) -> (z: p) -> p
Base.Church.zero : Base.Church.Nat
Base.Church.zero = p => f => z => z
Base.Church.succ (n: Base.Church.Nat) : Base.Church.Nat
Base.Church.succ n = p => f => z => f (n p f z)
Base.Church.to_u60 (n: Base.Church.Nat) : U60
Base.Church.to_u60 n = n U60 (x => (+ x 1)) 0
// Church Tree
// -----------
Base.Church.Tree : Type
Base.Church.Tree = (p: Type) -> (n: p -> p -> p) -> (l: p) -> p
Base.Church.leaf : Base.Church.Tree
Base.Church.leaf = p => n => l => l
Base.Church.node (a: Base.Church.Tree) (b: Base.Church.Tree) : Base.Church.Tree
Base.Church.node a b = p => n => l => n (a p n l) (b p n l)
// Church Vector
// -------------
Base.Church.Vector (t: Type) (len: Base.Nat) : Type
Base.Church.Vector t n = (p: Base.Nat -> Type) -> (cons: (len: Base.Nat) -> (head: t) -> (tail: p len) -> p (Base.succ len)) -> (nil: p Base.zero) -> p n
Base.Church.nil <t: Type> : Base.Church.Vector t Base.zero
Base.Church.nil t = p => cons => nil => nil
Base.Church.cons <t: Type> (len: Base.Nat) (head: t) (tail: Base.Church.Vector t len) : Base.Church.Vector t (Base.succ len)
Base.Church.cons t len head tail = p => cons => nil => cons len head (tail p cons nil)
// Functions
// =========
Base.not (b: Base.Bool) : Base.Bool
Base.not Base.false = Base.true
Base.not Base.true = Base.false
Base.and (a: Base.Bool) (b: Base.Bool) : Base.Bool
Base.and Base.false Base.false = Base.false
Base.and Base.false Base.true = Base.false
Base.and Base.true Base.false = Base.false
Base.and Base.true Base.true = Base.true
Base.add (a: Base.Nat) (b: Base.Nat) : Base.Nat
Base.add x Base.zero = x
Base.add x (Base.succ y) = Base.succ (Base.add x y)
Base.mul (a: Base.Nat) (b: Base.Nat) : Base.Nat
Base.mul a Base.zero = Base.zero
Base.mul a (Base.succ b) = Base.add a (Base.mul a b)
Base.exp (a: Base.Nat) (b: Base.Nat) : Base.Nat
Base.exp a Base.zero = Base.succ Base.zero
Base.exp a (Base.succ b) = Base.mul a (Base.exp a b)
Base.is_even (a: Base.Nat) : Base.Bool
Base.is_even Base.zero = Base.true
Base.is_even (Base.succ a) = Base.not (Base.is_even a)
Base.full_tree (d: Base.Nat) : Base.Tree
Base.full_tree Base.zero = Base.leaf
Base.full_tree (Base.succ d) = let branch = Base.full_tree d; Base.node branch branch
Base.tree_fold (a: Base.Tree) (p: Type) (n: p -> p -> p) (l: p) : p
Base.tree_fold Base.leaf p n l = l
Base.tree_fold (Base.node a b) p n l = n (Base.tree_fold a p n l) (Base.tree_fold b p n l)
Base.force_tree (a: Base.Tree) : Base.Bool
Base.force_tree t = Base.tree_fold t Base.Bool (a => b => Base.and a b) Base.true
Base.Church.not (b: Base.Church.Bool) : Base.Church.Bool
Base.Church.not b = p => t => f => b p f t
Base.Church.and (a: Base.Church.Bool) (b: Base.Church.Bool) : Base.Church.Bool
Base.Church.and a b = p => t => f => a p (b p t f) f
Base.Church.add (a: Base.Church.Nat) (b: Base.Church.Nat) : Base.Church.Nat
Base.Church.add a b = p => f => z => a p f (b p f z)
Base.Church.mul (a: Base.Church.Nat) (b: Base.Church.Nat) : Base.Church.Nat
Base.Church.mul a b = p => f => a p (b p f)
Base.Church.exp (a: Base.Church.Nat) (b: Base.Church.Nat) : Base.Church.Nat
Base.Church.exp a b = p => b (p -> p) (a p)
Base.Church.is_even (a: Base.Church.Nat) : Base.Church.Bool
Base.Church.is_even a = a Base.Church.Bool (x => Base.Church.not x) Base.Church.true
Base.Church.full_tree (d: Base.Church.Nat) : Base.Church.Tree
Base.Church.full_tree d = p => n => l => d p (t => n t t) l
Base.Church.tree_fold (a: Base.Church.Tree) (p: Type) (n: p -> p -> p) (l: p) : p
Base.Church.tree_fold t p n l = t p n l
Base.Church.force_tree (a: Base.Church.Tree) : Base.Church.Bool
Base.Church.force_tree t = Base.Church.tree_fold t Base.Church.Bool (a => b => Base.Church.and a b) Base.Church.true
// Elaboration
// ===========
//Id : (t : Type) -> t -> t
//Id = t => x => x
//Bad : (t : Type) -> t -> t
//Bad = ((Id) _ Id) _ Id
// Constants
// =========
Base.N0 : Base.Nat { Base.zero }
Base.N1 : Base.Nat { Base.succ Base.N0 }
Base.N2 : Base.Nat { Base.succ Base.N1 }
Base.N3 : Base.Nat { Base.succ Base.N2 }
Base.N4 : Base.Nat { Base.succ Base.N3 }
Base.N5 : Base.Nat { Base.succ Base.N4 }
Base.N6 : Base.Nat { Base.succ Base.N5 }
Base.N7 : Base.Nat { Base.succ Base.N6 }
Base.N8 : Base.Nat { Base.succ Base.N7 }
Base.N9 : Base.Nat { Base.succ Base.N8 }
Base.N10 : Base.Nat { Base.succ Base.N9 }
Base.N11 : Base.Nat { Base.succ Base.N10 }
Base.N12 : Base.Nat { Base.succ Base.N11 }
Base.N13 : Base.Nat { Base.succ Base.N12 }
Base.N14 : Base.Nat { Base.succ Base.N13 }
Base.N15 : Base.Nat { Base.succ Base.N14 }
Base.N16 : Base.Nat { Base.succ Base.N15 }
Base.N17 : Base.Nat { Base.succ Base.N16 }
Base.N18 : Base.Nat { Base.succ Base.N17 }
Base.N19 : Base.Nat { Base.succ Base.N18 }
Base.N20 : Base.Nat { Base.succ Base.N19 }
Base.N21 : Base.Nat { Base.succ Base.N20 }
Base.N22 : Base.Nat { Base.succ Base.N21 }
Base.N23 : Base.Nat { Base.succ Base.N22 }
Base.N24 : Base.Nat { Base.succ Base.N23 }
Base.N25 : Base.Nat { Base.succ Base.N24 }
Base.N26 : Base.Nat { Base.succ Base.N25 }
Base.N27 : Base.Nat { Base.succ Base.N26 }
Base.N28 : Base.Nat { Base.succ Base.N27 }
Base.N29 : Base.Nat { Base.succ Base.N28 }
Base.N30 : Base.Nat { Base.succ Base.N29 }
Base.N31 : Base.Nat { Base.succ Base.N30 }
Base.N32 : Base.Nat { Base.succ Base.N31 }
Base.Church.N0 : Base.Church.Nat { Base.Church.zero }
Base.Church.N1 : Base.Church.Nat { Base.Church.succ Base.Church.N0 }
Base.Church.N2 : Base.Church.Nat { Base.Church.succ Base.Church.N1 }
Base.Church.N3 : Base.Church.Nat { Base.Church.succ Base.Church.N2 }
Base.Church.N4 : Base.Church.Nat { Base.Church.succ Base.Church.N3 }
Base.Church.N5 : Base.Church.Nat { Base.Church.succ Base.Church.N4 }
Base.Church.N6 : Base.Church.Nat { Base.Church.succ Base.Church.N5 }
Base.Church.N7 : Base.Church.Nat { Base.Church.succ Base.Church.N6 }
Base.Church.N8 : Base.Church.Nat { Base.Church.succ Base.Church.N7 }
Base.Church.N9 : Base.Church.Nat { Base.Church.succ Base.Church.N8 }
Base.Church.N10 : Base.Church.Nat { Base.Church.succ Base.Church.N9 }
Base.Church.N11 : Base.Church.Nat { Base.Church.succ Base.Church.N10 }
Base.Church.N12 : Base.Church.Nat { Base.Church.succ Base.Church.N11 }
Base.Church.N13 : Base.Church.Nat { Base.Church.succ Base.Church.N12 }
Base.Church.N14 : Base.Church.Nat { Base.Church.succ Base.Church.N13 }
Base.Church.N15 : Base.Church.Nat { Base.Church.succ Base.Church.N14 }
Base.Church.N16 : Base.Church.Nat { Base.Church.succ Base.Church.N15 }
Base.Church.N17 : Base.Church.Nat { Base.Church.succ Base.Church.N16 }
Base.Church.N18 : Base.Church.Nat { Base.Church.succ Base.Church.N17 }
Base.Church.N19 : Base.Church.Nat { Base.Church.succ Base.Church.N18 }
Base.Church.N20 : Base.Church.Nat { Base.Church.succ Base.Church.N19 }
Base.Church.N21 : Base.Church.Nat { Base.Church.succ Base.Church.N20 }
Base.Church.N22 : Base.Church.Nat { Base.Church.succ Base.Church.N21 }
Base.Church.N23 : Base.Church.Nat { Base.Church.succ Base.Church.N22 }
Base.Church.N24 : Base.Church.Nat { Base.Church.succ Base.Church.N23 }
Base.Church.N25 : Base.Church.Nat { Base.Church.succ Base.Church.N24 }
Base.Church.N26 : Base.Church.Nat { Base.Church.succ Base.Church.N25 }
Base.Church.N27 : Base.Church.Nat { Base.Church.succ Base.Church.N26 }
Base.Church.N28 : Base.Church.Nat { Base.Church.succ Base.Church.N27 }
Base.Church.N29 : Base.Church.Nat { Base.Church.succ Base.Church.N28 }
Base.Church.N30 : Base.Church.Nat { Base.Church.succ Base.Church.N29 }
Base.Church.N31 : Base.Church.Nat { Base.Church.succ Base.Church.N30 }
Base.Church.N32 : Base.Church.Nat { Base.Church.succ Base.Church.N31 }
Base { 0 }
Size : Base.Church.Nat
Size = Base.Church.N15
Main : Base.Equal (Base.Church.to_u60 (Base.Church.exp Base.Church.N2 Size)) 32768
Main = Base.refl

View File

@ -1,2 +0,0 @@
All terms check.

View File

@ -1,179 +0,0 @@
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))))))))
Unit : Type
Kind.Checker (a: Type) : Type
Kind.Checker a = ((_: (Kind.Context)) ((_: U60) ((_: (Bool)) ((_: (Kind.Subst)) ((_: (List (Kind.Equation))) ((_: (List (Kind.Error))) (Kind.Result a)))))))
Bool : Type
Kind.Equation : Type
Kind.Error : Type
Kind.Context : Type
Kind.Subst : Type
List (t: Type) : Type
Kind.Result (a: Type) : Type
Kind.Result.checked <a: Type> (ctx: (Kind.Context)) (depth: U60) (rhs: (Bool)) (sub: (Kind.Subst)) (equations: (List (Kind.Equation))) (errors: (List (Kind.Error))) (ret: a) : (Kind.Result a)
Kind.Term : Type
Kind.Term.typ (orig: U60) : (Kind.Term)
Kind.Term.hol (orig: U60) (number: U60) : (Kind.Term)
Kind.Term.var (orig: U60) (name: U60) (index: U60) : (Kind.Term)
Kind.Term.all (orig: U60) (name: U60) (typ: (Kind.Term)) (body: ((_: (Kind.Term)) (Kind.Term))) : (Kind.Term)
Kind.Term.lam (orig: U60) (name: U60) (body: ((_: (Kind.Term)) (Kind.Term))) : (Kind.Term)
Kind.Term.app (orig: U60) (func: (Kind.Term)) (arg: (Kind.Term)) : (Kind.Term)
Kind.Term.let (orig: U60) (name: U60) (expr: (Kind.Term)) (body: ((_: (Kind.Term)) (Kind.Term))) : (Kind.Term)
Kind.Term.ann (orig: U60) (expr: (Kind.Term)) (typ: (Kind.Term)) : (Kind.Term)
Kind.Term.sub (orig: U60) (name: U60) (indx: U60) (redx: U60) (expr: (Kind.Term)) : (Kind.Term)
Kind.Term.ct0 (ctid: U60) (orig: U60) : (Kind.Term)
Kind.Term.ct1 (ctid: U60) (orig: U60) (x0: (Kind.Term)) : (Kind.Term)
Kind.Term.ct2 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) : (Kind.Term)
Kind.Term.ct3 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) : (Kind.Term)
Kind.Term.ct4 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) : (Kind.Term)
Kind.Term.ct5 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) : (Kind.Term)
Kind.Term.ct6 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) : (Kind.Term)
Kind.Term.ct7 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) : (Kind.Term)
Kind.Term.ct8 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) : (Kind.Term)
Kind.Term.ct9 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) : (Kind.Term)
Kind.Term.ct10 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) : (Kind.Term)
Kind.Term.ct11 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) : (Kind.Term)
Kind.Term.ct12 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) (x11: (Kind.Term)) : (Kind.Term)
Kind.Term.ct13 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) (x11: (Kind.Term)) (x12: (Kind.Term)) : (Kind.Term)
Kind.Term.ct14 (ctid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) (x11: (Kind.Term)) (x12: (Kind.Term)) (x13: (Kind.Term)) : (Kind.Term)
Kind.Term.ct15 (ctid: U60) (orig: U60) (args: (Kind.Term)) : (Kind.Term)
Kind.Term.ct16 (ctid: U60) (orig: U60) (args: (Kind.Term)) : (Kind.Term)
Kind.Term.fn0 (fnid: U60) (orig: U60) : (Kind.Term)
Kind.Term.fn1 (fnid: U60) (orig: U60) (x0: (Kind.Term)) : (Kind.Term)
Kind.Term.fn2 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) : (Kind.Term)
Kind.Term.fn3 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) : (Kind.Term)
Kind.Term.fn4 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) : (Kind.Term)
Kind.Term.fn5 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) : (Kind.Term)
Kind.Term.fn6 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) : (Kind.Term)
Kind.Term.fn7 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) : (Kind.Term)
Kind.Term.fn8 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) : (Kind.Term)
Kind.Term.fn9 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) : (Kind.Term)
Kind.Term.fn10 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) : (Kind.Term)
Kind.Term.fn11 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) : (Kind.Term)
Kind.Term.fn12 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) (x11: (Kind.Term)) : (Kind.Term)
Kind.Term.fn13 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) (x11: (Kind.Term)) (x12: (Kind.Term)) : (Kind.Term)
Kind.Term.fn14 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) (x11: (Kind.Term)) (x12: (Kind.Term)) (x13: (Kind.Term)) : (Kind.Term)
Kind.Term.fn15 (fnid: U60) (orig: U60) (args: (Kind.Term)) : (Kind.Term)
Kind.Term.fn16 (fnid: U60) (orig: U60) (args: (Kind.Term)) : (Kind.Term)
Kind.Term.FN0 (fnid: U60) (orig: U60) : (Kind.Term)
Kind.Term.FN1 (fnid: U60) (orig: U60) (x0: (Kind.Term)) : (Kind.Term)
Kind.Term.FN2 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) : (Kind.Term)
Kind.Term.FN3 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) : (Kind.Term)
Kind.Term.FN4 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) : (Kind.Term)
Kind.Term.FN5 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) : (Kind.Term)
Kind.Term.FN6 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) : (Kind.Term)
Kind.Term.FN7 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) : (Kind.Term)
Kind.Term.FN8 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) : (Kind.Term)
Kind.Term.FN9 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) : (Kind.Term)
Kind.Term.FN10 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) : (Kind.Term)
Kind.Term.FN11 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) : (Kind.Term)
Kind.Term.FN12 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) (x11: (Kind.Term)) : (Kind.Term)
Kind.Term.FN13 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) (x11: (Kind.Term)) (x12: (Kind.Term)) : (Kind.Term)
Kind.Term.FN14 (fnid: U60) (orig: U60) (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) (x11: (Kind.Term)) (x12: (Kind.Term)) (x13: (Kind.Term)) : (Kind.Term)
Kind.Term.FN15 (fnid: U60) (orig: U60) (args: (Kind.Term)) : (Kind.Term)
Kind.Term.FN16 (fnid: U60) (orig: U60) (args: (Kind.Term)) : (Kind.Term)
Kind.Term.hlp (orig: U60) : (Kind.Term)
Kind.Term.u60 (orig: U60) : (Kind.Term)
Kind.Term.num (orig: U60) (num: U60) : (Kind.Term)
Kind.Term.op2 (orig: U60) (operator: (Kind.Operator)) (left: (Kind.Term)) (right: (Kind.Term)) : (Kind.Term)
Kind.Term.args15 (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) (x11: (Kind.Term)) (x12: (Kind.Term)) (x13: (Kind.Term)) (x14: (Kind.Term)) : (Kind.Term)
Kind.Term.args16 (x0: (Kind.Term)) (x1: (Kind.Term)) (x2: (Kind.Term)) (x3: (Kind.Term)) (x4: (Kind.Term)) (x5: (Kind.Term)) (x6: (Kind.Term)) (x7: (Kind.Term)) (x8: (Kind.Term)) (x9: (Kind.Term)) (x10: (Kind.Term)) (x11: (Kind.Term)) (x12: (Kind.Term)) (x13: (Kind.Term)) (x14: (Kind.Term)) (x15: (Kind.Term)) : (Kind.Term)
Kind.Operator : Type
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.Subst.end : (Kind.Subst)
Kind.Subst.unfilled (rest: (Kind.Subst)) : (Kind.Subst)
Kind.Subst.sub (term: (Kind.Term)) (rest: (Kind.Subst)) : (Kind.Subst)
Unit.new : (Unit)

View File

@ -1,2 +0,0 @@
All terms check.

View File

@ -1,6 +0,0 @@
String : Type
String.cons (head: U60) (tail: String) : String
String.nil : String
Main.hello : String
Main.hello = "Hello, World"

View File

@ -1,2 +0,0 @@
All terms check.

View File

@ -1,7 +0,0 @@
// We should open an issue for this?
Arity3 -(e: U60) -(f: U60) <g> <h> <i> (d: U60) : U60
Arity3 e f g h i d = d
Arity2 -(e: U60) -(f: U60) <g> <h> <i> (d: U60) : U60
Arity2 d = d

View File

@ -1,5 +0,0 @@
Inspection.
- Goal: U60
On '{{#F0F#}}':
{{#R0:20:21R#}}

View File

@ -1,3 +0,0 @@
Main : U60
Main =
?

Some files were not shown because too many files have changed in this diff Show More