Lean proofs
The static semantics of the Core (Chapter 4), of modules (Chapter 5) and of programs (Chapter 9); the dynamic semantics of the Core (Chapter 6), of modules (Chapter 7), of tasks, commands, subscriptions and ports (Chapter 8) and of programs (Chapter 9); and the arithmetic, equality, order, Boolean, conversion, append and character part of APPLY are encoded in the proof assistant Lean 4 (v4.35.0), one inductive relation per judgement and one constructor per rule, 193 rules in all. A type inference is proved sound and principal for the static semantics. An evaluator is proved sound and complete for the dynamic semantics: whatever value it computes, the rules derive (evExp_sound), and every derivation is found by it. Every theorem below is checked by Lean each time the project is built, and each has a page with its statement and proof.
The evaluator is run on the test programs of this suite, translated into Lean by a program from their Elm source: 702 of the 1017 tests tagged elm-spec, with 1909 checks, of which 1909 agree with the value the test expects. 702 further theorems are generated when Lean compiles the project, one for each translated program, proving that the rules give 1907 of those checks the value the test expects.
Which tests are in Lean
The translator, definition/tools/src/Translate.elm, puts each of the 1017 tests tagged elm-spec into Lean in up to two forms. The first is the program as written, in the source syntax the book starts from; the static semantics is proved about it. The second, only for a test whose program compiles, is the reduced program, which Lean's evaluator runs to prove the test's checks.
Static semantics: is the program legal?
Lean proves 702 programs legal (a theorem legal_<project>_<Test>) and 287 not legal (refuse_<project>_<Test>), the second for the tests that expect a compile error. Each test's page names its theorem and how it is proved.
Evaluation: the reduced program
Every one of the 702 tests whose program compiles is translated into a reduced program the evaluator runs. A test that expects a compile error has no meaning to run, so it has no reduced program.
StandardElmMech/Apply.lean
Eq and cmp as functions; IEEE 754-2019 minimum and maximum (fMinimum, fMaximum) and clamp at floats built on them (fClamp); APPLY as the relation Apply (one constructor per line of the book's displays) and as the executable applySet, with applySet_sound and applySet_complete; logEntry, the log entry of an application of Debug.log
The executable set
applySetCore_soundtactic proofapplySetNew_soundtactic proofapplySetEff_soundtactic proofapplySet_soundtactic proofEvery member ofapplySet b vsis in APPLY(b, vs).applySetEff_completetactic proofapplySet_completetactic proofEvery member of APPLY(b, vs) is inapplySet b vs(completeness of the executable set).applySetEff_lengthtactic proofAPPLY of an effect value has at most one member ("each set has exactly one member", sec:effects-apply, where it is defined).applySet_length_le_twotactic proofAPPLY has at most two members: only function equality has two.
StandardElmMech/Forget.lean
Generated by scripts/gen_forget.py: forget (a logged derivation is a derivation of the book) and lift (every derivation of the book has a logged one)
EvalAtExpL.forgetterm proofEvalExpRowL.forgetterm proofEvalExpL.forgetterm proofAppValL.forgetterm proofEvalMatchL.forgetterm proofEvalMRuleL.forgetterm proofEvalDecL.forgetterm proofEvalValBindL.forgetterm proofMatchAtPatL.forgetterm proofMatchPatRowL.forgetterm proofMatchPatL.forgetterm proofEvalExpOptL.forgetterm proofEvalExpRowOptL.forgetterm proofEvalValBindOptL.forgetterm proofMatchPatOptL.forgetterm proofMatchPatRowOptL.forgetterm proofMatchAtPatsL.forgetterm proofEvalAtExp.liftterm proofEvalExpRow.liftterm proofEvalExp.liftterm proofAppVal.liftterm proofEvalMatch.liftterm proofEvalMRule.liftterm proofEvalDec.liftterm proofEvalValBind.liftterm proofMatchAtPat.liftterm proofMatchPatRow.liftterm proofMatchPat.liftterm proofEvalExpOpt.liftterm proofEvalExpRowOpt.liftterm proofEvalValBindOpt.liftterm proofMatchPatOpt.liftterm proofMatchPatRowOpt.liftterm proofMatchAtPats.liftterm proof
StandardElmMech/Sound.lean
soundAt, evExp_sound_l, evExp_sound: every value of the evaluator, with its log, is derivable in the logged relation, and so in the book's
sconTest_truetactic proofsconTest_falsetactic proofconIs_truetactic proofconIs_falsetactic proofconArgs_sometactic proofconArgs_nonetactic proofapplySet_singletactic proofapplySet_firsttactic proofapplySet_secondtactic proofatpat_tuple_l'term proofr:d-atpat-tuple with its first premise v = (v1, v2 [, v3]) discharged.app_basic_choice_ltactic proofr:d-app-basic-apply at a member chosen by the oracle.soundAttactic proofevExp_sound_lterm proofSoundness for the logged relation: a value of the evaluator, with its log, is derivable.evDec_sound_lterm proofappVal_sound_lterm proofevValBind_sound_lterm proofevExp_soundtactic proofMain theorem: the evaluator's values are derivable in the definition.evDec_soundtactic proof
StandardElmMech/Complete.lean
The index of the next choice only grows (evExp_next and the others); Agrees; lemmas for the side conditions
The index only grows
nextAttactic proofevAtExp_nextterm proofevExpOpt_nextterm proofevExpRow_nextterm proofevExpRowOpt_nextterm proofevExp_nextterm proofappVal_nextterm proofevMatch_nextterm proofevMRule_nextterm proofevDec_nextterm proofevValBind_nextterm proofevValBindOpt_nextterm proofmatchAtPat_nextterm proofmatchPatOpt_nextterm proofmatchPatRow_nextterm proofmatchPatRowOpt_nextterm proofmatchPat_nextterm proofmatchAtPats_nextterm proofsconTest_iffterm proofconIs_iffterm proofconArgs_eq_sometactic proofconArgs_eq_nonetactic proofMatchAtPatsL.length_eqterm proof
Agreement of an oracle with a list of choices (for completeness, Completeness.lean)
agrees_nilterm proofagrees_appendtactic proofagrees2term proofagrees3tactic proofagrees_singletactic proofconArgs_none_ofterm proof
StandardElmMech/NoStuck.lean
Generated by scripts/gen_nostuck.py: for a derivation, the evaluator runs out of fuel, reads a choice, or gives exactly its value and log
EvalAtExpL.nostuckterm proofEvalExpRowL.nostuckterm proofEvalExpL.nostuckterm proofAppValL.nostuckterm proofEvalMatchL.nostuckterm proofEvalMRuleL.nostuckterm proofEvalDecL.nostuckterm proofEvalValBindL.nostuckterm proofMatchAtPatL.nostuckterm proofMatchPatRowL.nostuckterm proofMatchPatL.nostuckterm proofEvalExpOptL.nostuckterm proofEvalExpRowOptL.nostuckterm proofEvalValBindOptL.nostuckterm proofMatchPatOptL.nostuckterm proofMatchPatRowOptL.nostuckterm proofMatchAtPatsL.nostuckterm proof
StandardElmMech/Completeness.lean
Generated by scripts/gen_complete.py: every derivation is found by the evaluator, with some choices and fuel
EvalAtExpL.completeterm proofEvalExpRowL.completeterm proofEvalExpL.completeterm proofAppValL.completeterm proofEvalMatchL.completeterm proofEvalMRuleL.completeterm proofEvalDecL.completeterm proofEvalValBindL.completeterm proofMatchAtPatL.completeterm proofMatchPatRowL.completeterm proofMatchPatL.completeterm proofEvalExpOptL.completeterm proofEvalExpRowOptL.completeterm proofEvalValBindOptL.completeterm proofMatchPatOptL.completeterm proofMatchPatRowOptL.completeterm proofMatchAtPatsL.completeterm proof
StandardElmMech/Determinism.lean
noValue_of_stuck, evExp_unique, evExp_unique_l, evExp_complete, noValue_iff, and the same for applications and declarations
evExp_unique_ltactic proofevExp_uniquetactic proofnoValue_of_stucktactic proofappVal_unique_ltactic proofappVal_noValue_of_stucktactic proofevDec_unique_ltactic proofevDec_noValue_of_stucktactic proofagrees_ofListtactic proofevExp_completetactic proofD1's completeness: every derivation of the book is found by some choices and fuel.evExp_complete_ltactic proofCompleteness for the logged relation: the derivation's log is the evaluator's.noValue_ifftactic proof
StandardElmMech/Checks.lean
What a check states (plan decision D9): Expect (structural values) with its decider, the parser of CHECK values, CheckStmt, the log statements EntryPat, LogCheck, ExpChecks with their deciders, regular expressions Rx
The value a CHECK line states
Expect.holds_inttactic proofExpect.holds_strtactic proof
The log statements
EntryPat.check_soundtactic proofmem_tailsOfterm proofrunAt_soundterm proofLogCheck.check_soundtactic proofexpChecks_soundtactic proof
A value statement for the ruling theorems
valueCheck_soundtactic proofuniqueValue_soundtactic proofcheckShowWith_soundtactic proof
StandardElmMech/Eff/Boundary.lean
Boundary values (BVal, with arrays and objects in the list types BArr, BObj), JSON numbers as exact rationals (jnum, isDecimal), canonical values, JSON values (isJson), mkObj, the exact value of a float (floatToRat?, dyadic) and the float nearest a decimal (ratToFloat)
BArr.toList_ofListterm proofBObj.toList_ofListterm proof
StandardElmMech/Eff/EncDec.lean
The book's relations Enc and Dec (15 and 14 rules, r_e_enc_*, r_e_dec_*), enc_iff, dec_iff, and that both are partial functions
The applications of the array rules
appVal_arrayToListtactic proofappVal_arrayFromListtactic proof
Lists and bytes
toList?_ofListterm proofofList_of_toList?term proofbyteOf?_inttactic proofmapM_bytesterm proofmapM_bytes_invterm proofmapM_bytes_compterm proofenc_binValtactic proofBArr.ofList_toListterm proof
The relations are the functions
encSeq_of_mapMterm proofdecSeq_of_mapMterm proofenc_iffterm proofThe relation Enc is the function enc (D8).dec_iffterm proofThe relation Dec is the function dec (D8).Enc.functionaltactic proofEnc_τ is a partial function (sec:effects-ports, the property's first sentence).Dec.functionaltactic proofDec_τ is a partial function.
StandardElmMech/Eff/Task.lean
Task reduction (TaskRed, 7 rules, r_e_task_*) and its logged twin, focus and plug, the property of task reduction (taskRed_iff, taskRed_outcome, taskRed_kind, taskRed_silent_same, taskRed_none), and the executable step stepTaskL, sound, complete and unique
TaskRedL.forgetterm proofTaskRed.liftterm proof
The redex of a task
taskRed_outcometactic proofAn outcome has no reduction.taskRed_of_focusterm proofA reduction of the redex, plugged back into the frames, is a reduction of the task.taskRed_ifftactic proofA reduction is a reduction of the redex, plugged back into the frames.taskRed_same_redextactic proofTwo reductions of a task reduce its one redex.taskRed_kindtactic proofEither every reduction of a task is silent or every one is labelled, by one primitive and one argument list (sec:effects-tasks, the property).taskRed_silent_sametactic proofSilent reductions of a task have the same right-hand side, up to the choice of a member of APPLY in the application of the redex.taskRed_nonetactic proofA well-formed task that is not an outcome has no reduction only when the application of r:e-task-andthen-succeed or r:e-task-onerror-fail at its redex has no result.
The executable step
mapOut_valuetactic proofappVal_sound_outtactic proofstepTaskL_soundtactic proofEvery step of the evaluator is a logged reduction.TaskRedL.not_outcometactic proofstepTaskL_andThen_innertactic proofstepTaskL_onError_innertactic proofstepTaskL_completetactic proofEvery logged reduction is found by the evaluator, with some choices, fuel and fresh identifier (the one the reduction spawns, if it spawns).stepTaskL_uniquetactic proofWhen the evaluator reads no choice and the reduction spawns nothing, its step is the only one (a spawn's outcome is any identifier, which the rule leaves free).
StandardElmMech/Eff/Flat.lean
Flattening of commands and subscriptions (flat, flat_leaves)
leafCore_mapE_maptactic proofflat_nonetactic proofCmd.none, and a batch of nones, flatten to the empty multiset.
StandardElmMech/Eff/Messages.lean
Messages (Recv, 3 rules, r_e_msg_*) and its logged twin, and the executable recvL, sound, complete and unique
RecvL.forgetterm proofRecv.liftterm proofrecvL_soundterm proofrecvNone_soundtactic proofrecvL_completetactic proofEvery logged reception is found by the evaluator, with some choices and fuel.recvL_nextterm proofThe index of the next unread choice only grows.recvL_uniquetactic proofWhen the evaluator reads no choice, its message and log are the only ones.
StandardElmMech/Eff/TaskTexts.lean
The elm/core 1.0.5 texts of Task and of the List functions it reaches, their values taken in order, and their derivations (textValue_eval, taskTexts_eval, listTexts_eval); ME0(Task) and ME0(Process)
Values of texts taken in order
textValue_evaltactic proofEvery text derives its value in its environment.textValue_evalLtactic proofThe same derivation in the logged relation, with the empty log (a lambda logs nothing).
The environments and the interfaces
taskTexts_evalterm proofEach text of Task derives its value in the environment of the texts before it.listTexts_evalterm proofEach text of List (foldl and foldrHelper by r:d-dec-rec, reverse and foldr by r:d-dec-nonrec) derives its value in the environment of the texts before it.taskTexts_evalLterm proofThe logged derivations, with the empty log.listTexts_recursivekernel-checked (decide +kernel)foldl and foldrHelper are recursive, reverse and foldr are not (so their values are Rec of their closures, and the closures themselves).
StandardElmMech/Eff/Properties.lean
APPLY of the effect values has one member; the rulings A74, A76, A88 and A92; canonical payload types, the decimality of a float's exact value, and that every value of a payload type has a canonical encoding (enc_total)
APPLY of the effect values
apply_effect_singletontactic proofAPPLY of an effect value has at most one member ("each set has exactly one member", sec:effects-apply, where it is defined).
A74
a74_value_enctactic proofA74: at the type Json.Encode.Value a value encodes exactly as the JSON value it holds.a74_value_dectactic proofA74: a boundary value decodes at Json.Encode.Value exactly when it is JSON.a74_nonfinite_nullnative_decide (trusts the compiled evaluator)A74: NaN and the infinities encode as null.a74_maybe_float_nullterm proofA74: null decodes at Maybe Float as Nothing.
A76
fmLookup_permtactic prooflabelsMatch_permtactic proofencFields_permterm proofa76_enc_record_permtactic proofA76: objects are unordered: the encoding of a record value does not depend on the order in which its fields are held (its labels distinct, as evaluation makes them).decFields_noneterm proofa76_dec_missing_keytactic proofA76: decoding fails when a key of the record type is missing from the object.
A88
a88_negzero_encnative_decide (trusts the compiled evaluator)A88: -0 encodes as the JSON number 0: a JSON number has no sign apart from its value. [native] (a float's bits)a88_zero_dec_inttactic proofA88: the JSON number 0 decodes at Int as 0, and only so.a88_int_exactterm proofA88: JSON numbers decode at Int exactly, within IntRange; an Int encodes as itself.a88_int_rangekernel-checked (decide +kernel)A88: 2^63 is outside IntRange, and 1.5 is no Int: neither decodes at Int.a88_huge_dec_floatnative_decide (trusts the compiled evaluator)A88: a JSON number beyond the floats decodes at Float as an infinity. [native] (the rounding of Float.ofScientific is the C library's)
A92
a92_bytes_not_jsontactic proofA92: a byte sequence is not JSON.a92_dec_bytestactic proofA92: only a byte sequence decodes at Bytes, as bin# of its bytes.a92_bytes_not_stringtactic proofA92: a byte sequence does not decode at String.a92_bytes_not_listtactic proofA92: a byte sequence does not decode at List Int.a92_value_no_bytesterm proofA92: a value of Json.Encode.Value carries no byte sequence.a92_bytes_nestedkernel-checked (decide +kernel)A92: a list of byte sequences encodes as an array of byte sequences.
Numbers: a float's exact value is decimal
pow2_of_dvdterm proofA92: a list of byte sequences encodes as an array of byte sequences. -/ theorem a92_bytes_nested : Enc (.list .bytes) (Val.ofList [binVal [1, 2]]) (.arr (.cons (.bytes [1, 2]) .nil)) := (enc_iff _ _ _).mpr (by decide +kernel) /-! ## Canonical payload types and boundary values (D7) -/ mutual /-- Canonical payload types: the fields of every record type strictly increasing by label. -/ def PTy.canonB : PTy → Bool | .list τ | .maybe τ | .array τ => τ.canonB | .tuple2 a b => a.canonB && b.canonB | .tuple3 a b c => a.canonB && b.canonB && c.canonB | .record fs => fs.canonB && fs.labelsIncreasing | _ => true def PFields.canonB : PFields → Bool | .nil => true | .cons _ τ rest => τ.canonB && rest.canonB def PFields.labelsIncreasing : PFields → Bool | .nil => true | .cons _ _ .nil => true | .cons l _ (.cons l' τ' rest) => decide (l < l') && (PFields.cons l' τ' rest).labelsIncreasing end def PTy.Canon (τ : PTy) : Prop := τ.canonB = true /-! ## Numbers: a float's exact value is decimalstripFactor_pow2tactic proofstripFactor_oneterm proofisDecimal_of_den_dvdtactic proofisDecimal_intterm proofdyadic_den_dvdtactic prooffloatToRat?_decimaltactic proof
Every value of a payload type has an encoding (sec:effects-ports, the property)
keysIncreasing_of_labelsterm proofcanonB_ofListterm proof
StandardElmMech/Eff/MkObj.lean
A76: mkObj ignores the order of distinct keys (a76_mkObj_perm), a lookup finds the last binding (lookup_mkObj), and decoding ignores keys outside the record type (a76_dec_extra_key)
Sorting by insertion
insertByKey_permterm proofinsertByKey_sortedterm proofsortByKey_permterm proofsortByKey_sortedterm proof
Keeping the last binding of each key
mem_of_keys_nodup_eqterm proofdedup_step_noduptactic proofdedup_foldl_noduptactic proofdedupLastByKey_noduptactic proofa76_mkObj_permtactic proofA76: objects are unordered: the order of an object's distinct keys does not matter.
Lookups through `mkObj`
lookup_ofListterm prooffmLookup_append'term prooffmLookup_filter_netactic prooffmLookup_append_singletactic proofdedup_foldl_lookuptactic proofdedup_keys_nodupterm prooflookup_insertByKeyterm proofkeysOf_sortByKey_permterm prooflookup_sortByKeyterm prooflookup_mkObjtactic proofA lookup inmkObj kvsfinds the last binding of the key in kvs.decFields_congrterm proofa76_dec_extra_keytactic proofA76: decoding ignores further keys: adding a key absent from the record type leaves the result unchanged.
StandardElmMech/Eff/Normalise.lean
PTy.normalise (record fields sorted by label) and normalise_canon: canonical when each record's labels are distinct
Labels increasing as a pairwise property
labelsIncreasing_iffterm prooflabels_insert_permterm prooflabels_sort_permterm proofinsert_increasingtactic proofsort_increasingterm proofcanonB_insertterm proofcanonB_sortterm prooflabels_normaliseEachterm proofnormalise_examplekernel-checked (decide +kernel)normalise sorts the fields of nested record types too.
StandardElmMech/Eff/WF.lean
Well-formed values (Val.WF): no byte sequence outside an out leaf
wf_out_leaftactic proofAn out leaf may carry any boundary value, a byte sequence included (A92).wf_bv_ifftactic proofwf_ofListterm proof
StandardElmMech/Eff/RoundTrip.lean
The round trip of encoding and decoding (roundtrip), except where A88 says otherwise (NoExc), under the named hypothesis FloatRoundTrip; the exceptions shown to be needed
Lists and their values
toList?_sometactic proofnormVal_ofListterm proofmapM_cons_sometactic proofmapM_byteOfterm proofkeys_nodup_mem_eqterm prooflookup_encFields_othertactic proofnodup_of_mapterm proofnormFields_eqterm prooffieldOf_of_memterm prooffieldOf_some_memterm proofmem_keys_fieldOftactic proofsortFields_eqtactic proofWith distinct labels, the fields of a record value whose labels are the type's, sorted by label and normalised, are the decoded fields.roundtripterm proofThe round trip (sec:effects-ports, the property): a value of a canonical payload type that encodes to j decodes from j to itself with its records' fields in label order, unless one of the exceptions of A88 occurs in it; given the one fact about Lean's floats it uses.
The exceptions are needed
a88_roundtrip_negzeronative_decide (trusts the compiled evaluator)A88: -0 encodes as 0, which decodes as +0: the round trip loses the sign. [native] (a float's bits)roundtrip_nan_failsnative_decide (trusts the compiled evaluator)NaN encodes as null, which does not decode at Float. [native] (a float's bits)roundtrip_just_nothingkernel-checked (decide +kernel)Just Nothingat Maybe (Maybe Int) encodes as null, which decodes as Nothing.
StandardElmMech/Eff/Examples.lean
Task.perform, Task.sequence of six tasks reduced to its outcome, Task.attempt of a failing task, and the flattening of Cmd.batch [Cmd.none, Cmd.none], by the kernel
exValue_soundtactic proofeqFO_sound_alltactic proofeqFO_soundterm proofoptEq_soundtactic proofex_performkernel-checked (decide +kernel)Task.perform identity (Task.succeed 1) evaluates to a task leaf command.ex_sequencekernel-checked (decide +kernel)Task.sequence of six succeeding tasks reduces to succeed [1, ..., 6]; six elements exercise foldrHelper's unrolling by four and its recursion.ex_attempt_errkernel-checked (decide +kernel)Task.attempt identity (Task.fail 3) is a task leaf whose task succeeds with Err 3.ex_flat_nonekernel-checked (decide +kernel)Cmd.batch [Cmd.none, Cmd.none] flattens to the empty multiset.
StandardElmMech/Mod/RulesL.lean
The logged twins of the four relations that can log, with forget and lift
Forget and lift
EvalForcesL.forgetterm proofEvalForces.liftterm proofEvalTopDecL.forgetterm proofEvalTopDec.liftterm proofEvalModuleL.forgetterm proofEvalModule.liftterm proofEvalProgramL.forgetterm proofEvalProgram.liftterm proof
StandardElmMech/Mod/Sound.lean
Its soundness
evExpItem_soundtactic proofevExpItems_soundterm proofevExpList_soundtactic proofevExpListOpt_soundtactic proofevHeader_soundtactic proofevImports_soundterm proofevConBind_soundterm proofevConBindOpt_soundterm proofevDatBind_soundterm proofevDatBindOpt_soundterm proofevTypBind_soundtactic proofevForces_sound_lterm proofevTopDec_sound_lterm proofevModule_sound_ltactic proofevProgram_sound_lterm proofevProgram_soundtactic proof
StandardElmMech/Mod/Complete.lean
The functional parts' converses, nostuck for modules and programs, noMeaning_of_stuck, evProgram_unique_l, completeness (evProgram_complete, noMeaning_iff)
EvalExpItem.eq_evterm proofEvalExpItems.eq_evterm proofEvalExpList.eq_evterm proofEvalExpListOpt.eq_evterm proofEvalHeader.eq_evterm proofEvalImports.eq_evterm proofEvalConBind.eq_evterm proofEvalConBindOpt.eq_evterm proofEvalDatBind.eq_evterm proofEvalDatBindOpt.eq_evterm proofEvalTypBind.eq_evterm proof
nostuck
evForces_next_geterm proofevForces_nexttactic proofEvalForcesL.nostuckterm proofevTopDec_next_geterm proofevTopDec_nexttactic proofevModule_nexttactic proofevProgram_next_geterm proofevProgram_nexttactic proofEvalTopDecL.nostuckterm proofEvalModuleL.nostuckterm proofEvalProgramL.nostuckterm proof
Statements about every derivation of a program
noMeaning_of_stucktactic proofA program on which the evaluator is stuck without reading a choice has no meaning (A25, A62).evProgram_unique_ltactic proofA program value found without reading a choice is the only one, and its log the only log.evModule_unique_ltactic proof
Completeness (D1): every derivation is found by some choices and fuel
EvalForcesL.completeterm proofEvalTopDecL.completeterm proofEvalModuleL.completeterm proofEvalProgramL.completeterm proofevProgram_completetactic proofD1 for programs: every derivation of a program's meaning is found by some choices and fuel.noMeaning_ifftactic proofA program has no meaning exactly when no choices and fuel give it one.
StandardElmMech/Mod/ME0.lean
The dynamic ME0 of the default-imported modules (plan decision D3), the harness Html and Btest (D2), E_default (the environment the default imports give, derived by the rules), the texts of none
noneIsBatch_soundtactic proofme0_PlatformCmd_none_evalkernel-checked (decide +kernel)The text of Platform.Cmd'snoneevaluates, in its environment, to batch() (D3).me0_PlatformSub_none_evalkernel-checked (decide +kernel)The text of Platform.Sub'snoneevaluates, in its environment, to batch() (D3).E_default_evalterm proof
StandardElmMech/Mod/Properties.lean
The frame lemmas (a module's derivation reads the basis only at the modules it imports) and Btest_agrees
Finite maps
fmLookup_appendtactic prooffmLookup_filtertactic prooffmLookup_none_ifftactic prooffmLookup_fmPlustactic proof
The frame lemma
EvalImports.frameterm proofEvalModuleL.frameterm proofA module's derivation reads the basis only at the modules it imports.EvalProgramL.frameterm proofA program's derivation reads the basis only at the modules its modules import.
The test basis (D2)
btestStep_othertactic proofOne step of Btest's fold changes only the binding of its own module.foldl_btest_otherterm proofBtest_agreestactic proofD2: the test basis agrees with ME0 on every module but Html and the library's modules.
StandardElmMech/Mod/Good.lean
The property of interfaces (Interface.Good): ME0 and the harness have it (ME0_good), a top-level declaration with distinct bound names infers an interface with it (EvalTopDec.good), a header's exposing list keeps it (EvalHeader.good), and so does every interface a module puts in the basis (EvalModule.good)
Finite maps
fmLookup_isSome_memtactic prooffmLookup_none_of_not_memtactic prooffmLookup_fmPlus_some_righttactic prooffmLookup_fmPlus_lefttactic prooffmLookup_fmPlus_isSometactic prooffmLookup_fmPlus_casestactic proofA binding of f + g is a binding of g, or of f where g binds nothing.fmLookup_fmPlus_isSome_casestactic prooffmLookup_singleton_isSometactic proof
The domains of the bindings
EvalConBind.domterm proofEvalDatBind.domterm proofzip_keys_isSometactic proofEvalTopDec.domterm proofA top-level declaration's interface binds in its VE only the names the declaration binds.
Top-level declarations
fmLookup_singleton_sometactic proofnodup_append_disjointterm proofnodup_append_leftterm proofnodup_append_rightterm proofnone_of_not_boundtactic proofA binding of VE outside the names a derivation binds is none.EvalDatBind.goodterm proofThe constructors of a custom-type binding: each CE entry's bindings are VE's, when the constructors are distinct.ofVE_goodterm proofempty_goodterm proofEvalTopDec.goodterm proofA top-level declaration whose bound names are distinct infers an interface with the property (the restrictions of sec:syntax-modules-restrictions make them distinct).
Headers
partOf_emptyterm proofpartOf_plustactic proofpartOf_foldlterm proofEvalExpItem.partOfterm proofEvalExpItems.partOfterm proofEvalHeader.goodtactic proofThe exposing list of a header keeps the property.EvalModule.goodtactic proofEvery interface a module's derivation puts in the basis has the property, when the module's bound names are distinct.
ME0 and the harness
fmLookup_some_memterm proofmem_fmPlustactic proofgood_of_entriesterm proofAn interface without record aliases has the property when every constructor its CE entries bind is bound in its VE to the same value.I_Basics_goodtactic proofI_Maybe_goodtactic proofI_Result_goodtactic proofME0_goodtactic proofThe interfaces of ME0 and of the harness have the property.
StandardElmMech/Mod/A25.lean
A25: the module x = let f _ = x in f () has no meaning (a25_no_value, a25_no_meaning), by the loop of the evaluator forcing x's thunk (a25_loop) and completeness
a25T_eqterm proofappVal_wild_outtactic proofApplying a closure whose pattern is_evaluates its body, two fuel levels down.appVal_wildtactic proofa25_steptactic proofOne turn of the loop: forcing at fuel M + 14 comes back to forcing at M + 6.a25_looptactic proofThe evaluator runs out of fuel forcing the thunk, at every fuel.a25_force_outtactic proofForcing x's thunk, in the environment the group's value binding gives, never ends.thunkGroup_a25term proofa25_no_valuetactic proofA25: a delayed self-reference forced during its own evaluation has no result: the modulex = let f _ = x in f ()has no meaning, in any basis.a25_no_meaningtactic proofA25: a program whose first module isx = let f _ = x in f ()has no meaning.
StandardElmMech/Mod/Rulings.lean
A82, A38 and A28 on programs written by hand
programValue_soundtactic proofa82_main_not_exposedkernel-checked (decide +kernel)a38_shared_qualifier_mergeterm proofA38: two imports that give the same qualifier merge under it (sec:dynamic-modules-merge).a38_later_import_keptterm proofA38: where two imports expose the same name, the later import's binding is kept.a38_ambiguous_unusedkernel-checked (decide +kernel)A38: both imports expose x, the module never uses it, and the program has a meaning. [harness] [params]a28_written_import_replaces_defaultterm proofA28: a written import replaces what a default import exposes: afterimport A exposing (Maybe(..)),Justis A's constructor, of arity 2.
StandardElmMech/Lib/Library.lean
The core library values written in Elm (plans/library-elm-texts.md): libME, the interfaces Chapter 7's rules give the library modules of Generated/Library.lean, evaluated in order in ME0 (libME_eval: each module's derivation by r:dm-module, from the evaluator's soundness); Lib.Btest, the dynamic test basis with the library (Mod.Btest libME), in which the view programs' theorems are stated. Only a value a program looks up is evaluated
evLibModule_soundtactic prooflibCheck_soundterm prooflibME_evalkernel-checked (decide +kernel)The library modules, evaluated in order in ME0 by Chapter 7's rules (r:dm-module and the rules of its premises), have the interfaceslibMEbinds: the analogue, for the core library, ofelmTexts_evalandme0_PlatformCmd_none_eval.libME_modulesterm proofThe modules the library extends, in order.
StandardElmMech/Mod/Program.lean
A test program in module form (plan step 3): Appendix A's derived form for modules (Module.ofSource: the custom types, the aliases, the ports, then the definitions in components), a program's modules in program order; ViewChecks and NoMeaning with their deciders proved sound; viewChecks_every
The statements
viewChecks_soundtactic proofnoMeaning_soundtactic proofviewChecks_everytactic proofWhen the evaluator reads no choice, the checks hold of every derivation's log, not only of some (from evProgram_unique_l): the existential of D9 is then also universal.
StandardElmMech/Prog/Objects.lean
Chapter 9's objects of execution (plan step 5): port environments, processes, configurations, events, SleepReady
natLookup_natSet_selftactic proofnatLookup_filter_netactic proofnatLookup_natSet_othertactic proof
StandardElmMech/Prog/Dispatch.lean
Dispatch (4 rules, r_p_disp_*) and the executable dispatchFn with fresh identifiers, sound
le_foldl_maxterm proofmem_le_foldl_maxterm prooffreshPid_freshtactic proofdispatchFn_soundterm proof
StandardElmMech/Prog/Rules.lean
The start of a program (Start, r:p-init, with Flags_τ, A72 and A77), the 12 transition rules (Step, r_p_*), the messages of an accepted value (AcceptMsgs), their logged twins, forget and lift
The logged relations are the book's with a log
StartL.forgetterm proofStart.liftterm proofAcceptMsgsL.forgetterm proofAcceptMsgs.liftterm proofStepL.forgetterm proofStep.liftterm proof
StandardElmMech/Prog/Exec.lean
Hosts (any, none, the test runner's echo), executions with and without logs, a worker's executions (WorkerExec, its log as D9 defines it), traces and Tr (tr_nil, tr_prefix, tr_empty_iff_no_start)
ExecL.forgetterm proofExec.liftterm proofWorkerExecO.exectactic prooftr_niltactic proofWith the book's host, an execution with no step has the empty trace: a program that starts has the empty trace.tr_empty_iff_no_starttactic proofA program has no trace exactly when it does not start.exec_taketerm proofEvery prefix of an execution under the book's host is an execution.trace_take_prefixtactic prooftr_prefixtactic proofTr is closed under prefixes (sec:programs-behaviour: every finite prefix of transitions is an execution).
StandardElmMech/Prog/Sched.lean
The default scheduler (run): one choice per iteration, overridable per test, each transition proved by doChoice_sound; run_sound: every run is an execution
LeafOrder.permtactic proof
Helpers, each with its soundness
sleepReadyB_soundtactic proofacceptFn_soundterm proofhostAfter_soundtactic proof
Soundness
stepTaskL_sound_eqtactic proofdoUpdate_soundtactic proofprocTask_soundtactic proofprocOutcome_soundtactic proofdoProc_soundtactic proofdoOut_soundtactic proofdoInn_soundtactic proofdoWait_soundtactic proofdoChoice_soundtactic prooflastConfig_appendtactic proofExecL.appendterm proofrun_soundterm proofA run is an execution: the transitions the scheduler takes, from where it started.
StandardElmMech/Prog/Worker.lean
Worker tests: WorkerTest.Holds (some execution the book allows, under the test's host, has a log meeting every check), runWorker (evaluate the modules, start, run the scheduler), runWorker_sound, holds_of_run
startFn_soundtactic proofrunWorker_soundOtactic proofrunWorker_soundterm proofholds_of_runtactic proofA run whose log meets every check, and which sends out the values ofsent, proves the worker's statement.
StandardElmMech/Prog/Guarantees.lean
The guarantees of A86: a86_step (messages handled one at a time, in queue order, every other step keeps the model and only appends messages) and a86_out_fifo (each outgoing port delivers its values in the order they were queued)
a86_steptactic proofMessages are handled one at a time, by r:p-update, in queue order, each update applying update to the model of the previous one; every other step keeps the model and only appends to the queue.
Outgoing queues
OutQ.get_fmPlus_sametactic proofOutQ.get_fmPlus_othertactic proofdispatch_outqtactic proofDispatch only appends to a queue.step_outqtactic proofEach step either delivers the head of p's queue on p, or delivers nothing on p and only appends to p's queue.a86_out_fifotactic proofThe values of each outgoing port are delivered in the order in which they joined its queue: over any execution, what is delivered on p, followed by what remains queued, is what was queued at the start followed by what each step appended, in step order.
StandardElmMech/Prog/Rulings.lean
The rulings A62, A72, A77, A79, A80 and A81 as theorems, and a66_batch_order_open: a program whose batch is delivered in either order
A62: an update with no result ends message handling; other steps go on
a62_auxtactic proofThe invariant of an execution in which the head message has no update: the model is K's and the queue of messages is B (K's queue, whose head is that message) followed by others.a62_no_updateterm proofA62: while the head message has no update, no step changes the model, and every queue of messages begins with the queue at the start.a62_wait_continuestactic proofA62: other steps go on; time can always pass.a62B_truekernel-checked (decide +kernel)a62_exampletactic proofA62, a concrete program: its update has no result, so no update step exists.
A77 and A72: flags
a77_flags_unitterm proofA77: unit flags accept every boundary value.a77_port_unittactic proofA77: a port of the unit type accepts only null.flagsVal_unittactic proofa77_start_any_flagstactic proofA77: with unit flags, the start does not depend on the flags.a72_maybe_nullterm proofA72: absent flags are null; with Maybe flags the program starts with Nothing.
A79: a failing process ends, whatever its origin, and nothing else happens
a79_fail_endsterm proofa79_spawned_succeed_endsterm proofnatLookup_some_memterm proofdispatch_preserves_existingtactic proofDispatch only adds processes with fresh identifiers: an existing entry is kept.a79_nothing_elsetactic proofA79: when a process without origin ends, nothing else happens in that step.
A80: killing an ended process changes nothing but the killer's own entry
a80_kill_endedtactic proof
A81: sleep
a81_lowertactic proofA81: the sleep action is no sooner than max(0, d) after the process reached the sleep.a81_any_latertactic proofA81: no upper bound: whenever the sleep is due by some later time, it can happen then.a81_nonfinitetactic proofA81: no condition for a non-finite delay.
A66: the order of a batch's leaves is open (the "no other guarantee" of A86)
a66_listedkernel-checked (decide +kernel)a66_reversedkernel-checked (decide +kernel)a66_batch_order_openterm proofA66: the program has executions delivering 1 then 2, and 2 then 1.
StandardElmMech/Prog/Invariant.lean
CHECK-NOT as a statement about every execution (WorkerTest.HoldsNot), per-test invariants (TestInv, TestInv.sound, holdsNot_any), and the determinism and inversion lemmas they use
The statement
noMatch_nilterm proofnoMatch_appendtactic proofnoMatch_of_Btactic proofPathL.log_constactic proof
Invariants
TestInv.exectactic proofTestInv.soundtactic proofExecL.toAnyterm proofUnder the book's host the host state never changes.holdsNot_anyterm proofAn invariant proved for the book's host (Host.any) holds under every host.
Results of the evaluator, checked by the kernel
_root_.StandardElm.Res.eq_gettactic proofappValL_detterm proofThe application's only value and log (D1).taskRedL_dettactic proofThe task step's only action, task and log, when it spawns nothing (D1).recvL_detterm proofThe message's only value and log (D1).
Shapes of values, checked by the kernel
pair_eqtactic proofunit_eqtactic prooftaskLeaf_eqtactic proofsucceed_eqtactic proofprog_eqtactic proofflat_emptytactic proofopt_eq_getDtactic proofsingle_getterm proofsingle_setterm proofset_get_selfterm proofsingle_initterm proofrecvL_task_invtactic proofnotOutcome_ne_succeedtactic proofA live process whose task is not an outcome neither sends a message nor ends.notOutcome_ne_failtactic proofflat_leaftactic proofflat_twotactic proofoutLeaf_eqtactic proof
Inversions
perm_nil'term proofperm_oneterm proofperm_twotactic proofdispatch_niltactic proofdispatch_task1tactic proofoutValue_oftactic proofdispatch_outsterm proofDispatching out leaves of one port p, whose queue is the only one, appends their values.hostAllows_echo_intactic proofThe echo host sends back on i only the oldest value it holds.hostAllows_echo_outtactic proofA value delivered on o joins the echo host's state; on another port, nothing changes.hostAllows_othertactic proofOther events leave the host's state.acceptMsgsL_onetactic proofThe messages of one subscription c that receives x as the evaluator computes, with no choice.platStep_emptyterm proof
StandardElmMech/Prog/T1.lean
Finding T1: an execution of StandardA81SleepBeyond32BitsTest the book allows that logs the line its CHECK-NOT forbids (t1_a81_long_sleep_may_end)
t1Check_truekernel-checked (decide +kernel)t1_a81_long_sleep_may_endtactic proofFinding T1: r:p-wait lets 3e9 ms pass before the 200 ms sleep's action is taken; then the long sleep's action is ready, and the process logs before it is killed.
StandardElmMech/Src/Graph.lean
Reachability on graphs over 0 .. n-1 (Plus, Reach) and its decider, proved correct (plusB_iff, reachB_iff)
Plus.lttactic proofPlus.firsttactic proofThe first step of a path.
Counting the members of filters
len_filter_monoterm prooflen_filter_eqterm proof
Facts about growing
mem_growtactic proofmem_starttactic proofshape_growterm proofshape_lttactic proofshape_lentactic proofshape_selftactic proofA shaped set is the filter ofrange nby its own membership.grow_geterm proofclosed_of_lentactic proofA shaped set that does not grow is closed.closed_of_fulltactic proofA shaped set with n members is all ofrange n, so closed.iter_propstactic proofplusSet_closedtactic proofstart_subterm proofiter_soundterm proofreach_closedtactic proofplusB_ifftactic proofreachB_ifftactic proof
StandardElmMech/Src/Restrictions.lean
The 27 syntactic restrictions decidable on a syntax tree, each a Prop as the book states it, decidable; ModuleOK, ProgramOK, SynOK, ModulesSynOK
Deciders
decSynOK_iffterm proofsynOK_of_decterm proofnot_synOK_of_dectactic proof
StandardElmMech/Src/GroupingProof.lean
components_valid: the canonical grouping is one the book allows (ValidNumbering)
Mutual reachability
reach_reflterm proofreach_transtactic proofreach_stepterm proofmr_reflterm proofmr_symmterm proofmr_transterm proof
The reach table
reachIn_ifftactic proofmem_clstactic proofself_mem_clsterm proofcls_sortedtactic proof
The classes partition `range n`
disj_symmterm proofclasses_eqterm proofstepC_invtactic prooffoldl_invterm proofclasses_invtactic proofclasses_covertactic proofclasses_lengthtactic proof
Among the unplaced classes one is ready
exists_minterm proofcls_ltterm proofexists_readytactic proof
Placing
inv_nonemptytactic proofinv_noduptactic proofinv_permterm proofcover_permterm proofplace_specterm proofreadyList_getterm proof
The canonical grouping is valid
flatten_nodupterm proofcomponents_validtactic proof
StandardElmMech/Src/AliasOrderProof.lean
aliasOrder_valid: the canonical order of aliases is one the book allows
aliasOrderAux_eqterm proofexists_idxterm proofThe index of an alias of a list with distinct names.perm_filter_nametactic proofA name-distinct list: removing an alias by name removes exactly it.names_distincttactic proofexists_aReadytactic proofaliasOrderAux_specterm proofaReadyList_getterm proofaliasOrder_validtactic proof
StandardElmMech/Src/DerivesTo.lean
The derived forms as the book states them, a relation (DerivesE, DerivesTo), and derive_derivesTo
groupLet_eqterm proof
Modules
deriveDef_derivestactic prooftopBinds_relterm proofaliases_namesterm proofaliasDecls_eqterm proofplus_congrtactic proofderive_derivesTotactic proofUnder the restrictions of the module, the function's choices are among those the appendix allows.
StandardElmMech/Src/SynSet.lean
The restrictions of the set of a program's modules (SynOKSet) and the refusals of every order
synOKSet_of_synOKterm proofmodulesSynOKSet_ofterm proof
Refusals whatever the order
import_beforeterm proofIn a sequence meeting res:program-import-order and res:program-modules-distinct, a module that imports a module of the program comes after it.not_twoCycletactic proofsetFails_permtactic prooftwoCycle_permtactic proofnot_setFails_oftactic proofA sequence meeting the restrictions fails none of the set conditions.notSynOKSet_of_setFailstactic proofnotSynOKSet_of_twoCycletactic proofnotModulesSynOKSet_of_setFailstactic proofnotModulesSynOKSet_of_twoCycletactic proof
StandardElmMech/Stat/Objects.lean
The static semantic objects (plan step 9): type variables with their classes, row variables, type names, types, rows, schemes, type functions, environments, contexts, static bases
Rows
Row.subB_ifftactic proof
Well-formedness
Ty.okB_ifftactic proof
StandardElmMech/Stat/FMap.lean
Finite maps for the static semantics (association lists, first occurrence wins), with their lemmas
find?_consterm prooffind?_appendtactic prooffind?_filter_nottactic prooffind?_isSome_ifftactic prooffind?_modifytactic proof
StandardElmMech/Stat/Subst.lean
Substitutions, the classes and their meets, admissible types (Adm, adm_iff, adm_mono)
Admissible types (fig:static-core-admissible)
admComp_ifftactic proofadm_ifftactic proofSubst.respectsB_ifftactic proof
Group 1: classes
Cls.meet_spectactic proofCls.meet_nonetactic proofCls.le_transtactic proofadm_monotactic proofThe property of sec:static-core-types, first part: κ ≤ κ' gives Adm κ ⊆ Adm κ'.
StandardElmMech/Stat/Schemes.lean
Type functions, schemes and their canonical form, instances (Gen, genAt), explicit variables (NewFor), closure (closGroup, A93)
Binding variables to types
gen_of_genAttactic proofgenAt_of_gentactic proof
Explicit type variables (sec:static-core-explicit)
mem_dedupLterm proofname?_nameVartactic proofnameVar_namedtactic proofmem_newU0tactic proofmem_namesUtactic proofnewFor_of_newForBtactic proof
StandardElmMech/Stat/Deterministic.lean
The deterministic parts as functions, each sound for its relation: type expressions, imports and exposing, type declarations given their names (checkTypes), ports
Type expressions
elabTy_soundterm proofelabTyRow_soundterm proofelabTyRowOpt_soundterm proofelabTyOpt_soundterm proofelabTyList_soundterm proof
Exposing lists and imports
elabItem_soundtactic proofelabItems_soundterm proofelabExpList_soundtactic proofelabImports_soundterm proof
Type declarations, given the type names they generate
elabConBind_soundterm proofnamesNewB_spectactic proofelabDatBind_soundterm proofelabTypBind_soundtactic proofelabTypBinds_soundterm proofcheckTypes_fixtactic proofcheckTypes_closedtactic proofcheckTypesFix_soundtactic proofcheckTypes_soundterm proof
StandardElmMech/Stat/Annotated.lean
Annotated phrases (D10: a derivation is a phrase with the objects its rules choose) and the checker (checkExp, checkModule, checkProgram)
The types at the nodes
nodesOkB_appendtactic proofnodesOkB_singletactic proofnodesOkB_nodesAtPatterm proofnodesOkB_nodesPatRowterm proofnodesOkB_nodesPatRowOptterm proofnodesOkB_nodesPatterm proofnodesOkB_nodesPatOptterm proofnodesOkB_nodesAtPatsterm proofnodesOkB_nodesAtExpterm proofnodesOkB_nodesExpRowterm proofnodesOkB_nodesExpRowOptterm proofnodesOkB_nodesExpterm proofnodesOkB_nodesExpOptterm proofnodesOkB_nodesMatchterm proofnodesOkB_nodesMatchOptterm proofnodesOkB_nodesDecterm proofnodesOkB_nodesValBindterm proofnodesOkB_nodesValBindOptterm proof
The checker
checkExpS_of_checkExptactic proofnodesOkB_ifftactic proofokB_of_checkExptactic proofAt every node of a derivation the checker accepts, the types areTy.okB.checkExp_ifftactic proof
Modules
AModule.result_of_ctxtactic proof
StandardElmMech/Stat/CheckSound.lean
The checker is sound: a phrase that checks has a derivation by the rules of Chapters 4 and 5 (checkExp_sound, checkModule_sound)
isConTy_spectactic proofisListTy_spectactic proofisRecordTy_spectactic prooffn_of_matchtactic proof
Patterns
checkAtPat_soundterm proofcheckPatRow_soundterm proofcheckPatRowOpt_soundterm proofcheckPat_soundterm proofcheckPatOpt_soundterm proofcheckAtPatList_soundterm proof
Expressions
checkAnn_soundtactic prooflookup_gentactic proofcheckAtExp_soundterm proofcheckExpRow_soundterm proofcheckExpRowOpt_soundterm proofcheckExpS_soundterm proofcheckExpOpt_soundterm proofcheckMatch_soundterm proofcheckMatchOptAt_soundterm proofcheckMRule_soundterm proofcheckDec_soundterm proofcheckValBind_soundterm proofcheckValBindOpt_soundterm proofcheckExp_soundterm proof
Modules
portB_soundterm proofportRowB_soundterm proofelabPort_soundtactic proofcheckTopDec_soundterm proofcheckTopDecOpt_soundtactic proofcheckModule_soundtactic proofD10: a certificate that checks is a derivation of r:sm-module.
StandardElmMech/Stat/Principal.lean
Instances of derivations, principal derivations of phrases and modules, InferPrincipalFor (D11: what the inference returns is principal)
The Core (sec:static-core-principal)
principal_uniqueterm proof
StandardElmMech/Stat/PatternsProof.lean
The pattern decider is correct: every type is inhabited (inhabited), useful_spec, exhDec_sound, irrDec_sound
Typed patterns
PTypedList.length_eqterm proofPTypedList.appendterm proofPTypedList.wildsterm proofPTypedList.splitterm proof
Inhabitants: construction and decomposition
Inh.exttactic proofmkCon_subtactic proofchildren_lengthtactic proofchildren_getElemtactic proofdecomposetactic proofIsInh.roottactic proofThe root of an inhabitant: a node given by a clause, nothing beyond its arity.IsInh.childtactic proofisInh_mkContactic proofisInh_leaftactic proof
A97: every type has an inhabitant
ctorsAt_argTystactic proofargTys_ctorsAttactic prooflitKind_spectactic proofcanonNode_clausetactic proofcanonInh_subtactic proofinhabitedtactic proofA97: every type has an inhabitant, in both modes.
Rows of patterns and vectors of inhabitants
RowCovers.lengthterm proofRowCovers.appendterm proofRowCovers.wildsterm proofWT.lengthterm proofWT.appendterm proofWT.splitterm proofWT.ofGetterm proofWT.getterm proofcoversArgs_iffterm proofcovers_con_ifftactic proofchildren_mkContactic proofcovers_mkCon_ifftactic proofnot_covers_leaf_contactic proofcovers_leaf_dentactic proofnot_covers_mkCon_dentactic proof
Specialisation and the default matrix
specializeCon_fwdterm proofspecializeCon_bwdterm proofspecializeDen_fwdterm proofspecializeDen_bwdterm proofdefaultM_bwdterm proofA row of the default matrix covers hr: its row of P covers h :: hr, whatever h.defaultM_fwdterm proofA row of P covering h :: hr whose first pattern is not a wildcard covers h by a head the node h does not match; so a row of the default matrix covers hr.
Small facts the induction uses
anyOpt_trueterm proofanyOpt_falseterm proofmem_headConstactic proofmem_headDenstactic prooflitCandidate_spectactic proofmissingDen_spectactic proofptyped_dentactic proofptyped_contactic proofspecializeCon_typedterm proofspecializeDen_typedterm proofdefaultM_typedterm proofcon_rows_lengthtactic proofRows typed at τ :: τr whose head is constructor k have as many arguments as k takes.
The three cases of a wildcard
useful_default_fwdtactic proofuseful_default_bwdtactic proofuseful_of_spectactic proofA constructor that applies at τ: a vector useful after specialising by it gives one for the wildcard.useful_spec_oftactic proofAn inhabitant whose root is constructor k with argument types as, decomposed.spec_of_usefultactic proof
Usefulness is decided
useful_spectactic proof
The deciders
typedB_soundterm proofexhDec_soundtactic proofres:core-exhaustiveness, decided.irrDec_soundtactic proofres:core-irredundancy, decided.matchOKB_soundtactic proofexhOneB_soundtactic proof
The further restrictions of a derivation, decided
furtherAtExpB_soundterm prooffurtherExpRowB_soundterm prooffurtherExpRowOptB_soundterm prooffurtherExpB_soundterm prooffurtherExpOptB_soundterm prooffurtherMatchB_soundterm prooffurtherMatchOptB_soundterm prooffurtherDecB_soundterm prooffurtherValBindB_soundterm prooffurtherValBindOptB_soundterm prooffurtherTopDecB_soundterm prooffurtherModInB_soundtactic proof
StandardElmMech/Stat/Legal.lean
The master theorems: a program whose inferred derivation checks, meets the further restrictions and gives main a Chapter 9 type is legal, under D11 (legal_of_infer1, legal_of_infer)
The conditions of Chapter 9, decided
portsDisjointB_soundtactic proofviewTy_soundtactic proofelProgram_maintactic proofThe last step of a program: its main module's derivation givesmaina type by one of the two rules.
One-module programs
inferModuleIn_importstactic prooflegal_of_infer1tactic proof
Programs of several modules
inferProgramFrom_constactic proofprogCheck_inferterm proofprogCheck_elterm prooflegal_of_infertactic proofLegality of a program of any number of modules, everything computed by the kernel.
StandardElmMech/Stat/Refusals.lean
Refusals (milestone 9d): inversion of Chapter 9's rules, and the lemmas that turn "no derivation checks", "no derivation meets the further restrictions" or "no derivation gives main a Chapter 9 type" into ¬ LegalProgram, with no hypothesis about principality
Inversion of the rules of Chapter 9
elProgram_invtactic proofprincipalModDer_checktactic proof
The refusals
not_legal_of_synterm proofA program that breaks a syntactic restriction (whatever the order of its modules, step 8).not_legal_of_noDerivtactic proofThe first module has no derivation.not_legal_of_noDeriv2tactic proofThe second module has no derivation, whatever the derivation of the first.not_legal_of_furthertactic proofNo derivation of the one module meets the further restrictions.not_legal_of_maintactic proofNo derivation of the one module givesmaina type of Chapter 9.noDeriv_of_importstactic proofA module whose imports do not elaborate has no derivation.not_legal_of_importstactic proof
StandardElmMech/Stat/RefuseScope.lean
Refusals by scope, constructor arity and imports, for one module and for a module after a helper (scopeFailB)
Arities
apply_arrowsterm proofarrows_lenterm proofgenAt_aritytactic proofarityOf_specterm proofarity_canontactic proofarity_clostactic proof
Finite maps
find?_mapVtactic proofkeys_mapVtactic proofmapV_modifytactic proofmapV_foldl_modifytactic proofmapV_plusAlltactic proofkeys_modifytactic proofkeysIn_niltactic proofkeysIn_singletactic proofkeysIn_modifytactic proofkeysIn_monoterm proofkeysIn_foldltactic proofkeysIn_plusAllterm proofkeysIn_mapVtactic prooffind?_vstactic proof
Sound value environments and the extension of shapes
vesound_of_keysIntactic proofvesound_modifytactic proofvesound_clostactic proofabs_exttactic prooflookupExt_plusVEtactic proofabs_plusVEterm proofabs_plusUterm proofabs_ctxShapetactic proof
The keys of the value environments of patterns and bindings
keys_atPatterm proofkeys_patRowterm proofkeys_patRowOptterm proofkeys_patterm proofkeys_patOptterm proofkeys_atPatListterm proofkeys_valBindterm proofkeysIn_closGrouptactic proof
The bare checker is sound
conOK_oftactic prooflength_tyListterm prooflength_eraseListterm proofsc_atPatterm proofsc_patterm proofsc_patOptterm proofsc_atPatListterm proofisSome_of_lookuptactic proofkeys_dectactic proofThe environment a declaration adds binds only the variables of its bindings.sc_atExpterm proofsc_expRowterm proofsc_expRowOptterm proofsc_expterm proofsc_expOptterm proofsc_matchterm proofsc_matchOptterm proofsc_mruleterm proofsc_decterm proofsc_valBindterm proofsc_valBindOptterm proof
Top-level declarations
vesound_nilterm proofvesound_singletactic proofelabTyList_lengthterm proofvesound_conBindterm proofvesound_datBindterm proofkeysIn_closVEtactic proofkeysIn_typBindtactic proofkeysIn_typBindsterm proofvesound_typBindstactic proofvesound_checkTypestactic prooftopSound_plustactic proofelabPort_shapetactic prooftopSoundterm prooflookupExt_oplusEtactic proofsc_topterm proofsc_topOpttactic proof
One module: the shape of a concrete import context
noDeriv_of_ctxtactic proofnoDeriv_scope1tactic proof
The context of a provider map binds only what the map provides
find?_addQterm proofenvKeys_monoterm proofenvKeys_addQterm proofenvKeys_steptactic proofenvKeys_envOfterm proofabs_piShapetactic proof
Skeletons of interfaces: what the elaboration of imports reads of them
keys_ofStatusVtactic proofany_find?_mapVtactic proofelabItem_sktactic proofelabItems_skterm proofdom_sktactic proofelabExpList_sktactic proofelabImports_sktactic proof
The skeleton of a module's interface is the same in every derivation
conBind_skterm proofclosVE_sktactic proofdatBind_skterm prooftypBind_sktactic prooftypBinds_skterm proofcheckTypes_sktactic proofelabPort_TEtactic proofteSk_topterm proofteSk_topOpttactic proofskI_plustactic proofexposeItem_sktactic proofexposeItems_skterm proof
Two modules: the second module's imports, or its body, fail for every derivation of the first
result_invtactic proofnoDeriv_scope2tactic proofnot_legal_of_scopeFailBtactic proof
StandardElmMech/Stat/RefuseTypes.lean
Refusals by type expressions (aliases, constructor arguments, annotations, ports) and by the type of main (typesFailB, mainFailB), for every choice of generated names and variable sorts
Renaming type names
mapTys_eqterm proofmapRow_eqterm prooffind?_map_sndterm prooffind?_map_keyterm proofmergeF_mapterm proofmerge_maptactic proofmodifyF_mapterm proofmodify_maptactic proofmapRow_rowMaptactic proofapply_maptactic proofapplyRow_mapterm proofapplyList_mapterm proofbindSubst_mapterm prooftyFcnApply_maptactic proofrenumber_fixedterm proofcanon_maptactic prooftoFcn_maptactic proof
Simulation of the elaboration of type expressions
mem_unionLtactic proofUEq.plusUtactic prooftupleTy_maptactic proofmodify_single_maptactic proofelabTy_simterm proofelabTyRow_simterm proofelabTyRowOpt_simterm proofelabTyOpt_simterm proofelabTyList_simterm proof
Lookups in modified contexts
lookupTy_noneterm prooflookupTy_oplusTE_nonetactic prooflookupTy_oplusTE_someterm prooflookupTy_oplusE_nonetactic prooflookupTy_oplusE_sometactic prooflookupTy_someterm proofsameTy_oplusE_typestactic proofsameTy_oplusE_ofVEtactic proofsameTy_oplusE_plustactic prooflookSim_of_sametactic prooflookSim_plusUterm prooflookSim_plusVEterm proof
The abstract context
col_fcoltactic proofCol.builtinsterm proofInv.sameterm proofT_oplusEtactic proofInv.ofVEterm proofinv_basetactic proof
Sorts of the new variables of an annotation
assigns_coverterm proofnames_of_newFortactic proofannCands_covertactic proofEvery U' an annotation may have agrees, on named variables, with a candidate.uEq_unionL_nilterm proofuEq_reflterm proof
Type declarations
typBind_shapetactic prooftypBinds_foldterm proofconBind_okterm proofdatBind_factsterm prooffind?_mem_valsterm proofname?_toFcntactic proofaliases_innerterm proofleaf_coretactic prooftypes_leaftactic proof
Annotations and ports
vbRefuted_vartactic proofportB_maptactic proofportRowB_mapterm proofportShapeB_maptactic proofelabPort_shapetactic proofann_simtactic proofAn annotation elaborated in a derivation's context elaborates, collapsed, at a candidate.vb_not_refutedterm proofport_not_failstactic proof
The module's declarations
The type of `main`
applyList_lengthterm proofbadHead_applytactic proofbadHead_canontactic proofbadHead_maptactic proofnot_mainOKtactic proofforcedBad_soundterm proofforcedBadAt_soundterm proofvbNoMain_vartactic proofvbMainBad_vartactic proofve_vartactic proofvb_noMaintactic proofvb_mainBadterm proofno_mainterm proofmain_badterm proofimportCtx_UTtactic proofresultIn_checktactic proofbody_erasetactic proofimports_erasetactic proofnot_legal_of_typesFailBtactic proofnot_legal_of_mainFailBtactic proof
StandardElmMech/Stat/RefuseAll.lean
The refusal deciders certify tries, and the refusals of step 8's syntactic restrictions for one-module programs and texts without main
synOK_of_modulestactic proofSynOKreads only the modules of a program.not_synOKSet_of_onetactic proofA program of one module has one order: if it breaks the restrictions, it is refused (step 8 refuses such a program in its canonical order only).not_legal_of_syn_oneterm proofThe refusal of a one-module program step 8 refuses in its canonical order.modulesSynOK_of_synOKterm proofnot_legal_of_modsyntactic proofA text withoutmain(a module tested alone) that breaks a restriction other than res:program-main, whatever the order of its modules.not_legal_of_modsyn_onetactic proofThe same for a text of one module that step 8 refuses in its canonical order.
StandardElmMech/Stat/CopyLoop.lean
The copy loop terminates within 2^k + 1 rounds, makes the least set of copies closed under requests, at most 2^k (copyLoop_fuel, copyLoop_least, copies_le_pow)
Assignments
length_flatMap_twoterm proofallAssignments_lengthtactic proofallAssignments_mem_lengthterm proofallAssignments_completeterm prooflength_le_powtactic proofDistinct assignments of length k are at most 2^k.
`dedupFirst`
mem_dedupFirstterm proofnodup_dedupFirstterm proof
`translateAll`
translateAll_okterm prooftranslateAll_errorterm proof
One round
mem_todoOftactic proofcopyLoop_succtactic proofA round: stop when nothing is to be translated, else translate and recur.mem_next_pendingtactic proof
The invariant
keys_appendtactic proofcopyLoop_invterm proofWhat the loop returns: every pending and made assignment is made; the made ones are the least set closed under requests above the pending and made ones; and they are closed when the made ones' requests are pending or made.copyLoop_leasttactic proofThe copies made: the least set of assignments that contains the initial ones and is closed under the requests of the copies it contains (sec:dynamic-core-numbers, A59, A87).
Fuel and the number of copies
copyLoop_lengthsterm proofThe loop's invariant on lengths: made assignments are distinct and of length k.copyLoop_fuelterm proofWith fuel 2^k + 1 the loop does not run out of fuel unless a translation fails.copies_le_powtactic proofAt most 2^k copies (the book's finiteness remark), and distinct.
StandardElmMech/Stat/Pipeline.lean
SpecOf, DynOf (in Lib.Btest for a view, Mod.Btest [] for a worker: dynBasis), ProgramSem (r:p-program), D11For; copy names, payload types and main (copyName_inj, toPTy_isSome_iff, mainKind_worker_iff, mainKind_view_iff); the pipeline theorems (specOf_of_endToEnd, programSem_of_legal)
Copy names
Assignment.isDefault_defaulttactic proofcopyName_defaulttactic proofkey_toListterm proofnum_key_toListtactic proofkeyChars_injterm proofappend_dollar_injterm proofThe part before the first$.isDefault_ifftactic proofcopyName_injtactic proofCopy names are new and distinct ($spells no identifier, syntax-core).
Payload types and `main`
toPTy_isSometerm prooftoPFields_isSometerm proofportRowB_of_allterm proofportB_completetactic prooftoPTy_isSome_ifftactic prooffig:static-modules-port:toPTyis defined exactly on the types ofPort.port_of_toPTyterm proofmainKind_worker_ifftactic proofmainKind_view_ifftactic proof
The pipeline
checkProgram_of_progResultstactic proofendToEnd_oktactic proofWhat a successful run of the pipeline gives: the derivation the inference returned, the results of its modules, and the reduced program.principalProgDeriv_of_endToEndtactic proofspecOf_of_endToEndterm proofA run of the pipeline gives a specialisation of the program, under D11 for it.bases_of_progResultsterm proofprogResults_lengthterm proofmainScheme_someterm proofelProgram_main_of_kindtactic proofr:p-stat-main-program or r:p-stat-main-view frommainKind.elProgram_of_resultsterm proofstatProgram_of_endToEndtactic proofA run of the pipeline gives the static premise of r:p-program, under D11 for the program and its further restrictions.programSem_of_spectactic proofr:p-program with both premises, from a run of the pipeline, the static premise, and a value of the reduced modules.programSem_of_legalterm proofThe same, with the static premise from step 9's legality of the program (legal_X h).
Values of Part I's programs
value_of_viewCheckstactic proofA check statement includes a value of the program (the logged relation's forget, D4).value_of_holdstactic proofA worker's execution starts from the value ofmain.dynOf_viewterm proofdynOf_workerterm proof
StandardElmMech/Stat/RenameCounterexample.lean
Two principal derivations of one program that specialisation once told apart (finding of 2026-11-12), kept as a regression theorem (ce_equal)
ceSwap_applyterm proofceSwap_injtactic proofceSwap_clstactic proofrenameSecond_erasetactic proofce_checkskernel-checked (decide +kernel)Both check, in the bases they build from the test basis.ce_erasekernel-checked (decide +kernel)The inferred derivation is a derivation of the program.ce_progDerivterm proofce_equalkernel-checked (decide +kernel)With the fix, the two principal program derivations give the same reduced program.
StandardElmMech/Stat/DupValuesCounterexample.lean
Two derivations with the same nodes that differ only in an instance specialisation once read through a scope the checker disagrees with (a module with two top-level x); specialisation now reads instances off the occurrence's type (same)
not_valuesDistincttactic proofThe program breaks res:modules-values-distinct.factskernel-checked (decide +kernel)Both are derivations of the program, and generate no type name.nodes_eqkernel-checked (decide +kernel)Their nodes are equal.samekernel-checked (decide +kernel)Specialisation gives the same for both: no reduced program (x's instance is not a number).
StandardElmMech/Stat/SpecExamples.lean
The rulings on small programs: A27 (a free number is Float, annotations bind), A87 (the default copy is made), A93 (vacuous variables), polymorphic recursion, copy names, abs$Int, exposing items, payload types, kinds of main, eight copies, renaming invariance, record-pattern copies
A27: a free `number` is Float; a variable bound by an annotation is not defaulted
a27_float_defaultkernel-checked (decide +kernel)A27 (revised 2026-11-10; dynamic-core, "Defaulting of number"): thenumberof2 ^ -1is fixed by nothing, so it is Float, and both integer constants (2, and the1of the derivedBasics.negate 1) are constants at Float.a27_annotation_boundkernel-checked (decide +kernel)A27 (clarification of 2026-11-10), dynamic-core'sf/gexample: thenumberofxis bound byf's annotation, not by the closure ofg, and is not defaulted.
A87: the default copy is always made; a variable the declaration does not quantify
a87_default_copy_madekernel-checked (decide +kernel)A87 (with A27 and A59), dynamic-core'scheck/xexample:mainusesxonly at Int, yet the default copyx(at Float, where2 ^ -1is 0.5 andcheckreachesDebug.todo) is emitted besidex$Int; each copy ofxuses the copy ofcheckat its own assignment, and its constants are at its own type.a87_vacuous_innerkernel-checked (decide +kernel)A87, A43, A27 (dynamic-core, after thecheckexample): thenumberof2 ^ -1(and of the0it is compared with) is not mentioned by the type ofy, so it is not a variable of the declaration: no closure generalises it, and it is Float in every copy ofy,y$Intincluded.
A93: a `number` variable of a group that one binding's type does not mention
a93_mutualkernel-checked (decide +kernel)A93 (option (b), with A27's Float default; dynamic-core, "Every binding of a declaration quantifies all the variables of class number of the declaration"):f's type does not mention thenumbervariablebofg'sy, butf's scheme quantifies it; atf 3nothing fixes it, so it is Float, as aren's and the result's, whichf 3leaves free.a93_vacuous_witnesskernel-checked (decide +kernel)A93's example with the instance of the vacuous variable atf 3set to Int by hand in the annotated phrase that inference gives (where it is a freenumbervariable, which the book's principal derivation does not determine): the reduced program is the same,a93_mutual's.
The choices of the plan
spec_polyreckernel-checked (decide +kernel)Polymorphic recursion through an annotation (dynamic-core: "even when a binding is used recursively at an instance other than its own"; Choices, items 4 and 5):mainusesfat Int; insidef$Int,f 1.5is an occurrence at Float, sof$Intrequests the default copyf.spec_two_vars_orderkernel-checked (decide +kernel)The canonical order of a declaration'snumbervariables is their first occurrence in the bindings' types (Choices, item 2), not the order of their names:numberboccurs beforenumbera, so the copy atnumberb = Int,numbera = Floatisr$Int$Float, wherex + 1takes1at Int andy + 1at Float.spec_basis_abskernel-checked (decide +kernel)A value of the basis written in Elm (abs, Appendix D) is copied like a program's: its occurrences at Int, unqualified and qualified, refer toabs$IntandBasics.abs$Int, and the exposing itemabsof the import stands forabs, abs$Int(sec:dynamic-modules-reduced).spec_exposingkernel-checked (decide +kernel)Copies across modules (sec:dynamic-modules-reduced):Amakesf$IntbecauseMainrequests it (modules are specialised last to first);A's header itemfandMain's import itemfeach stand forf, f$Int.spec_rename_invariantkernel-checked (decide +kernel)An instance ofreduceProgram_rename(the invariance lemma: specialisation reads a type only through what a renaming preserves, Choices, item 2): the annotated program inference gives forspec_exposing, renamed byswapFresh, reduces to the same program.spec_rename_invariant_a93kernel-checked (decide +kernel)The same on A93's example, whose group'snumbervariables are fresh ones (the instance atf 3is renamed), so that the canonical order of the variables and the copies are read through the renaming.spec_port_payloadkernel-checked (decide +kernel)A port keeps its direction and payload type as elaboration records them (sec:dynamic-modules-reduced): the alias is expanded and the record's fields are sorted by label.spec_main_kindskernel-checked (decide +kernel)The kind of a program and its flags type, from the scheme ofmain(r:p-stat-main-view, r:p-stat-main-program;mainKind): a view, whose flags type is not read and is()(Choices, item 1; Translator changes, item 3); a worker whose flags type()itsinitfixes; a worker whose flags typeIntits annotation fixes.spec_copy_boundkernel-checked (decide +kernel)The bound of dynamic-core ("a declaration with k variables of class number has at most 2^k copies"), reached: three variables used at all eight assignments give eight copies, the default copy first and then the others in the lexicographic order of their assignments, Float before Int (Choices, item 4), whatever the order of the uses.spec_record_pattern_copykernel-checked (decide +kernel)A copy of a destructuring binding with a record pattern (ruling A99, which closes step 10's Issues, item 4):xis used at Int, so the binding has its default copy{ x = x } = { x = 1 }at Float and the copy at Int{ x = x$Int } = { x = 1 }, which binds the new variablex$Intto the same fieldx; the use refers to the copy at Int.
StandardElmMech/Stat/Complete/Discharge.lean
Step 11, milestone (g): Stat.wCheck, legal_of_W, ident_of_wCheck, programSem_of_wCheck (D11 discharged test by test), not_legal_of_wMainVar (A96's flags refusal), principalExistsCore_of_covers, principalExistsMod_of_covers, d11For_of_agree; Lean's pipeline with W, endToEndW (step 10's endToEnd with W in place of step 9's inference), with endToEndW_of_wCheck (the per-test spec_ from wcheck_, without a second run of the inference), specOf_of_endToEndW, ident_of_endToEndW, programSem_of_endToEndW (step 10's statements, without D11); wCheckIn, wCheck_of_ctx (the W check of a one-module program with the context of its imports given by a lemma ctx_<name>_eq, so the kernel does not compute it per test: an end-to-end shard of 20 tests takes 32 s instead of 98 s)
The check
furtherAll_modterm proofwCheck_invtactic proofWhat a successful check says.
Legality, the specialisation of the program, its meaning
legal_of_wChecktactic proofStep 9's legality, without hypothesis: the program is legal when W's derivation of it passes the checks.specOf_of_wChecktactic proofThe reduced program the check names is a specialisation of the program.typesOrdered_of_inferProgramWterm proofEvery module W elaborates has ordered type declarations.ident_of_wChecktactic proofStep 10'sident_X, without hypothesis: the specialisation of the program is unique, and is the reduced program the check names.programSem_of_wChecktactic proofStep 10'smean_X, without hypothesis: r:p-program with both premises, from the check and a value of the reduced modules (Part I'st_X).legal_of_Wterm proofThe per-test forms, in the test basis.finish_eq_Intactic proofinferModuleW_eq_Intactic proofwCheck_of_ctxtactic proofA check with the context given is the check.endToEndW_oktactic proofWhat a successful run of the pipeline with W gives.endToEndW_of_wChecktactic proofA W check that names a reduced program says that the pipeline with W gives it.specOf_of_endToEndWtactic proofStep 10'sspecOf_of_endToEndfor the pipeline with W, without D11: what it gives is a specialisation of the program.ident_of_endToEndWtactic proofStep 10'sident_of_spec'for the pipeline with W, without D11: the specialisation of the program is unique, and is what the pipeline with W gives.programSem_of_endToEndWtactic proofStep 10'sprogramSem_of_legalfor the pipeline with W, without D11.
A96: flags of a type variable (StandardA96NumberFlagsTest)
find?_map_sndterm proofapplyList_lengthterm proofgetD_apply_contactic proofdflt_con3tactic proofThe default of a scheme whose body is(τ1, τ2, τ3) tis a type of three arguments.not_legal_of_wMainVartactic proofA96 (correction 3, and the comment after r:p-stat-main-view): when W's principal scheme ofmaingives the flags a type variable, no derivation of the program has a type of Chapter 9 formain.not_legal_of_wMainVar_testterm proofA96's refusal, in the test basis.principal_of_inferExpWDterm proofA Core phrase on which W succeeds has a principal derivation.principalExistsCore_of_coverstactic proofsec:static-core-principal, from W's coverage.principalMod_of_inferModuleWterm proofA module on which W succeeds has a principal derivation.principalExistsMod_of_coverstactic proofsec:static-modules-principal, from W's coverage.d11For_of_agreeterm proofD11 for one program (step 10'sD11For, about step 9's inference) holds wherever step 9's inference returns what W returns.
StandardElmMech/Theorems.lean
The command #mod_program_theorems (one theorem per program, in module form, in Lib.Btest; tagged [library] when the program names a core library value), budgetNative, the rulings stated directly, and theorems that D1 makes possible (a43_one_unique, a51_one_choice, log_order_demo)
The values of Basics written in Elm (sec:appendix-dynamic-basis-elm)
elmText_derivationtactic proofA textvar atpat1 ... atpatn = exp, not recursive, evaluates in E by r:d-dec-nonrec (with r:d-valbind-var and r:d-exp-lambda) to the closure that InitialBasis.lean binds.elmTexts_nonreckernel-checked (decide +kernel)elmTexts_evaltactic proofEvery text of the fragment evaluates in E_K to the value VE_elm binds.never_evalkernel-checked (decide +kernel)The text ofnever(recursive) evaluates in E_K, by r:d-dec-rec, to Rec of its closure.never_valueterm proofME0 bindsneverto that value.
Statements that the oracle evaluator makes possible (D1)
a43_one_uniquekernel-checked (decide +kernel)A43: 1 ^ -1 has the value 1 and no other: the evaluator reads no choice, so bynostuckevery derivation gives it.a51_one_choicekernel-checked (decide +kernel)A51:(\x -> x) == (\x -> x)reads exactly one choice of the oracle, whichever it is.log_order_demokernel-checked (decide +kernel)D4:Debug.log "a" 1 + Debug.log "b" 2logs a then b in the logged relation's order, one of the orders the book allows (A58).
The rulings, stated directly (kernel-checked)
a43_onekernel-checked (decide +kernel)A43: 1 ^ -1 is 1 (eco: 0).a43_minus_one_oddkernel-checked (decide +kernel)A43: (-1) ^ -3 is -1 (eco: 0).a43_minus_one_evenkernel-checked (decide +kernel)A43: (-1) ^ -2 is 1 (eco: 0).a43_apply_singletontactic proofA43: APPLY(pow, 1, -1) = {1}: the set has one member, so the definition gives no other value for 1 ^ -1 at this step.a42_idivkernel-checked (decide +kernel)A42: 3 // 0, modBy 0 3 and remainderBy 0 3 are all 0.a42_modBykernel-checked (decide +kernel)a42_remainderBykernel-checked (decide +kernel)a48_floatnative_decide (trusts the compiled evaluator)A48: at floats APPLY(max) and APPLY(min) are IEEE 754-2019 maximum and minimum, whatever the order of the arguments: NaN when either is NaN, +0 for max and -0 for min of the two zeros.a48_int_maxkernel-checked (decide +kernel)A48: at Int, max and min give the elm/core text's result (kernel-checked).a48_int_minkernel-checked (decide +kernel)a49_apply_floatnative_decide (trusts the compiled evaluator)A49: at floats APPLY(clamp, lo, hi, x) is min (max x lo) hi with the IEEE 754-2019 minimum and maximum: hi when lo > hi, NaN when any argument is NaN, +0 for clamp 0 1 -0.a49_float_lo_gt_hinative_decide (trusts the compiled evaluator)A49 through the rules:clamp 10 0 5at Float evaluates to +0 (hi), by r:d-app-basic-partial and r:d-app-basic-apply with APPLY(clamp). [native]a49_float_nan_boundnative_decide (trusts the compiled evaluator)A49:clamp nan 1 0.5at Float evaluates to NaN. [native]a49_float_signed_zeronative_decide (trusts the compiled evaluator)A49:clamp 0 1 -0at Float evaluates to +0. [native]a49_int_lo_gt_hikernel-checked (decide +kernel)A49: at Int, clamp gives the elm/core text's result:clamp 10 0 5is 10 (lo, since 5 < 10), kernel-checked.a49_int_apply_singletontactic proofA49: APPLY(clamp, 10, 0, 5) = {10} at Int: the set has one member.a51_truekernel-checked (decide +kernel)A51:(\x -> x) == (\x -> x)evaluates to True ...a51_falsekernel-checked (decide +kernel)... and to False: both results are derivable.a44_conversionsnative_decide (trusts the compiled evaluator)A44: the conversions to Int at 2.5, -2.5, NaN, the infinities and 1e300, in that order:roundrounds a half upward (x + 1/2 exact), and every conversion saturates into [-2^63, 2^63 - 1], NaN giving 0.a44_round_minus_halfnative_decide (trusts the compiled evaluator)A44:round -2.5is -2, by the rules from E0. [native]
Generated at compile time
kc_<Shard>_<n>kernel-checked (decide +kernel)1907 theorems made by the command #kernel_checks, one per check of a translated test that the kernel can compare.
StandardElmMech/Generated/ChecksElm.lean
The theorems of the translated tests of shard Elm: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elmkernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElmCore.lean
The theorems of the translated tests of shard ElmCore: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_ElmCorekernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElmCore_CompareI.lean
The theorems of the translated tests of shard ElmCore_CompareI: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_ElmCore_CompareIkernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElmCore_CoreIssue115.lean
The theorems of the translated tests of shard ElmCore_CoreIssue115: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_ElmCore_CoreIssue115kernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElmCore_FloatD.lean
The theorems of the translated tests of shard ElmCore_FloatD: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_ElmCore_FloatDkernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElmCore_FloatSu.lean
The theorems of the translated tests of shard ElmCore_FloatSu: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_ElmCore_FloatSukernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElmCore_NotEqualBoolP.lean
The theorems of the translated tests of shard ElmCore_NotEqualBoolP: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_ElmCore_NotEqualBoolPkernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElmCore_StandardA42.lean
The theorems of the translated tests of shard ElmCore_StandardA42: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_ElmCore_StandardA42kernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElmCore_TaskOnErrorS.lean
The theorems of the translated tests of shard ElmCore_TaskOnErrorS: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_ElmCore_TaskOnErrorSkernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElm_Ap.lean
The theorems of the translated tests of shard Elm_Ap: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elm_Apkernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElm_As.lean
The theorems of the translated tests of shard Elm_As: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elm_Askernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElm_CaseF.lean
The theorems of the translated tests of shard Elm_CaseF: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elm_CaseFkernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElm_CaseS.lean
The theorems of the translated tests of shard Elm_CaseS: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elm_CaseSkernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElm_CharU.lean
The theorems of the translated tests of shard Elm_CharU: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elm_CharUkernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElm_CombinatorL.lean
The theorems of the translated tests of shard Elm_CombinatorL: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elm_CombinatorLkernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElm_CombinatorP.lean
The theorems of the translated tests of shard Elm_CombinatorP: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elm_CombinatorPkernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElm_CombinatorSP.lean
The theorems of the translated tests of shard Elm_CombinatorSP: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elm_CombinatorSPkernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElm_CompilerIssue22.lean
The theorems of the translated tests of shard Elm_CompilerIssue22: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elm_CompilerIssue22kernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElm_CovTailRecPairParameters.lean
The theorems of the translated tests of shard Elm_CovTailRecPairParameters: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elm_CovTailRecPairParameterskernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElm_EmbeddedNo.lean
The theorems of the translated tests of shard Elm_EmbeddedNo: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elm_EmbeddedNokernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElm_Fli.lean
The theorems of the translated tests of shard Elm_Fli: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elm_Flikernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElm_ImportE.lean
The theorems of the translated tests of shard Elm_ImportE: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elm_ImportEkernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElm_InfixPrecO.lean
The theorems of the translated tests of shard Elm_InfixPrecO: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elm_InfixPrecOkernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElm_LetN.lean
The theorems of the translated tests of shard Elm_LetN: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elm_LetNkernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElm_LetNumberLo.lean
The theorems of the translated tests of shard Elm_LetNumberLo: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elm_LetNumberLokernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElm_Li.lean
The theorems of the translated tests of shard Elm_Li: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elm_Likernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElm_M.lean
The theorems of the translated tests of shard Elm_M: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elm_Mkernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElm_PartialAppCh.lean
The theorems of the translated tests of shard Elm_PartialAppCh: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elm_PartialAppChkernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElm_PortEchoN.lean
The theorems of the translated tests of shard Elm_PortEchoN: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elm_PortEchoNkernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElm_RecordAccessorFunctionT.lean
The theorems of the translated tests of shard Elm_RecordAccessorFunctionT: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elm_RecordAccessorFunctionTkernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElm_SingleCtorPairBoolF.lean
The theorems of the translated tests of shard Elm_SingleCtorPairBoolF: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elm_SingleCtorPairBoolFkernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElm_StandardL.lean
The theorems of the translated tests of shard Elm_StandardL: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elm_StandardLkernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksElm_TailRecT.lean
The theorems of the translated tests of shard Elm_TailRecT: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Elm_TailRecTkernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
StandardElmMech/Generated/ChecksWorker01.lean
The theorems of the translated tests of shard Worker01: one generated theorem per check the kernel can compare, and the derivability of every check
ports_canon_Worker01kernel-checked (decide +kernel)Every port of every program of this shard, its helper modules' included, has a canonical payload type (D7).
A Standard Definition of Elm? (Draft version 0.4) © Rupert Smith. The text is licensed under CC BY 4.0: share and adapt it freely, with credit and a link to the licence.