Cicada Language Manual
Installation
Introduction
Basic
Built-in Types
Module
Import
Datatypes
Natural Number
Proving Theorems About Nat
List
Vector
Either
Relations
List Length
List Append
Equality
Equal Utilities
Class
Class and Object
Inheritance
Fulfilling Type
Mathematical Structure as Class
Implicit and Vague
Implicit Arguments
Vague Arguments
Structures
Group Theory
Category Theory
Initial and Terminal Objects
Groupoid Theory
Order Theory
Bishop's Set Theory
Boolean Lattice
Univalent
Univalent Axiom
TODO
Group Category
Semigroup with Built-in Associative
Order Theory
List Length
#
ListLength
import { List } from "../datatypes/list.md" import { Nat } from "../datatypes/nat.md"
datatype ListLength(E: Type) (list: List(E), length: Nat) { null_zero: ListLength(E, List.null, Nat.zero) cons_add1( head: E, tail: List(E), prev: Nat, tail_length: ListLength(E, tail, prev), ): ListLength(E, List.cons(head, tail), Nat.add1(prev)) }
check ListLength.null_zero: ListLength(Trivial, List.null, Nat.zero) check ListLength.cons_add1( sole, List.null, Nat.zero, ListLength.null_zero, ): ListLength(Trivial, List.cons(sole, List.null), Nat.add1(Nat.zero))
#
map
_
keep
_
list
_
length
import { map } from "../datatypes/list.md" function map_keep_list_length( implicit E: Type, list: List(E), length: Nat, list_length: ListLength(E, list, length), implicit R: Type, f: (E) -> R, ): ListLength(R, map(list, f), length) { return induction (list_length) { motive (list, length, target) => ListLength(R, map(list, f), length) case null_zero => ListLength.null_zero case cons_add1(head, tail, prev, _tail_length, almost) => ListLength.cons_add1(f(head), map(tail, f), prev, almost.tail_length) } }
Either
List Append
List Length
#
ListLength
import { List } from "../datatypes/list.md" import { Nat } from "../datatypes/nat.md"
datatype ListLength(E: Type) (list: List(E), length: Nat) { null_zero: ListLength(E, List.null, Nat.zero) cons_add1( head: E, tail: List(E), prev: Nat, tail_length: ListLength(E, tail, prev), ): ListLength(E, List.cons(head, tail), Nat.add1(prev)) }
check ListLength.null_zero: ListLength(Trivial, List.null, Nat.zero) check ListLength.cons_add1( sole, List.null, Nat.zero, ListLength.null_zero, ): ListLength(Trivial, List.cons(sole, List.null), Nat.add1(Nat.zero))
#
map
_
keep
_
list
_
length
import { map } from "../datatypes/list.md" function map_keep_list_length( implicit E: Type, list: List(E), length: Nat, list_length: ListLength(E, list, length), implicit R: Type, f: (E) -> R, ): ListLength(R, map(list, f), length) { return induction (list_length) { motive (list, length, target) => ListLength(R, map(list, f), length) case null_zero => ListLength.null_zero case cons_add1(head, tail, prev, _tail_length, almost) => ListLength.cons_add1(f(head), map(tail, f), prev, almost.tail_length) } }
Either
List Append