host: relations-as-posts slice 4 — type ALGEBRA (intersection ∧ union)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 25s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 25s
An algebraic type is a post with operand edges: conj edges (intersection members), disj edges (union members). host/blog-instances-of-expr computes its extent from the operands' extents by set intersection/union, RECURSIVELY — operands can themselves be algebraic (meta-circular; tested with (tag ∧ article) ∧ tag). host/blog-is-a-expr? generalises is-a? to type expressions; make-and!/make-or! build them. Binary today (nth 0/1, no fold over operands — robust on the serving JIT). Operand edges are KV-only (host/blog--add-edge-kv!, read via host/blog-out), NOT in lib/relations — feeding extra kinds into the Datalog graph blows up its per-query re-saturation; load-edges! skips conj/disj on replay too. conformance 295/295 (+4: intersection/union membership, extent = set op, nested expr). (NB: host conformance can EXIT 124 purely from a sibling loop's CPU contention — ran with timeout 1200.) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -527,6 +527,29 @@
|
||||
(contains? (host/blog-out "alpha-post" "is-a") "beta-post"))
|
||||
false)
|
||||
|
||||
;; -- Slice 4: type ALGEBRA — intersection (∧) and union (∨) types --
|
||||
;; ocaml is-a tag (seeded above); make it is-a article too, so it's in BOTH extents.
|
||||
(host/blog-relate! "ocaml" "article" "is-a")
|
||||
(host/blog-make-and! "taggy-article" "tag" "article") ;; tag ∧ article
|
||||
(host/blog-make-or! "tag-or-article" "tag" "article") ;; tag ∨ article
|
||||
(host-bl-test "intersection (∧): a member iff it's an instance of BOTH operands"
|
||||
(list (host/blog-is-a-expr? "ocaml" "taggy-article") ;; is-a tag AND is-a article
|
||||
(host/blog-is-a-expr? "ppost" "taggy-article")) ;; neither
|
||||
(list true false))
|
||||
(host-bl-test "union (∨): a member iff it's an instance of EITHER operand"
|
||||
(list (host/blog-is-a-expr? "ocaml" "tag-or-article") ;; is-a tag (and article)
|
||||
(host/blog-is-a-expr? "ppost" "tag-or-article")) ;; neither tag nor article
|
||||
(list true false))
|
||||
(host-bl-test "the extent is the set intersection of the operands' extents"
|
||||
(let ((ext (host/blog-instances-of-expr "taggy-article")))
|
||||
(list (contains? ext "ocaml") ;; in tag ∩ article
|
||||
(contains? ext "ppost"))) ;; in neither
|
||||
(list true false))
|
||||
;; algebra is META-CIRCULAR: an operand can itself be an algebraic type.
|
||||
(host/blog-make-and! "nested-and" "taggy-article" "tag") ;; (tag ∧ article) ∧ tag
|
||||
(host-bl-test "nested type expression: (tag ∧ article) ∧ tag still admits ocaml"
|
||||
(host/blog-is-a-expr? "ocaml" "nested-and") true)
|
||||
|
||||
;; -- Phase 3: tags as posts -- (ocaml is-a tag, from the seed-types test above)
|
||||
(host-bl-test "is-tag?: a post that is-a tag is a tag; others are not"
|
||||
(list (host/blog-is-tag? "ocaml") (host/blog-is-tag? "ppost"))
|
||||
|
||||
Reference in New Issue
Block a user