NotEqualBoolMaybeTest
Tags:elm-spec
Checks, in A Standard Definition of Elm?:basis Basics.neqbasis Maybe.Maybe
Translated into Lean for the mechanisation of the book: see its Lean translation.
`/=` on `Maybe Bool` values gives the right answer for `Just True`, `Just False` and `Nothing`, compared in seven pairings: each value with itself, the two `Just`s both ways round, and `Nothing` with `Just True` on either side.
Results
elm-0.19.1
passran in 104 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. jt_jt: False jt_jf: True jf_jt: True jf_jf: False n_jt: True n_n: False jt_n: True
elm-0.19.2
passran in 67 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. jt_jt: False jt_jf: True jf_jt: True jf_jf: False n_jt: True n_n: False jt_n: True
elm-0.19.3
passran in 59 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. jt_jt: False jf_jf: False jf_jt: True jt_jf: True jt_n: True n_n: False n_jt: True
lamdera-1.5.0
passran in 63 msOutput
jt_jt: False jf_jf: False jf_jt: True jt_jf: True jt_n: True n_n: False n_jt: True
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-core/NotEqualBoolMaybeTest] in its title.
Source
The -- CHECK: lines give the expected output.
module NotEqualBoolMaybeTest exposing (main)
{-| `/=` on `Maybe Bool` values gives the right answer for `Just True`,
`Just False` and `Nothing`, compared in seven pairings: each value with
itself, the two `Just`s both ways round, and `Nothing` with `Just True` on
either side.
-}
-- TAGS: elm-spec, b:Basics.neq, b:Maybe.Maybe
-- CHECK: jt_jt: False
-- CHECK: jt_jf: True
-- CHECK: jf_jt: True
-- CHECK: jf_jf: False
-- CHECK: n_jt: True
-- CHECK: n_n: False
-- CHECK: jt_n: True
import Html exposing (text)
main =
let
jt : Maybe Bool
jt = Just True
jf : Maybe Bool
jf = Just False
n : Maybe Bool
n = Nothing
_ = Debug.log "jt_jt" (jt /= jt)
_ = Debug.log "jt_jf" (jt /= jf)
_ = Debug.log "jf_jt" (jf /= jt)
_ = Debug.log "jf_jf" (jf /= jf)
_ = Debug.log "n_jt" (n /= jt)
_ = Debug.log "n_n" (n /= n)
_ = Debug.log "jt_n" (jt /= n)
in
text "done"
Lean translation
This program is translated into Lean by the translator of the Lean mechanisation of A Standard Definition of Elm?: the program it is, its modules in the reduced syntax of Chapter 7 with every integer constant at Int or Float by number specialisation, and its CHECK lines as written (g_elm_core_NotEqualBoolMaybeTest, in StandardElmMech/Generated/ElmCore_FloatSu.lean). Lean's evaluator runs the program by the rules of Chapters 7 and 9, and its checks become one generated theorem: some derivation of the program has a log that meets every check, or, for a test that stops at Debug.todo, the program has no meaning.
| Check | Expected (CHECK) | Lean evaluator | Proved by |
|---|---|---|---|
jt_jt | False | False | t_elm_core_NotEqualBoolMaybeTest |
jt_jf | True | True | t_elm_core_NotEqualBoolMaybeTest |
jf_jt | True | True | t_elm_core_NotEqualBoolMaybeTest |
jf_jf | False | False | t_elm_core_NotEqualBoolMaybeTest |
n_jt | True | True | t_elm_core_NotEqualBoolMaybeTest |
n_n | False | False | t_elm_core_NotEqualBoolMaybeTest |
jt_n | True | True | t_elm_core_NotEqualBoolMaybeTest |
/-- tests/elm-core/src/NotEqualBoolMaybeTest.elm -/
def g_elm_core_NotEqualBoolMaybeTest : Program := {
name := "NotEqualBoolMaybeTest", source := "tests/elm-core/src",
exposing := (.items [.var "main"]), imports := [⟨"Html", "Html", some (.items [.var "text"])⟩],
types := [],
aliases := [],
defs := [
.fn "main" [] (letDefs [.fn "jt" [] (ap (c "Just") [c "True"]), .fn "jf" [] (ap (c "Just") [c "False"]), .fn "n" [] (c "Nothing"), .pat pw (ap (qv "Debug" "log") [str "jt_jt", .atexp (.paren (bin "/=" (v "jt") (v "jt")))]), .pat pw (ap (qv "Debug" "log") [str "jt_jf", .atexp (.paren (bin "/=" (v "jt") (v "jf")))]), .pat pw (ap (qv "Debug" "log") [str "jf_jt", .atexp (.paren (bin "/=" (v "jf") (v "jt")))]), .pat pw (ap (qv "Debug" "log") [str "jf_jf", .atexp (.paren (bin "/=" (v "jf") (v "jf")))]), .pat pw (ap (qv "Debug" "log") [str "n_jt", .atexp (.paren (bin "/=" (v "n") (v "jt")))]), .pat pw (ap (qv "Debug" "log") [str "n_n", .atexp (.paren (bin "/=" (v "n") (v "n")))]), .pat pw (ap (qv "Debug" "log") [str "jt_n", .atexp (.paren (bin "/=" (v "jt") (v "n")))])] (ap (v "text") [str "done"])) ],
checks := [
chk .check "jt_jt: False" .data,
chk .check "jt_jf: True" .data,
chk .check "jf_jt: True" .data,
chk .check "jf_jf: False" .data,
chk .check "n_jt: True" .data,
chk .check "n_n: False" .data,
chk .check "jt_n: True" .data ] }Reading the translation: v "x" is the variable x, c "K" the constructor K, i 42 the integer 42 at Int, .scon (.intF 2) the integer 2 at Float, and str "s" a string; ap f [a, b] applies f to a and then b, and bin "+" a b is a + b. lams, caseOf, ifte, listE, tup2 and recE build lambdas, case, if, lists, pairs and records by the book's derived forms; pv, pw and pcon are variable, wildcard and constructor patterns. defs are the program's top-level definitions and locals the other declarations of main's let, placed in a let around each check; ckk label value kind exp is one check. A name with $ (incF$Float) is a copy number specialisation made.
Static semantics (Chapters 4, 5 and 9): legal_elm_core_NotEqualBoolMaybeTest states that the program as written is legal, with no hypothesis: the proved inference W gives each module a principal derivation, which meets the syntactic restrictions and the further restrictions, with a type of main Chapter 9 allows. End to end: spec_elm_core_NotEqualBoolMaybeTest states that Lean computes the reduced program above from the source (derived forms, inference, the proved checker, number specialisation, type erasure), so the theorems about it do not trust the translator's elaboration ([elab]); mean_elm_core_NotEqualBoolMaybeTest states that the program has a meaning by r:p-program, with both premises, and ident_elm_core_NotEqualBoolMaybeTest that its specialisation is unique and is the reduced program above, both with no hypothesis about principality.