Lean2Js.Denote
An author's theorem as a claim about the shipped JavaScript #
Lean2Js/Example.lean proves theorems about ordinary Lean functions. This is the descent: what one of
those theorems says about the module the compiler writes.
The step that crosses is the certificate, which certificates% wrote next to the declaration. Everything
else — that the generated function agrees with the reference semantics, that it throws the same codes,
that arguments the entry refuses never reach the body — is proved once about every program and cited here
without knowing what the declaration looks like.
What the walk refuses is pinned here too: a refusal is part of the subset's boundary, and a
#guard_msgs is what keeps the wording from drifting.
Lean2Js.Denote.encode_toValue
sourceUsed by
Lean2Js.Denote.decl_ships
sourceOne declaration, as the claim an author wants: on arguments the entry accepts, the shipped function
either answers what the author's own def computes, read out through the type the declaration gave it,
or throws one of the codes Err enumerates. The certificate is the only part of this that changes from
one declaration to the next.
The reading is encodeAt rather than encodeValue because a return type may say a dictionary crosses
as a plain object, and then the two differ. Where it says no such thing —
encodeAt_eq_encodeValue, which each concrete claim below is rewritten through — they are the same
function and the claim is the one it has always been.
Used by
Lean2Js.Denote.add_ships
sourceUsed by
Lean2Js.Denote.lineTotal_ships
sourceThe one that makes the shape worth the trouble: lineTotal calls clampQuantity, and the step that
crosses the call is clampQuantity's own certificate — cited by the walk, not written here.
Used by
Lean2Js.Denote.roleRank_ships
sourceUsed by
Lean2Js.Denote.add_comm_ships
sourceadd_comm is proved about Example.add, and rewriting it into add_ships is the whole descent.
Nothing in this step knows what the declaration looks like.
Used by
The fold deriving Enc writes for a type that names itself #
A type that names itself has a walk over it, and the subset has no recursion to spell one with, so the
walk has to be a name — and a name per type, because the algebra has one function per constructor.
deriving Enc writes that name beside the encoding and marks it with the type it walks, so that the
walk is found by the mark rather than by a suffix an author's own Category.fold would also carry.
Beside the fold it writes the alternatives a fold is reified to and the certificate that the subset's
walk over them computes it. Reify reads all three where an author calls the fold, so what is pinned here
is what that reading stands on.
The alternatives: one per constructor, in declaration order, every field bound. An author writes no
match to fold, so there is no matcher to read them off — Reify writes them, and binding every field
is what makes them exhaustive at every column the walk goes into.
And the two halves meeting, which is what a reified fold will be: the plumbing takes the scrutinee
and a walk, deriving Enc wrote the walk for the type that has one, and the alternatives the walk was
proved about are the ones Reify writes. Nothing here knows what the bodies are — only that each
denotes its constructor's own function, which is what reifying the algebra's lambda hands over.
What the walk refuses #
A refusal that cannot name what to write instead names the rule the term broke, and the three rules are
the three questions the subset reference opens with: what may be a value, how a program repeats, and
whose vocabulary it reads. One fixture per rule is what keeps the two sides from drifting — the wording lives
in Lean2Js.Reify and is read back here.
Lean's / on Int rounds towards negative infinity and the subset's truncates, so / is not a form the
walk may quietly accept. It refuses at the reify_decl% call rather than at the author's /:
Lean.Expr carries no source positions, so pointing at the author's own syntax needs more than the
elaborated term.
A lambda is a value nowhere: the traversals carry their binder and body as syntax, and every other position wants a value the boundary can carry.
A type with no Enc has no place in Value, so there is nothing for the boundary to carry it as.
_private.Lean2Js.Denote.0.Lean2Js.Denote.Untagged.amount
sourceEquations
- Lean2Js.Denote.Untagged.amount✝ self = self.1
Instances For
Used by
== is the one refusal about the type rather than about the term. eval compares encodings, so a
type whose BEq is not known to decide equality has nothing to say about what that comparison means.
Lean2Js.Denote.Tier
sourceInstances For
Used by
Lean2Js.Denote.instBEqTier.beq
sourceEquations
- Lean2Js.Denote.instBEqTier.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Used by
Lean2Js.Denote.instBEqTier
sourceEquations
Used by
Lean2Js.Denote.Tier.accepts
sourceEquations
Instances For
Used by
Lean2Js.Denote.Tier.toValue
sourceEquations
Instances For
Used by
Lean2Js.Denote.Tier.ty_eq
sourceUsed by
Lean2Js.Denote.Tier.toValue_hasTy
sourceUsed by
Lean2Js.Denote.instEncTier
sourceEquations
- One or more equations did not get rendered due to their size.
Used by
Lean2Js.Denote.Tier.toValue_eq
sourceUsed by
Lean2Js.Denote.Tier.ofValue_toValue
sourceUsed by
Lean2Js.Denote.Tier.typeDef
sourceEquations
Instances For
Used by
Lean2Js.Denote.Tier.ofValue
sourceEquations
Instances For
Used by
A call is the one refusal the author can act on, so it says which certificate was missing rather than that the term was unreadable.
Lean2Js.Denote.uncertified
sourceEquations
- Lean2Js.Denote.uncertified x = x + 1
Instances For
Used by
Lean2Js.Denote.callsUncertified
sourceEquations
Instances For
Used by
A function crosses the boundary as a declaration's name, so a function the author wrote inline has no name to cross as.