tricu/demos/equality.tri
James Eversole 1f5a910fb2
All checks were successful
Test, Build, and Release / test (push) Successful in 1m22s
Test, Build, and Release / build (push) Successful in 1m23s
Immutable definitions and documentation updates
2025-01-24 16:14:33 -06:00

36 lines
1.2 KiB
Plaintext

-- We represent `false` with a Leaf and `true` with a Stem Leaf
false = t
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
of
(\_ : ot)
(\_ _ : ot)
)
-- Lambda representation of the Boolean `not` function
not_Lambda? = matchBool false 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
-- representation. Between different languages that evaluate to tree calculus
-- terms, the exact implementation of Lambda elimination may differ and lead
-- to different tree representations even if they share extensional behavior.
-- Let's see if these are the same:
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_Lambda? = not_Lambda? false
false_Lambda? = not_Lambda? true
bothTrueEqual? = equal? true_TC? true_Lambda?
bothFalseEqual? = equal? false_TC? false_Lambda?