Eval optimization! Tests for demos

This commit is contained in:
2025-01-25 09:18:13 -06:00
committed by James Eversole
parent 3175132eec
commit 00cdeca280
6 changed files with 70 additions and 45 deletions

View File

@ -1,19 +1,19 @@
-- We represent `false` with a Leaf and `true` with a Stem Leaf
false = t
true = t t
demo_false = t
demo_true = t t
-- Tree Calculus representation of the Boolean `not` function
not_TC? = t (t (t t) (t t t)) (t t (t t t))
-- /demos/toSource.tri contains an explanation of `triage`
triage = (\a b c : t (t a b) c)
matchBool = (\ot of : triage
demo_triage = (\a b c : t (t a b) c)
demo_matchBool = (\ot of : demo_triage
of
(\_ : ot)
(\_ _ : ot)
)
-- Lambda representation of the Boolean `not` function
not_Lambda? = matchBool false true
not_Lambda? = demo_matchBool demo_false demo_true
-- Since tricu eliminates Lambda terms to SKI combinators, the tree form of many
-- functions defined via Lambda terms are larger than the most efficient TC
@ -25,11 +25,11 @@ not_Lambda? = matchBool false true
lambdaEqualsTC = equal? not_TC? not_Lambda?
-- Here are some checks to verify their extensional behavior is the same:
true_TC? = not_TC? false
false_TC? = not_TC? true
true_TC? = not_TC? demo_false
false_TC? = not_TC? demo_true
true_Lambda? = not_Lambda? false
false_Lambda? = not_Lambda? true
true_Lambda? = not_Lambda? demo_false
false_Lambda? = not_Lambda? demo_true
bothTrueEqual? = equal? true_TC? true_Lambda?
bothFalseEqual? = equal? false_TC? false_Lambda?