OrderingTupleWithEmptyStringTest
Tags:elm-spec
Checks, in A Standard Definition of Elm?:basis Basics.ltbasis Basics.lebasis Basics.gtbasis Basics.ge
Translated into Lean for the mechanisation of the book: see its Lean translation.
Tests `<`, `<=`, `>` and `>=` on `( Int, String )` tuples whose first components are equal, so the result is decided by comparing `""` with `"a"` in the second component.
Results
elm-0.19.1
passran in 78 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. lt_ee: False lt_eA: True lt_Ae: False le_ee: True le_eA: True le_Ae: False gt_ee: False gt_eA: False gt_Ae: True ge_ee: True ge_eA: False ge_Ae: True
elm-0.19.2
passran in 83 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. lt_ee: False lt_eA: True lt_Ae: False le_ee: True le_eA: True le_Ae: False gt_ee: False gt_eA: False gt_Ae: True ge_ee: True ge_eA: False ge_Ae: True
elm-0.19.3
passran in 73 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. ge_ee: True gt_ee: False le_ee: True lt_ee: False ge_Ae: True ge_eA: False gt_Ae: True gt_eA: False le_Ae: False le_eA: True lt_Ae: False lt_eA: True
lamdera-1.5.0
passran in 55 msOutput
ge_ee: True gt_ee: False le_ee: True lt_ee: False ge_Ae: True ge_eA: False gt_Ae: True gt_eA: False le_Ae: False le_eA: True lt_Ae: False lt_eA: True
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-core/OrderingTupleWithEmptyStringTest] in its title.
Source
The -- CHECK: lines give the expected output.
module OrderingTupleWithEmptyStringTest exposing (main)
{-| Tests `<`, `<=`, `>` and `>=` on `( Int, String )` tuples whose first
components are equal, so the result is decided by comparing `""` with `"a"`
in the second component.
-}
-- TAGS: elm-spec, b:Basics.lt, b:Basics.le, b:Basics.gt, b:Basics.ge
-- CHECK: lt_ee: False
-- CHECK: lt_eA: True
-- CHECK: lt_Ae: False
-- CHECK: le_ee: True
-- CHECK: le_eA: True
-- CHECK: le_Ae: False
-- CHECK: gt_ee: False
-- CHECK: gt_eA: False
-- CHECK: gt_Ae: True
-- CHECK: ge_ee: True
-- CHECK: ge_eA: False
-- CHECK: ge_Ae: True
import Html exposing (text)
main =
let
e : ( Int, String )
e = ( 0, "" )
a : ( Int, String )
a = ( 0, "a" )
_ = Debug.log "lt_ee" (e < e)
_ = Debug.log "lt_eA" (e < a)
_ = Debug.log "lt_Ae" (a < e)
_ = Debug.log "le_ee" (e <= e)
_ = Debug.log "le_eA" (e <= a)
_ = Debug.log "le_Ae" (a <= e)
_ = Debug.log "gt_ee" (e > e)
_ = Debug.log "gt_eA" (e > a)
_ = Debug.log "gt_Ae" (a > e)
_ = Debug.log "ge_ee" (e >= e)
_ = Debug.log "ge_eA" (e >= a)
_ = Debug.log "ge_Ae" (a >= e)
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_OrderingTupleWithEmptyStringTest, in StandardElmMech/Generated/ElmCore_NotEqualBoolP.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 |
|---|---|---|---|
lt_ee | False | False | t_elm_core_OrderingTupleWithEmptyStringTest |
lt_eA | True | True | t_elm_core_OrderingTupleWithEmptyStringTest |
lt_Ae | False | False | t_elm_core_OrderingTupleWithEmptyStringTest |
le_ee | True | True | t_elm_core_OrderingTupleWithEmptyStringTest |
le_eA | True | True | t_elm_core_OrderingTupleWithEmptyStringTest |
le_Ae | False | False | t_elm_core_OrderingTupleWithEmptyStringTest |
gt_ee | False | False | t_elm_core_OrderingTupleWithEmptyStringTest |
gt_eA | False | False | t_elm_core_OrderingTupleWithEmptyStringTest |
gt_Ae | True | True | t_elm_core_OrderingTupleWithEmptyStringTest |
ge_ee | True | True | t_elm_core_OrderingTupleWithEmptyStringTest |
ge_eA | False | False | t_elm_core_OrderingTupleWithEmptyStringTest |
ge_Ae | True | True | t_elm_core_OrderingTupleWithEmptyStringTest |
/-- tests/elm-core/src/OrderingTupleWithEmptyStringTest.elm -/
def g_elm_core_OrderingTupleWithEmptyStringTest : Program := {
name := "OrderingTupleWithEmptyStringTest", source := "tests/elm-core/src",
exposing := (.items [.var "main"]), imports := [⟨"Html", "Html", some (.items [.var "text"])⟩],
types := [],
aliases := [],
defs := [
.fn "main" [] (letDefs [.fn "e" [] (tup2 (i 0) (str "")), .fn "a" [] (tup2 (i 0) (str "a")), .pat pw (ap (qv "Debug" "log") [str "lt_ee", .atexp (.paren (bin "<" (v "e") (v "e")))]), .pat pw (ap (qv "Debug" "log") [str "lt_eA", .atexp (.paren (bin "<" (v "e") (v "a")))]), .pat pw (ap (qv "Debug" "log") [str "lt_Ae", .atexp (.paren (bin "<" (v "a") (v "e")))]), .pat pw (ap (qv "Debug" "log") [str "le_ee", .atexp (.paren (bin "<=" (v "e") (v "e")))]), .pat pw (ap (qv "Debug" "log") [str "le_eA", .atexp (.paren (bin "<=" (v "e") (v "a")))]), .pat pw (ap (qv "Debug" "log") [str "le_Ae", .atexp (.paren (bin "<=" (v "a") (v "e")))]), .pat pw (ap (qv "Debug" "log") [str "gt_ee", .atexp (.paren (bin ">" (v "e") (v "e")))]), .pat pw (ap (qv "Debug" "log") [str "gt_eA", .atexp (.paren (bin ">" (v "e") (v "a")))]), .pat pw (ap (qv "Debug" "log") [str "gt_Ae", .atexp (.paren (bin ">" (v "a") (v "e")))]), .pat pw (ap (qv "Debug" "log") [str "ge_ee", .atexp (.paren (bin ">=" (v "e") (v "e")))]), .pat pw (ap (qv "Debug" "log") [str "ge_eA", .atexp (.paren (bin ">=" (v "e") (v "a")))]), .pat pw (ap (qv "Debug" "log") [str "ge_Ae", .atexp (.paren (bin ">=" (v "a") (v "e")))])] (ap (v "text") [str "done"])) ],
checks := [
chk .check "lt_ee: False" .data,
chk .check "lt_eA: True" .data,
chk .check "lt_Ae: False" .data,
chk .check "le_ee: True" .data,
chk .check "le_eA: True" .data,
chk .check "le_Ae: False" .data,
chk .check "gt_ee: False" .data,
chk .check "gt_eA: False" .data,
chk .check "gt_Ae: True" .data,
chk .check "ge_ee: True" .data,
chk .check "ge_eA: False" .data,
chk .check "ge_Ae: 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_OrderingTupleWithEmptyStringTest 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_OrderingTupleWithEmptyStringTest 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_OrderingTupleWithEmptyStringTest states that the program has a meaning by r:p-program, with both premises, and ident_elm_core_OrderingTupleWithEmptyStringTest that its specialisation is unique and is the reduced program above, both with no hypothesis about principality.