extras : AlgId → Option AlgReading page · generated from lean/Ecma/Implements.lean, lean/Ecma/Machine/Run.lean
What it is to implement the specification
The definition the engine's headline theorem is stated against, in full, with the definitions of a run it uses. What is proved reads it field by field.
What it is to implement the specification
From lean/Ecma/Implements.lean
An implementation has values (a Model), a host (a Host), algorithms of its own beside the specification's, and its own transition between the machine's configurations. It implements the specification (Implements) when its values obey the model's laws, its host obeys the host's laws, and each transition it takes from a configuration the specification's machine reaches is some transitions of that machine. Its every run is then a run of the specification's machine.
Both machines run under the readings of the errata (rd) and whether Asserts are checked, and the statement is of every rd. A definition reading, the overlay's one reading of prose steps, is no choice: the program's code holds its steps (Ins.reading), and rd is asked only at an erratum.
Spec.program
Implements.lean:34The specification's program, with an implementation's own algorithms extras where the specification defines none (sec-conformance: an implementation "may provide additional types, values, objects, properties, and functions beyond those described in this specification").
def Spec.program (extras : AlgId → Option Alg) : Prog' := Prog'.of (Spec.src.expanded extras)Implementation
Implements.lean:39An implementation over the model M: its own algorithms, its host, and its transition under the errata's readings and whether Asserts are checked. A transition may take many of the specification's steps at once, or compute one differently.
structure Implementation (M : Model) whereImplementation.spec
Implements.lean:45The specification's machine for I: the specification's program with I's algorithms, and I's host.
def Implementation.spec (I : Implementation M) (rd : ErratumId → Reading) (chk : Bool) : Ctx M := Ctx.spec (Spec.program I.extras) I.host rd chk
Reached
Implements.lean:51The configurations the machine X reaches: from a call in a state with no suspended execution context, by its transitions, and by a further call from the state a run ended in, whatever else of that state the host changed meanwhile (its suspended execution contexts it may not).
inductive Reached (X : Ctx M) : Cfg M → Prop whereImplementation.Runs
Implements.lean:58A run of I from c that ends with f.
inductive Implementation.Runs (I : Implementation M) (rd : ErratumId → Reading) (chk : Bool) : Cfg M → Final M → Prop where
Implements
Implements.lean:64I implements the specification.
structure Implements (I : Implementation M) : Prop whereits values are the specification's: the model's laws
model : Model.Laws M ∧ Model.UnicodeLaws M ∧ Model.ParentLaws Mits host meets every requirement the specification makes of a host
host : Host.WF I.hosteach transition it takes from a configuration the specification's machine reaches is some transitions of that machine, and where it ends, that machine's run ends so; or it gives up at a limit of its own (it never answers otherwise than the specification)
step : ∀ rd chk c, Reached (I.spec rd chk) c → match I.step rd chk c with | .inl c' => Steps (I.spec rd chk) c c' | .inr f => Runs (I.spec rd chk) c f ∨ f = .stop .implLimit
Runs
From lean/Ecma/Machine/Run.lean
What it is for the specification's algorithms to run, over any model and host: a relation between configurations, with no bound. Step is one transition of the machine (step), Steps any number of them, and Runs a run that ends. Calls is a call's run from a state to its result. The specification's own context (Ctx.spec) has the program's code, the host and the readings, and nothing else.
What it is for an implementation to be the specification's is stated over these (Ecma.Implements).
Machine.Ctx.spec
Run.lean:26The specification's context: the program's code, the host, the readings chosen for the errata, and whether Asserts are checked. A definition reading is no choice: the code holds its steps (Ins.reading), and rd is not asked of it.
def Ctx.spec (prog : Prog') (H : Host M) (rd : ErratumId → Reading) (chk : Bool) : Ctx M := { prog, H, rd, chk }
Machine.Step
Run.lean:30One transition.
def Step (X : Ctx M) (c c' : Cfg M) : Prop := step X c = .inl c'Machine.Ends
Run.lean:33The machine ends at c, with f.
def Ends (X : Ctx M) (c : Cfg M) (f : Final M) : Prop := step X c = .inr fMachine.Steps
Run.lean:36Any number of transitions.
inductive Steps (X : Ctx M) : Cfg M → Cfg M → Prop whereMachine.Runs
Run.lean:41A run from c that ends with f.
def Runs (X : Ctx M) (c : Cfg M) (f : Final M) : Prop := ∃ c', Steps X c c' ∧ Ends X c' fMachine.Calls
Run.lean:44The call k from the state s gives v, leaving the state t.
def Calls (X : Ctx M) (k : Call M) (s : State M) (v : Val M) (t : State M) : Prop := Runs X (start s k) (.ok v t)