Lean2Js.Core
The syntax of the Lean subset destined for JavaScript #
Holds the syntax of the Lean subset destined for JavaScript as a standalone AST inside Lean.
This is a deep embedding rather than a reader of ordinary Lean defs because compiler
correctness cannot even be stated without holding the source language's semantics in our own hands.
Lean2Js.Core.Ty
sourceThe types that may sit on the boundary of the public API. Only those whose JS representation is uniquely determined are listed.
var stands for a type parameter and is only ever written inside the field types of the TypeDef that
declares it; every type reaching a boundary has had its parameters substituted away.
option and result stay built in even though a user could now declare them, because the subset has
literal syntax for their constructors and the generated runtime checks them by shape. Expressing them as
declarations would remove neither special case.
Instances For
Used by
Lean2Js.Core.instReprTy.repr
sourceUsed by
Lean2Js.Core.instReprTy
sourceEquations
- Lean2Js.Core.instReprTy = { reprPrec := Lean2Js.Core.instReprTy.repr }
Used by
Lean2Js.Core.instInhabitedTy
sourceEquations
Used by
Lean2Js.Core.Ty.beq
sourceWritten out rather than derived so that Ty.eq_of_beq can be proved: Ty nests a List Ty, and
neither DecidableEq nor LawfulBEq derives through that. Recursing through a list helper keeps it
structural, so a type comparison still closes by rfl.
Equations
- Lean2Js.Core.Ty.bool.beq Lean2Js.Core.Ty.bool = true
- Lean2Js.Core.Ty.int53.beq Lean2Js.Core.Ty.int53 = true
- Lean2Js.Core.Ty.uint32.beq Lean2Js.Core.Ty.uint32 = true
- Lean2Js.Core.Ty.string.beq Lean2Js.Core.Ty.string = true
- Lean2Js.Core.Ty.bigint.beq Lean2Js.Core.Ty.bigint = true
- (Lean2Js.Core.Ty.var a).beq (Lean2Js.Core.Ty.var b) = (a == b)
- (Lean2Js.Core.Ty.named n as).beq (Lean2Js.Core.Ty.named m bs) = (n == m && Lean2Js.Core.Ty.beqList as bs)
- a.option.beq b.option = a.beq b
- (a₁.result a₂).beq (b₁.result b₂) = (a₁.beq b₁ && a₂.beq b₂)
- a.array.beq b.array = a.beq b
- a.dict.beq b.dict = a.beq b
- a.dictObj.beq b.dictObj = a.beq b
- (Lean2Js.Core.Ty.fn as a).beq (Lean2Js.Core.Ty.fn bs b) = (Lean2Js.Core.Ty.beqList as bs && a.beq b)
- x✝¹.beq x✝ = false
Instances For
Used by
Lean2Js.Core.Ty.beqList
sourceEquations
- Lean2Js.Core.Ty.beqList [] [] = true
- Lean2Js.Core.Ty.beqList (a :: as) (b :: bs) = (a.beq b && Lean2Js.Core.Ty.beqList as bs)
- Lean2Js.Core.Ty.beqList x✝¹ x✝ = false
Instances For
Used by
Lean2Js.Core.instBEqTy
sourceEquations
- Lean2Js.Core.instBEqTy = { beq := Lean2Js.Core.Ty.beq }
Used by
Lean2Js.Core.Ty.beq_refl
sourceUsed by
Lean2Js.Core.Ty.beqList_refl
sourceUsed by
Lean2Js.Core.Ty.eq_of_beq
sourceWritten out for the reason Ty.beq is: a type comparison is what ties the knot in a recursive
descriptor, and the knot has to be tied on equality rather than on a Bool nothing reads back.
Used by
Lean2Js.Core.Ty.eq_of_beqList
sourceUsed by
Lean2Js.Core.instLawfulBEqTy
sourceUsed by
Lean2Js.Core.Ty.size
sourceA node count, used to bound how far a type can be expanded. sizeOf would say the same thing, but its
derived instance is noncomputable and this number is computed while compiling.
Equations
- Lean2Js.Core.Ty.bool.size = 1
- Lean2Js.Core.Ty.int53.size = 1
- Lean2Js.Core.Ty.uint32.size = 1
- Lean2Js.Core.Ty.string.size = 1
- Lean2Js.Core.Ty.bigint.size = 1
- (Lean2Js.Core.Ty.var a).size = 1
- (Lean2Js.Core.Ty.named a a_1).size = 1 + Lean2Js.Core.Ty.sizeList a_1
- a.option.size = 1 + a.size
- (a.result a_1).size = 1 + a.size + a_1.size
- a.array.size = 1 + a.size
- a.dict.size = 1 + a.size
- a.dictObj.size = 1 + a.size
- (Lean2Js.Core.Ty.fn a a_1).size = 1 + Lean2Js.Core.Ty.sizeList a + a_1.size
Instances For
Used by
Lean2Js.Core.Ty.sizeList
sourceEquations
- Lean2Js.Core.Ty.sizeList [] = 0
- Lean2Js.Core.Ty.sizeList (t :: ts) = t.size + Lean2Js.Core.Ty.sizeList ts
Instances For
Used by
Lean2Js.Core.Ty.render
sourceEquations
- Lean2Js.Core.Ty.bool.render = "Bool"
- Lean2Js.Core.Ty.int53.render = "Int53"
- Lean2Js.Core.Ty.uint32.render = "UInt32"
- Lean2Js.Core.Ty.string.render = "String"
- Lean2Js.Core.Ty.bigint.render = "BigInt"
- (Lean2Js.Core.Ty.var a).render = a
- (Lean2Js.Core.Ty.named a a_1).render = a ++ Lean2Js.Core.Ty.renderArgs a_1
- a.option.render = "Option " ++ a.render
- (a.result a_1).render = "Result " ++ a.render ++ " " ++ a_1.render
- a.array.render = "Array " ++ a.render
- a.dict.render = "Dict " ++ a.render
- a.dictObj.render = "Dict.Obj " ++ a.render
- (Lean2Js.Core.Ty.fn a a_1).render = "(" ++ Lean2Js.Core.Ty.renderParams a ++ ") => " ++ a_1.render
Instances For
Used by
Lean2Js.Core.Ty.renderArgs
sourceEach argument carries its own leading space rather than being joined by one, so that a name applied to nothing renders as the bare name without a case split on the list.
Equations
- Lean2Js.Core.Ty.renderArgs [] = ""
- Lean2Js.Core.Ty.renderArgs (t :: ts) = " " ++ t.render ++ Lean2Js.Core.Ty.renderArgs ts
Instances For
Used by
Lean2Js.Core.Ty.renderParams
sourceEquations
Instances For
Used by
Lean2Js.Core.Ty.renderParamsRest
sourceEquations
- Lean2Js.Core.Ty.renderParamsRest [] = ""
- Lean2Js.Core.Ty.renderParamsRest (t :: ts) = ", " ++ t.render ++ Lean2Js.Core.Ty.renderParamsRest ts
Instances For
Used by
Lean2Js.Core.Ty.subst
sourceReplaces a declaration's type parameters with the arguments it was applied to. Recursing through a
list helper rather than args.map keeps this out of partial, which a proof about a declaration cannot
unfold.
Equations
- One or more equations did not get rendered due to their size.
- Lean2Js.Core.Ty.subst sigma (Lean2Js.Core.Ty.named n args) = Lean2Js.Core.Ty.named n (Lean2Js.Core.Ty.substArgs sigma args)
- Lean2Js.Core.Ty.subst sigma t.option = (Lean2Js.Core.Ty.subst sigma t).option
- Lean2Js.Core.Ty.subst sigma (ok.result err) = (Lean2Js.Core.Ty.subst sigma ok).result (Lean2Js.Core.Ty.subst sigma err)
- Lean2Js.Core.Ty.subst sigma t.array = (Lean2Js.Core.Ty.subst sigma t).array
- Lean2Js.Core.Ty.subst sigma v.dict = (Lean2Js.Core.Ty.subst sigma v).dict
- Lean2Js.Core.Ty.subst sigma v.dictObj = (Lean2Js.Core.Ty.subst sigma v).dictObj
- Lean2Js.Core.Ty.subst sigma (Lean2Js.Core.Ty.fn params ret) = Lean2Js.Core.Ty.fn (Lean2Js.Core.Ty.substArgs sigma params) (Lean2Js.Core.Ty.subst sigma ret)
- Lean2Js.Core.Ty.subst sigma x✝ = x✝
Instances For
Used by
Lean2Js.Core.Ty.substArgs
sourceEquations
- Lean2Js.Core.Ty.substArgs sigma [] = []
- Lean2Js.Core.Ty.substArgs sigma (t :: ts) = Lean2Js.Core.Ty.subst sigma t :: Lean2Js.Core.Ty.substArgs sigma ts
Instances For
Used by
Lean2Js.Core.Ty.isFn
sourceInstances For
Used by
Lean2Js.Core.Ty.noDictObj
sourceWhether a type's own shape reaches no dictObj. Written through a list helper rather than
args.all for the reason Ty.beq is: a structural recursion is what a proof can unfold.
This says nothing about what a named type's fields hold — those come from the program, not from the
type — so the reading a proof needs is this together with Program.noDictObj.
Equations
- Lean2Js.Core.Ty.bool.noDictObj = true
- Lean2Js.Core.Ty.int53.noDictObj = true
- Lean2Js.Core.Ty.uint32.noDictObj = true
- Lean2Js.Core.Ty.string.noDictObj = true
- Lean2Js.Core.Ty.bigint.noDictObj = true
- (Lean2Js.Core.Ty.var a).noDictObj = true
- (Lean2Js.Core.Ty.named a a_1).noDictObj = Lean2Js.Core.Ty.noDictObjList a_1
- a.option.noDictObj = a.noDictObj
- (a.result a_1).noDictObj = (a.noDictObj && a_1.noDictObj)
- a.array.noDictObj = a.noDictObj
- a.dict.noDictObj = a.noDictObj
- a.dictObj.noDictObj = false
- (Lean2Js.Core.Ty.fn a a_1).noDictObj = (Lean2Js.Core.Ty.noDictObjList a && a_1.noDictObj)
Instances For
Used by
Lean2Js.Core.Ty.noDictObjList
sourceEquations
Instances For
Used by
Lean2Js.Core.Ty.noDictObj_subst
sourceSubstituting types that reach no dictObj into a type that reaches none leaves one that reaches
none. This is what carries Ty.noDictObj through TypeDef.ctorsAt, which is the only place a field's
type is read at a use of the type it belongs to.
Used by
Lean2Js.Core.Ty.noDictObjList_substArgs
sourceUsed by
Lean2Js.Core.Ty.noDictObj_zip
sourceThe types a substitution puts in reach no dictObj when the arguments it was built from reach
none. TypeDef.ctorsAt builds its substitution by zipping the declared parameters against them.
Used by
Lean2Js.Core.Lit
sourceInstances For
Used by
Lean2Js.Core.instReprLit.repr
sourceEquations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.Core.instReprLit
sourceEquations
- Lean2Js.Core.instReprLit = { reprPrec := Lean2Js.Core.instReprLit.repr }
Used by
Lean2Js.Core.instBEqLit
sourceEquations
Used by
Lean2Js.Core.instBEqLit.beq
sourceEquations
- Lean2Js.Core.instBEqLit.beq (Lean2Js.Core.Lit.bool a) (Lean2Js.Core.Lit.bool b) = (a == b)
- Lean2Js.Core.instBEqLit.beq (Lean2Js.Core.Lit.int53 a) (Lean2Js.Core.Lit.int53 b) = (a == b)
- Lean2Js.Core.instBEqLit.beq (Lean2Js.Core.Lit.uint32 a) (Lean2Js.Core.Lit.uint32 b) = (a == b)
- Lean2Js.Core.instBEqLit.beq (Lean2Js.Core.Lit.str a) (Lean2Js.Core.Lit.str b) = (a == b)
- Lean2Js.Core.instBEqLit.beq (Lean2Js.Core.Lit.bigint a) (Lean2Js.Core.Lit.bigint b) = (a == b)
- Lean2Js.Core.instBEqLit.beq x✝¹ x✝ = false
Instances For
Used by
Lean2Js.Core.instInhabitedLit
sourceEquations
Used by
Lean2Js.Core.UnOp
sourceInstances For
Used by
Lean2Js.Core.instReprUnOp
sourceEquations
- Lean2Js.Core.instReprUnOp = { reprPrec := Lean2Js.Core.instReprUnOp.repr }
Used by
Lean2Js.Core.instReprUnOp.repr
sourceEquations
- Lean2Js.Core.instReprUnOp.repr Lean2Js.Core.UnOp.not prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.Core.UnOp.not")).group prec✝
- Lean2Js.Core.instReprUnOp.repr Lean2Js.Core.UnOp.neg prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.Core.UnOp.neg")).group prec✝
- Lean2Js.Core.instReprUnOp.repr Lean2Js.Core.UnOp.abs prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.Core.UnOp.abs")).group prec✝
- Lean2Js.Core.instReprUnOp.repr Lean2Js.Core.UnOp.toString prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.Core.UnOp.toString")).group prec✝
- Lean2Js.Core.instReprUnOp.repr Lean2Js.Core.UnOp.range prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.Core.UnOp.range")).group prec✝
Instances For
Used by
Lean2Js.Core.instBEqUnOp
sourceEquations
Used by
Lean2Js.Core.instBEqUnOp.beq
sourceEquations
- Lean2Js.Core.instBEqUnOp.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Used by
Lean2Js.Core.instInhabitedUnOp
sourceEquations
Used by
Lean2Js.Core.BinOp
sourceInstances For
Used by
Lean2Js.Core.instReprBinOp.repr
sourceEquations
- Lean2Js.Core.instReprBinOp.repr Lean2Js.Core.BinOp.add prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.Core.BinOp.add")).group prec✝
- Lean2Js.Core.instReprBinOp.repr Lean2Js.Core.BinOp.sub prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.Core.BinOp.sub")).group prec✝
- Lean2Js.Core.instReprBinOp.repr Lean2Js.Core.BinOp.mul prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.Core.BinOp.mul")).group prec✝
- Lean2Js.Core.instReprBinOp.repr Lean2Js.Core.BinOp.div prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.Core.BinOp.div")).group prec✝
- Lean2Js.Core.instReprBinOp.repr Lean2Js.Core.BinOp.mod prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.Core.BinOp.mod")).group prec✝
- Lean2Js.Core.instReprBinOp.repr Lean2Js.Core.BinOp.min prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.Core.BinOp.min")).group prec✝
- Lean2Js.Core.instReprBinOp.repr Lean2Js.Core.BinOp.max prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.Core.BinOp.max")).group prec✝
- Lean2Js.Core.instReprBinOp.repr Lean2Js.Core.BinOp.lt prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.Core.BinOp.lt")).group prec✝
- Lean2Js.Core.instReprBinOp.repr Lean2Js.Core.BinOp.le prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.Core.BinOp.le")).group prec✝
- Lean2Js.Core.instReprBinOp.repr Lean2Js.Core.BinOp.gt prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.Core.BinOp.gt")).group prec✝
- Lean2Js.Core.instReprBinOp.repr Lean2Js.Core.BinOp.ge prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.Core.BinOp.ge")).group prec✝
- Lean2Js.Core.instReprBinOp.repr Lean2Js.Core.BinOp.eq prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.Core.BinOp.eq")).group prec✝
- Lean2Js.Core.instReprBinOp.repr Lean2Js.Core.BinOp.ne prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.Core.BinOp.ne")).group prec✝
- Lean2Js.Core.instReprBinOp.repr Lean2Js.Core.BinOp.and prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.Core.BinOp.and")).group prec✝
- Lean2Js.Core.instReprBinOp.repr Lean2Js.Core.BinOp.or prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.Core.BinOp.or")).group prec✝
- Lean2Js.Core.instReprBinOp.repr Lean2Js.Core.BinOp.concat prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.Core.BinOp.concat")).group prec✝
Instances For
Used by
Lean2Js.Core.instReprBinOp
sourceEquations
- Lean2Js.Core.instReprBinOp = { reprPrec := Lean2Js.Core.instReprBinOp.repr }
Used by
Lean2Js.Core.instBEqBinOp.beq
sourceEquations
- Lean2Js.Core.instBEqBinOp.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Used by
Lean2Js.Core.instBEqBinOp
sourceEquations
Used by
Lean2Js.Core.instInhabitedBinOp
sourceEquations
Used by
Lean2Js.Core.StrUnOp
sourceThe string operations that take only the string. length is not here: an Array has one too, so the
two share Expr.length.
Instances For
Used by
Lean2Js.Core.instReprStrUnOp.repr
sourceEquations
- One or more equations did not get rendered due to their size.
- Lean2Js.Core.instReprStrUnOp.repr Lean2Js.Core.StrUnOp.trim prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.Core.StrUnOp.trim")).group prec✝
Instances For
Used by
Lean2Js.Core.instReprStrUnOp
sourceEquations
- Lean2Js.Core.instReprStrUnOp = { reprPrec := Lean2Js.Core.instReprStrUnOp.repr }
Used by
Lean2Js.Core.instBEqStrUnOp
sourceEquations
Used by
Lean2Js.Core.instBEqStrUnOp.beq
sourceEquations
- Lean2Js.Core.instBEqStrUnOp.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Used by
Lean2Js.Core.instInhabitedStrUnOp
sourceEquations
Used by
Lean2Js.Core.StrBinOp
sourceInstances For
Used by
Lean2Js.Core.instReprStrBinOp
sourceEquations
Used by
Lean2Js.Core.instReprStrBinOp.repr
sourceEquations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.Core.instBEqStrBinOp
sourceEquations
Used by
Lean2Js.Core.instBEqStrBinOp.beq
sourceEquations
- Lean2Js.Core.instBEqStrBinOp.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Used by
Lean2Js.Core.instInhabitedStrBinOp
sourceEquations
Used by
Lean2Js.Core.StrUnOp.name
sourceEquations
- Lean2Js.Core.StrUnOp.trim.name = "trim"
- Lean2Js.Core.StrUnOp.upper.name = "toUpper"
- Lean2Js.Core.StrUnOp.lower.name = "toLower"
- Lean2Js.Core.StrUnOp.toInt.name = "toInt"
Instances For
Used by
Lean2Js.Core.StrBinOp.name
sourceEquations
- Lean2Js.Core.StrBinOp.startsWith.name = "startsWith"
- Lean2Js.Core.StrBinOp.endsWith.name = "endsWith"
- Lean2Js.Core.StrBinOp.includes.name = "includes"
- Lean2Js.Core.StrBinOp.split.name = "split"
- Lean2Js.Core.StrBinOp.indexOf.name = "indexOf"
- Lean2Js.Core.StrBinOp.join.name = "join"
- Lean2Js.Core.StrBinOp.repeat.name = "repeat"
Instances For
Used by
Lean2Js.Core.QuantOp
sourceall and any differ only in which answer ends the walk, so they share one form. find does not
join them: it answers with the element rather than with a Bool.
Instances For
Used by
Lean2Js.Core.instReprQuantOp
sourceEquations
- Lean2Js.Core.instReprQuantOp = { reprPrec := Lean2Js.Core.instReprQuantOp.repr }
Used by
Lean2Js.Core.instReprQuantOp.repr
sourceEquations
- Lean2Js.Core.instReprQuantOp.repr Lean2Js.Core.QuantOp.all prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.Core.QuantOp.all")).group prec✝
- Lean2Js.Core.instReprQuantOp.repr Lean2Js.Core.QuantOp.any prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Lean2Js.Core.QuantOp.any")).group prec✝
Instances For
Used by
Lean2Js.Core.instBEqQuantOp
sourceEquations
Used by
Lean2Js.Core.instBEqQuantOp.beq
sourceEquations
- Lean2Js.Core.instBEqQuantOp.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Used by
Lean2Js.Core.instInhabitedQuantOp
sourceEquations
Used by
Lean2Js.Core.QuantOp.name
sourceEquations
- Lean2Js.Core.QuantOp.all.name = "all"
- Lean2Js.Core.QuantOp.any.name = "any"
Instances For
Used by
Lean2Js.Core.Pat
sourceWhat one match arm tests the scrutinee against. Nesting is what lets a rule branch on a combination
— a state together with a role — instead of one constructor at a time, and a wildcard is what lets it
name the combinations it cares about and leave the rest to a fallback.
bind and wild differ only in whether the value is given a name; the exhaustiveness check treats them
alike.
Instances For
Used by
Lean2Js.Core.instReprPat
sourceEquations
- Lean2Js.Core.instReprPat = { reprPrec := Lean2Js.Core.instReprPat.repr }
Used by
Lean2Js.Core.instReprPat.repr
sourceUsed by
Lean2Js.Core.instBEqPat.beq
sourceUsed by
Lean2Js.Core.instBEqPat
sourceEquations
Used by
Lean2Js.Core.instInhabitedPat
sourceEquations
Used by
Lean2Js.Core.Expr
sourceFor none and error / ok one side's type is not determined by the term, so the syntax carries an
annotation.
The array combinators carry their binder and body rather than taking a function, so no value in the subset is ever a function.
Instances For
Used by
Lean2Js.Core.instReprExpr.repr
sourceUsed by
Lean2Js.Core.instReprExpr
sourceEquations
- Lean2Js.Core.instReprExpr = { reprPrec := Lean2Js.Core.instReprExpr.repr }
Used by
Lean2Js.Core.instBEqExpr.beq
sourceUsed by
Lean2Js.Core.instBEqExpr
sourceEquations
Used by
Lean2Js.Core.instInhabitedExpr
sourceEquations
Used by
Lean2Js.Core.Alt
sourceEquations
Instances For
Used by
Lean2Js.Core.Alt.pat
sourceInstances For
Used by
Lean2Js.Core.Alt.body
sourceInstances For
Used by
Lean2Js.Core.FoldKind
sourceHow a fold carries one of a constructor's fields: the declared type coming round, a list of it coming round, or neither.
Instances For
Used by
Lean2Js.Core.instReprFoldKind
sourceEquations
Used by
Lean2Js.Core.instReprFoldKind.repr
sourceEquations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.Core.instBEqFoldKind.beq
sourceEquations
- Lean2Js.Core.instBEqFoldKind.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Used by
Lean2Js.Core.instBEqFoldKind
sourceEquations
Used by
Lean2Js.Core.instInhabitedFoldKind
sourceEquations
Used by
Lean2Js.Core.instDecidableEqFoldKind
sourceEquations
Used by
Lean2Js.Core.foldKindOf
sourceWhich of a constructor's fields a fold over typeName tyArgs goes into, read off the field's own
declared type. This is the one test: the evaluator walks by it and the emitter writes its spec from it,
so the two cannot disagree about which field comes round.
Only the type at the same arguments comes round. Tree Int inside Tree String is a different type and
a fold over one does not descend into the other.
Equations
- Lean2Js.Core.foldKindOf typeName tyArgs (Lean2Js.Core.Ty.named n as) = if (n == typeName && as == tyArgs) = true then Lean2Js.Core.FoldKind.self else Lean2Js.Core.FoldKind.plain
- Lean2Js.Core.foldKindOf typeName tyArgs (Lean2Js.Core.Ty.named n as).array = if (n == typeName && as == tyArgs) = true then Lean2Js.Core.FoldKind.list else Lean2Js.Core.FoldKind.plain
- Lean2Js.Core.foldKindOf typeName tyArgs x✝ = Lean2Js.Core.FoldKind.plain
Instances For
Used by
Lean2Js.Core.Param
sourceInstances For
Used by
Lean2Js.Core.instReprParam.repr
sourceEquations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.Core.instReprParam
sourceEquations
- Lean2Js.Core.instReprParam = { reprPrec := Lean2Js.Core.instReprParam.repr }
Used by
Lean2Js.Core.instBEqParam
sourceEquations
Used by
Lean2Js.Core.instBEqParam.beq
sourceEquations
Instances For
Used by
Lean2Js.Core.instInhabitedParam
sourceEquations
Used by
Lean2Js.Core.Field
sourceInstances For
Used by
Lean2Js.Core.instReprField.repr
sourceEquations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.Core.instReprField
sourceEquations
- Lean2Js.Core.instReprField = { reprPrec := Lean2Js.Core.instReprField.repr }
Used by
Lean2Js.Core.instBEqField.beq
sourceEquations
Instances For
Used by
Lean2Js.Core.instBEqField
sourceEquations
Used by
Lean2Js.Core.instInhabitedField
sourceEquations
Used by
Lean2Js.Core.CtorDef
sourceInstances For
Used by
Lean2Js.Core.instReprCtorDef
sourceEquations
- Lean2Js.Core.instReprCtorDef = { reprPrec := Lean2Js.Core.instReprCtorDef.repr }
Used by
Lean2Js.Core.instReprCtorDef.repr
sourceEquations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.Core.instBEqCtorDef
sourceEquations
Used by
Lean2Js.Core.instBEqCtorDef.beq
sourceEquations
Instances For
Used by
Lean2Js.Core.instInhabitedCtorDef
sourceEquations
Used by
Lean2Js.Core.TypeDef
sourceA structure / inductive declared by the user. The single-constructor ones are the structures.
params names the type parameters that the field types may mention as Ty.var.
discriminator is the key the generated JavaScript tells this type's constructors apart by: tag
unless the author wrote @[discriminator "..."] above the type.
Instances For
Used by
Lean2Js.Core.instReprTypeDef
sourceEquations
- Lean2Js.Core.instReprTypeDef = { reprPrec := Lean2Js.Core.instReprTypeDef.repr }
Used by
Lean2Js.Core.instReprTypeDef.repr
sourceEquations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.Core.instBEqTypeDef.beq
sourceEquations
- One or more equations did not get rendered due to their size.
- Lean2Js.Core.instBEqTypeDef.beq x✝¹ x✝ = false
Instances For
Used by
Lean2Js.Core.instBEqTypeDef
sourceEquations
Used by
Lean2Js.Core.instInhabitedTypeDef
sourceEquations
Used by
Lean2Js.Core.builtinCtors
sourceThe constructor names the subset spells itself, in Option and Result. No TypeDef declares
them, so they are carried under tag and a declared type may not key one of them elsewhere.
Instances For
Used by
Lean2Js.Core.Discriminators
sourceWhich key a constructor's name is carried under in the generated JavaScript.
A value the reference semantics returns carries the name of its constructor and not the type it came
from, so the key that name is written with has to be decided by the name alone. The compiler and
encodeValue both read it from here, which is what makes the two write the same object;
Compile.validateType is what checks this reading against what each type declares.
The two laws are what the generated code needs of a key wherever it is written rather than read off a
type, so they are carried here and not asked again at each use. Program.discriminators? is where a
program's own reading is checked against them.
A key is written as a property, so it has to be a name the generated code may write.
OptionandResultare written by the subset itself, undertag.
Instances
Used by
The law spelled out for each of the four, so that a proof about Option or Result meets tag
where it expects it.
Lean2Js.Core.keyFor_none
sourceUsed by
Lean2Js.Core.keyFor_some
sourceUsed by
Lean2Js.Core.keyFor_ok
sourceUsed by
Lean2Js.Core.keyFor_error
sourceUsed by
Lean2Js.Core.TypeDef.find?
sourceEquations
- t.find? ctor = List.find? (fun (x : Lean2Js.Core.CtorDef) => x.name == ctor) t.ctors
Instances For
Used by
Lean2Js.Core.TypeDef.ctorsAt
sourceThe constructors as seen by a use of the type at args. Every lookup that reads a field's type
rather than its name goes through here; reading a name back does not need the substitution.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.Core.TypeDef.findAt?
sourceEquations
- t.findAt? args ctor = List.find? (fun (x : Lean2Js.Core.CtorDef) => x.name == ctor) (t.ctorsAt args)
Instances For
Used by
Lean2Js.Core.Decl
sourceOne pure function the package carries.
Whether the author meant this declaration to be part of the package's API.
@[ship internal]clears it; a declaration whoseexportedis clear is compiled and callable from the others, and named by neitherindex.js's exports norindex.d.ts.
Instances For
Used by
Lean2Js.Core.instReprDecl
sourceEquations
- Lean2Js.Core.instReprDecl = { reprPrec := Lean2Js.Core.instReprDecl.repr }
Used by
Lean2Js.Core.instReprDecl.repr
sourceEquations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.Core.instBEqDecl
sourceEquations
Used by
Lean2Js.Core.instBEqDecl.beq
sourceEquations
- One or more equations did not get rendered due to their size.
- Lean2Js.Core.instBEqDecl.beq x✝¹ x✝ = false
Instances For
Used by
Lean2Js.Core.instInhabitedDecl
sourceEquations
Used by
Lean2Js.Core.Program
sourceInstances For
Used by
Lean2Js.Core.instReprProgram
sourceEquations
- Lean2Js.Core.instReprProgram = { reprPrec := Lean2Js.Core.instReprProgram.repr }
Used by
Lean2Js.Core.instReprProgram.repr
sourceEquations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.Core.instInhabitedProgram
sourceEquations
Used by
Lean2Js.Core.Decl.paramsCheckable
sourceWhether the entry check has something to read in every parameter. A function value has no shape to
check, so a declaration taking one has nothing to refuse at the boundary — which is what the refusing
direction, the descent and the small-step agreement each ask for, and all they ask for. Named apart from
isPublic because the two answer different questions and a proof wants this one.
Equations
- d.paramsCheckable = d.params.all fun (param : Lean2Js.Core.Param) => !param.ty.isFn
Instances For
Used by
Lean2Js.Core.Decl.isPublic
sourceA declaration crosses the boundary when its author meant it to and the entry check can read its parameters. A declaration that takes a function is internal whatever the author wrote: a function value cannot be checked at the boundary, so one that would need one checked never reaches it at all.
Equations
- d.isPublic = (d.exported && d.paramsCheckable)
Instances For
Used by
Lean2Js.Core.Program.publicDecls
sourceEquations
Instances For
Used by
Lean2Js.Core.TypeDef.noDictObj
sourceWhether a declared type's fields reach no dictObj, read before its parameters are substituted
away. The substitution only ever puts in types the use site wrote, so reading it here is enough.
Equations
- t.noDictObj = t.ctors.all fun (c : Lean2Js.Core.CtorDef) => c.fields.all fun (f : Lean2Js.Core.Field) => f.ty.noDictObj
Instances For
Used by
Lean2Js.Core.Decl.noDictObj
sourceWhether a declaration's boundary reaches no dictObj.
Equations
Instances For
Used by
Lean2Js.Core.Program.typesNoDictObj
sourceWhether no type this program declares reaches a dictObj. This is the half encodeAt reads: it
recurses into a declared type's fields and never into a declaration, so a program may hand a dictionary
across as a plain object and still satisfy this.
Equations
Instances For
Used by
Lean2Js.Core.Program.noDictObj
sourceWhether nothing this program declares crosses the boundary as a plain object.
Every claim written before a dictionary could cross as one holds under this, which is what lets those
claims keep the exact text they have: encodeAt_eq_encodeValue carries them back to encodeValue
rather than restating them.
Equations
Instances For
Used by
Lean2Js.Core.Program.typesNoDictObj_of_noDictObj
sourceUsed by
Lean2Js.Core.TypeDef.noDictObj_ctorsAt
sourceUsed by
Lean2Js.Core.Program.noDictObj_ret
sourceA declaration's return type, where the program reaches no dictObj.
Used by
Lean2Js.Core.Program.noDictObj_param
sourceA declaration's parameter types, where the program reaches no dictObj.
Used by
Lean2Js.Core.Program.find?
sourceEquations
- p.find? name = List.find? (fun (x : Lean2Js.Core.Decl) => x.name == name) p.decls
Instances For
Used by
Lean2Js.Core.Program.findType?
sourceEquations
- p.findType? name = List.find? (fun (x : Lean2Js.Core.TypeDef) => x.name == name) p.types
Instances For
Used by
Lean2Js.Core.Program.ownerOf?
sourceLooks up the type a constructor name belongs to. match can reach the type definition from the
scrutinee's type, so only the typing of ctor uses this.
Equations
- p.ownerOf? ctor = List.find? (fun (t : Lean2Js.Core.TypeDef) => t.ctors.any fun (x : Lean2Js.Core.CtorDef) => x.name == ctor) p.types
Instances For
Used by
Lean2Js.Core.Program.noDictObj_findAt?
sourceThe field types a constructor is read at, where no type the program declares reaches a dictObj and
the type was used at arguments that reach none. This is the step encodeAt takes at a named type.
Used by
Lean2Js.Core.TypeDef.checkedKey
sourceWhat a type's key has to be before a constructor's name can be read as carrying it.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.Core.checkedKeys
sourceWritten as a recursion rather than forM so that the two readings below can be taken back out of
it.
Equations
- Lean2Js.Core.checkedKeys [] = Except.ok ()
- Lean2Js.Core.checkedKeys (t :: rest) = do t.checkedKey Lean2Js.Core.checkedKeys rest
Instances For
Used by
Lean2Js.Core.Program.discriminators?
sourceThe reading this program declares: a constructor is carried under the key of the type that declares
it, and under tag when no type does — which is Option and Result, whose constructors are the
subset's own. Checked, because the reading is what the compiler and encodeValue share and the laws
above are what the generated code needs of it.
Equations
- One or more equations did not get rendered due to their size.