The Standard Aspect of Dialectical Logic
Dialectical logic is the logic of dialectical processes. The goal of dialectical logic is to introduce dynamic notions into logical computational systems. The fundamental notions of proposition and truth-value in standard logic are subsumed by the no…
Authors: Robert E. Kent
The Standard Asp ect of Dialectical Logic π αλιν τ oν oζ αρµoν ιη - π αλιν τ ρoπ oζ αρµoν ιη Rob ert E. Ken t Ma y 1989 Abstract Diale ctic al lo gic is the lo gic of dialectical processes. The go al of dialectical log ic is to in tro d uce dynamic notions into logical computational systems. The fundamental notions of pr op osition and truth- value in standard logic are su b sumed by the notions of pr o c ess and flow in d ialectical logic. Dialectical logic has a standard asp ect, whic h can b e d efined in terms of the “lo cal cartesian closure” of subtyp es. The standard asp ect of dialectical logic provides a natural program seman tics which incorporates H oare’ s precondition/p ostcondition seman tics and exten d s the standard Kripke semantics of dyn amic logic. The goal of the standard asp ect of d iale ctical logi c is to un ify the logic of small-sca le and large-scale program- ming. In tro d uction Dynamic logic [Kozen] seeks to bring dynamic no tions into logic and progra m sema n tics by basing this se- mantics and logic on the no tio n of “predicate trans former”. The alterna te program semant ics of Hoar e-st yle “precondition/ postconditio n ass ertions” is usually viewed as a sp ecial case of dynamic logic. Dialectical lo gic [Kent88] s e eks to bring dynamic notio ns in to lo g ic by basing logic [La wvere69 ] on the notion of “dia lectical contradiction” or adjoint p air . How do these thre e lo gics co nnect together? This pa per will show that dynamic logic and Hoare-style precondition/ postco nditio n assertional semantics ar e exactly equiv alent, and that dialectical lo gic subsumes b oth in the s ense that “ dy namic log ic is the standard a spect of dialectical logic”. More particularly , I show in this pap er that the axioms of dynamic log ic (or alter nativ ely , precon- dition/p ostcondition a ssertional ax ioms) characterize pr ecisely the dialec tical lo gic notion of diale ctic al flow c ate gory (or alter nativ ely , assertional c ate gory , a notion rela ted but not eq uiv alent to Mane s ’s as sertional category [Manes]). A dialec tica l flo w category is a kind of indexe d adjointness o r diale ctic al b ase which itself is a dialectical enr ic hmen t of the notion of indexe d pr e or der [Hyland]. In fact, a dialectical flow catego ry is an indexed adjoint ness of subtyp es which is loca lly cartesian clo sed. The indexing category her e is the enriched notion o f a join bisemilattic e [Kent88 ]. Dialectical flow categories ob jectivize the int uitive idea of predicate tra nsformation o r the “dialectical flow o f predicates”. 1 1 Base Structures The ess ence of dyna mic systems is conce n tr ated in the notion of “change”. The changing asp ect of dy namic systems is abstracted as “ state”. Change is represented mathematically b y the idea of “a rrow” ⇁ The c hange that an arrow in a dynamic sys tem symbolizes is the c hange of an int ernal state. This acc o rds well with the fact the the notion of a rrow is a p olar notion. An ar r o w ha s b oth a “so urce” and a “ target” y r ⇁ x , and these often sp ecify “ current sta te” and “next state” with an implied dir ection or p olarity . The source/ta rget p olar ity is a binary dualistic typing o f a rrows. This gives dyna mic s y stems a log ical type- theoretic flav o r. W e further this merging of logic and dynamics by iden tifying the logical notion of “term” with the dynamic notion o f ar row. The nondeterministic asp ect of actual dynamic systems pr ompts us to r e gard an ter m y r ⇁ x as a comp osite notion, so that ter ms in dynamic systems with the same so urce/target t yping p osses s a rela tionship of “no ndeterminism” with r y x s represe n ting the fact that “ s is mo re nondeterministic than r ”. W e assume that the no ndeter- ministic or der is a preorder. In this pap er we quotient out a n y nondeterministically equiv a len t terms, r ≡ s when r s and s r , and assume that nondeterminism is a partial o r der. By itself, the bas ic notion of term is only a p oten tially dy na mic notion. The actual dynamics of terms is concentrated in the notion of “ in ter action” ⊗ In dynamic sy stems, terms function a s “autono mous a gen ts” or “pro cesses ”. Such term-pro cesses interact through their source and target types, and hence types repr esen t the notio n o f “lo cal p orts” in dynamic systems. Two terms z s ⇁ y and y r ⇁ x c a n interact when they have a p ort (t yp e) in common o f opp osite po larit y through whic h the interaction is facilitated, is conducted and/ or takes place. This binary int eraction is a tensor pro duct z s ⊗ r ⇁ x , with the p ort which conducts the in teraction be ing “hidden” in the r esulting pro duct term. In dynamic sy stems, interaction is in terpreted to b e s yc hronization/ c omm unication b et ween term-pro cesses. W e assume that pro cess interaction is a sso c iativ e a nd respe c ts the nondeterminism or der. The notion of term-pr ocess is the fundamental notion, with the notion of type-p ort a der iv ed notion and sp ecial case. Type-p orts a re rega rded, and explicitly r endered, a s sp ecial term-pr oces s es x x ⇁ x which ar e “nops” or iden tities in proce ss interactions. The type-p orts identit y pro cesses are aggrega ted toge ther as a collection Id 1.1 T ensors Bip osets. T erms in dynamic systems form a bip oset. A bip oset is another na me for an o rdered catego ry; that is, a category P = h P , , ⊗ , Id i whose homsets are p osets and whose comp osition is monotonic on left and r igh t. W e prefer to v ie w bip osets as vertical struc tur es, preor ders with a tensor pro duct, r ather than as horizontal structur es, o rdered ca tegories. 2 In more detail, a bipo set P co nsists of the following data and a xioms. There is a collection o f P -ob jects x, y , z , · · · called typ es , a nd a collection of P -arrows r , s, t, · · · c a lled terms . Each term r ha s a unique source t yp e y and a unique tar get t yp e x , denoted b y the relational notatio n y r ⇁ x . The collection of terms from source type y to tar get type x is ordered by a binary relation y ,x called t erm entailment , which is transitiv e, if r s and s t then r t , reflex ive r r , and antisymmetric, r ≡ s implies r = s , where r ≡ s when r s and s r . D ialectical lo gic entailmen t y ,x betw een terms gener alizes standa rd logic entailmen t ⊢ betw een propo sitions. F or an y tw o terms z s ⇁ y and y r ⇁ x with matching types (target type of s = so ur ce t yp e of r ) there is a comp osite term z s ⊗ r ⇁ x , where ⊗ is a binary oper ation called tensor pr o duct , which is asso ciative t ⊗ ( s ⊗ r ) = ( t ⊗ s ) ⊗ r , a nd monotonic on left a nd right, s s ′ and r r ′ imply s ⊗ r s ′ ⊗ r ′ . T ensor pro duct r epresents the “ in ter action” o f the tw o term-pro cesses s and r . It allows each term y r ⇁ x to specify a right dir e ct flow P [ z , y ] ⊗ r → P [ z , x ] and a left dir e ct flow P [ x, z ] r ⊗ → P [ y , z ] for each type z . Any t yp e x is a term x x ⇁ x , which is a n identit y s ⊗ x = s and x ⊗ r = r , sp ecifying identit y dire c t/in v erse flow. An y ca tegory C is a bip oset with the trivial identit y homset or der y ,x = = y ,x . The category Re l (also denoted Mfn ) of sets and binary re lations (m ultiv a lued functions) is a bip oset. A bip oset with one ob ject (univ ersal t ype) is ca lle d a monoidal p oset . F or each P -type x , the c ollection P [ x, x ] of endoterms at x is a monoidal p oset. Any commutativ e monoid h M , ◦ , e i is a monoidal p o set with the “part (prefix) order” m n when there is a p ∈ M such that m ◦ p = n . Giv en an alphab et A , the monoid of formal A -languages P ( A ∗ ) is a monoidal po set, whose terms are for mal la nguages, whose tensor pro duct is la ng uage concatenatio n, and whose iden tit y is s ingleton empty string { ε } . If P is a bip oset, then the op-dua l or oppo site bip oset P op is the opp osite categ ory with the same homset or de r as P , and the co-dua l bip oset P co is (the same catego ry) P with the opp osite homs e t o rder. A morphism of bip osets P H → Q is a functor which preserves homset order. Adjoin t P airs . F or a n y opp osed pair of ordinar y relations Y R ⇁ X versus Y S ↽ X the “unit inequa lit y” Y ⊆ R ⊗ S and the “counit inequality” S ⊗ R ⊆ X taken to gether are equiv alent to the fa c ts that R is the graph R = y 1 ( f ) of a function Y f → X and that S is the trans pose S = R op = y 1 ( f ) op = y 0 ( f ). On the other hand, the gr aph Y y 1 ( f ) ⇁ X of any function Y f → X and its transp ose y 0 ( f ) = (y 1 ( f )) op satisfy the unit and co unit inequalities. So these c o nditions des cribe functionalit y in the bip oset Rel , and can b e used a s a wa y of axioma tizing functionality in g eneral bip osets. But they are also the defining conditions for in ternal adjoint pairs. Two o pposed terms y r ⇁ x and y s ↽ x form an adjoint p air of terms or a n adjunction , denoted b y y r ⊣ s ⇁ x , when they satisfy the “unit inequality” y r ⊗ s and the “counit inequality” s ⊗ r x . This ax iomatizes “functionality” of P -terms. T he term r is ca lled the left adjoi nt and the ter m s is called the right adjoi nt in the adjunction r ⊣ s . It is easy to show that right adjoints (and left adjoints) are unique, whe n they exist: if y r ⊣ s 1 ⇁ x and y r ⊣ s 2 ⇁ x then s 1 = s 2 . Denote the unique right adjoint o f y r ⇁ x by y r op ↽ x . A functional P -t erm is a P -term with a right adjoin t. W e usually use the nota tion y f ⊣ f op ⇁ x for functional terms. F or any adjoin t pair y f ⊣ f op ⇁ x : when the unit is equality y = f ⊗ f op they a r e a c or efle ctive p air ; when the counit is equality f op ⊗ f = x they ar e a r efle ctive p air ; and when bo th unit a nd c o unit are equalities they are an inverse p air . F or a n y functional term y f ⊣ f op ⇁ x : the adjunction f ⊣ f op is a co reflection iff f is an monomorphism (iff f op is a n epimorphism); the a djunction is a reflection iff f is an epimorphism (iff f op is an monomor phism); and the adjunction is a inv ersion iff f is an iso morphism (iff f op is an is o morphism), iff f op = f − 1 is the t wo-sided inverse of f . An coreflective pa ir y i ⊣ p ⇁ x is also ca lled a subtyp e of x . Adjoin t pairs co mp ose in the obvious wa y: ( g ⊣ g op ) ⊗ ( f ⊣ f op ) = ( g ⊗ f ) ⊣ ( f op ⊗ g op ), and ( x ⊣ x ) is the ident ity adjoint pa ir a t x . So each bip oset P has a n asso ciated adjoint pa ir categor y P ⊣ , whos e ob jects ar e P -types and whose arr o ws are 3 P -adjunctions. Eq uiv a len tly , P ⊣ -arrows a re just functional P -terms. There is an inclusion functor P ⊣ Inc → P . The co ns truction ( ) ⊣ can b e describ ed a s either “int ernal dialecticality” or “functionalit y”. Comonoids /Affirmation. F or any type x in a bip oset P a c omonoid u at x , deno ted by u : x , is an endoterm x u ⇁ x which satisfies the “pa rt” axio m (corefle x ivit y) u x,x x , stating that u is a par t of the t yp e (iden tity ter m) x , and the “ ide mp otency” axio m (cotra nsitivit y) u x,x u ⊗ u . Since u ⊗ u x ⊗ u = u , we can replace the ineq ualit y in the idemp otency axiom with the equality u ⊗ u = u . Comonoids are g eneralized subtypes. Comonoids of type x a re o rdered by ent ailment x df = x,x . The b ottom endoterm 0 x df = 0 x,x and the iden tit y endoterm x are the smallest and largest comonoids of t yp e x , resp ectively . F o r a functiona l term y f ⊣ f op ⇁ x the comp osite e ndoterm f op ⊗ f is a como noid o f t yp e x asso ciated with f . This asso ciated comonoid is the top comono id f op ⊗ f = x iff f is an epimo rphism iff f ⊣ f op is a reflective pair. Denote the p oset of comonoids of type x by Ω ( x ). W e can interpret the po set Ω ( x ) as a “s ta te-set” indexed by the t yp e x , with a comonoid u ∈ Ω ( x ) b eing a “state” of a system. The state u ∈ Ω ( x ) has internal s tr ucture a nd is a comp osite ob ject sharing an order ing of nondeterminism x with other states. F or a n y tw o comonoids u, v ∈ Ω ( x ) the tensor pr oduct is a lower bo und u ⊗ v u and u ⊗ v v which is an upper b ound for comonoids b elow u and v : if w u and w v then w u ⊗ v . If u and v commute u ⊗ v = v ⊗ u then the tensor pro duct u ⊗ v is a como no id; in which cas e it is the meet u ⊗ v = u ∧ v in Ω ( x ). In a co mplete Heyting categ ory H (see b elow) an endo term x p ⇁ x contains a large s t comonoid of the same type x , called the interior o f p and denoted by p ◦ . The interior is defined as the join p ◦ df = F { w ∈ Ω ( x ) | w x p } , a nd sa tisfies the condition w x p iff w x p ◦ for all co monoids w ∈ Ω ( x ). In an arbitrary biposet P , we use this condition to define (and to a s sert the existence of ) the interior of endoter ms. The interior p ◦ , when it exists, is the la rgest g e neralized P -subt yp e inside p . Any co mo noid w ∈ Ω ( x ) is its own in terior w ◦ = w . The int erior of the tensor pro duct is the meet in Ω ( x ): ( u ⊗ v ) ◦ = u ∧ v = ( v ⊗ u ) ◦ . The in terior of endoter ms mo dels the “affirmation mo dalit y” of linear logic [Gir ard]. W e are es pecially int erested in bip osets P for which any P -endoterm has such an interior. Such bipo sets can be called in ter ior (or pos sibly affir mation) bip osets. A biposet P is a n interior bip oset when at each t yp e x the inclusion-of-co monoids monotonic function Ω ( x ) Inc x − → P [ x , x ] has a right adjoint P [ x , x ] ( ) ◦ → Ω ( x ) called interior , which with inclusion for ms a cor eflectiv e pair of mo no tonic functions Inc x ⊣ ( ) ◦ . Comp osition ( ) ◦ · Inc x is an ge ne r al interior oper ator on endoterms. Any meets that ex is t in P [ x, x ] are pres erv ed by int erior ( p ∧ q ) ◦ = ( p ◦ ⊗ q ◦ ) ◦ for endoter ms p, q ∈ P [ x, x ], since interior is a right adjoint. [Standardization prop ert y:] In interior bipo sets Ω ( x ) a mee t semilattice, with the interior of tensor pr oduct ( u ⊗ v ) ◦ of t wo comonoids v , u ∈ Ω ( x ) b eing the meet in Ω ( x ) , and the tenso r pro duct identit y (or t yp e) endo term x b eing the largest comonoid of type x . This standa rdization proper t y mea ns tha t the lo cal co n texts of comonoids { Ω ( x ) | x a type } a re standard co n texts, and shows wh y prop ositions (int erpreted as comonoids) and progr ams (interpreted as terms) are subsumed by a single concept. Any complete Heyting categor y is an interior bip oset. Monoids/ Consideration. A monoid is the order -theoretic dual o f a comono id. F or any t yp e x in a bipo set P a monoid m at x , denoted b y m : x , is an endoterm x m ⇁ x whic h satisfies the “reflex ivit y” axiom x x,x m , and the “idemp otency” axio m (transitivit y) m ⊗ m x,x m . W e can repla ce the ineq ualit y in the transitivity axiom with the equa lity m ⊗ m = m . Monoids of type x are or dered by entailmen t x df = x,x . The identit y e ndoterm x is the smallest monoid of t ype x . There is no large s t monoid, in general. F or a functional term y f ⊣ f op ⇁ x the comp osite endoterm f ⊗ f op is a mo noid of type x asso ciated w ith f called the kernel of f . The kernel is the b ottom mo noid f ⊗ f op = x iff f is an monomorphis m iff f ⊣ f op is a 4 coreflective pair. Denote the poset o f mono ids of t ype x by ✵ ( x ). F or a n y t wo monoids m, n ∈ ✵ ( x ) the tensor pro duct is a n upp er bo und m m ⊗ n a nd n m ⊗ n which is a loww er b ound for monoids ab ov e u and v : if m k and n k then m ⊗ n k . If m and n commute m ⊗ n = n ⊗ m then the tens or pro duct m ⊗ n is a comonoid; in which ca se it is the join m ⊗ n = m ∨ n in ✵ ( x ). In a complete Heyting catego ry H (see below) an endoterm x p ⇁ x is co n ta ined in a smallest mo noid of the same t ype x , called the closur e of p and denoted b y p • . The closur e is defined as the meet p • df = V { m ∈ ✵ ( x ) | p x m } , and satisfies the condition p • x m iff p x m for all mo no ids m ∈ ✵ ( x ). In an arbitrar y bip oset P , we use this condition to define (and to a s sert the existence o f ) the closure of endoterms. The clos ure p • , when it exists, is the smallest P -mo noid containing p . Any mo noid m ∈ ✵ ( x ) is its own c losure m • = m . The closure of the tensor product is the join in ✵ ( x ): ( m ⊗ n ) • = m ∨ n = ( n ⊗ m ) • . The closure of endoterms mo dels the “ consideration mo dality” of linear log ic [Girard]. A bip oset P is an closur e (or c onsider ation ) bip oset when a t each type x the inclusio n- of-monoids mono tonic function ✵ ( x ) Inc x − → P [ x, x ] has a left adjoint P [ x, x ] ( ) • → ✵ ( x ) called closur e , which with inclusion forms a reflective pair of mo no tonic functions ( ) • ⊣ Inc x . Comp osition ( ) • · Inc x is an g eneral clos ure op erator o n endoter ms . Any joins that exist in P [ x, x ] are pr eserved by closure ( p ∨ q ) • = ( p • ⊕ q • ) • for endoterms p, q ∈ P [ x, x ], since closure is a left a djoin t. [Standardization prop erty:] In closure bip osets ✵ ( x ) a join semilattice, with the closure o f tensor pro duct ( m ⊗ n ) • of tw o mono ids m, n ∈ ✵ ( x ) b eing the join in ✵ ( x ), and the tensor pr o duct identit y (or type) endoterm x being the sma llest monoid o f type x . Any complete Hey ting catego ry is an closure bipo set, with the closure defined to b e the denumerable join p • df = W n p n = x ∨ p ∨ p ⊗ p · · · . An involutive bip oset P = h P , ( ) ∝ i is a bip oset P with a morphism of bip osets P op ( ) ∝ − → P which is monotonic, self-inv erse ( ) ∝ op · ( ) ∝ = Id P , identit y o n subtypes, and a djunctiv e on functional terms; so that ( s ⊗ r ) ∝ = r ∝ ⊗ s ∝ for co mposa ble terms z s ⇁ y and y r ⇁ x , x ∝ = x for all types x , if r s then r ∝ s ∝ for pa r allel terms y r,s ⇁ x , r ∝ ∝ = r , u ∝ = u for all comono ids u ∈ Ω ( x ), and r ∝ = r op for functional terms y r ⊣ r op ⇁ x . In an in v olutive interior bip oset, in terior must co mmute with in v olution: ( r ∝ ) ◦ = ( r ◦ ) ∝ for a ll terms y r ⇁ x . Dually , in an inv o lutiv e closure bipo set, clo sure must commute with inv o lution: ( r ∝ ) • = ( r • ) ∝ for all terms y r ⇁ x . In an in volutiv e bip oset with the interpretation of ter m entailmen t as nondeter ministic order, functional ter ms are minimally nondeterministic (maximally deterministic) terms: if y f ⊣ f op ⇁ x and y g ⊣ g op ⇁ x a re para llel functiona l terms satisfying f g , then f ⊣ g op and hence f = g . A top olo gic al bip oset P is a clas s ical bipo set with b oth interior and clo sure which satisfy ∼ ( p ◦ ) = ( ∼ p ) • . Dialectical Flow. In ob jectiv e dialectics, since dia lectical contradictions ar e re presen ted by adjunctions, systems of dia lectical contradictions ar e represented b y diagrams in (pseudo functors into) the catego ry Adj whose ob jects ar e s mall catego ries a nd whose morphis ms are adjo int pair s of functor s. W e call such a (pseudo)functor B E − → Adj a diale ctic al b ase or an indexe d adjointness , a nd use the notation E ( y r → x ) = ( E r ⊣ E r ): E ( y ) → E ( x ). A dialectica l base can be split into its dir e ct flow asp e ct B E ( ) − → Cat and its inverse flow asp e ct B op E ( ) − → Cat . In this pa per we ar e c hiefly concerned with dialectical bases of preorder s which transform predicates (subtypes); in other words, dia lectical predicate transformer s. Her e a dialectical base B E − → adj factors thro ugh the categor y adj of preor ders and adjoint pair s o f mo notonic functions, and direct flow B E ( ) − → PO and in verse flow B op E ( ) − → PO map to preorder s (and usually semilattices). Let P be an y bip oset. Any functional term y f ⊣ f op ⇁ x defines a dir e ct image monotonic function P [ y , y ] P f − → P [ x, x ] defined by P f ( q ) df = f op ⊗ q ⊗ f for endoterms y q ⇁ y , a inverse image monotonic function P [ y , y ] P f ← − P [ x, x ] defined by P f ( p ) df = f ⊗ p ⊗ f op for endoterms x p ⇁ x . It is e a sy to chec k that direct and in verse 5 image is a n adjoin t pair of monotonic functions P ( y f ⇁ x ) = P [ y , y ] P f ⊣ P f − → P [ x, x ] for eac h functional P -term y f ⊣ f op ⇁ x . Let adj b e the categ ory o f preo r ders a nd adjoint pa irs of monotonic functions. The constr uction P , mapping types to their p oset o f endoterms P ( x ) = P [ x, x ] a nd mapping functional P -ter ms to their adjoint pair of direct/inverse image adjunction, is a dialectical base (indexed a djoin tness) P ⊣ P − → adj , mapping functional P -terms into the subcateg ory of adj c onsisting of monoidal posets and adjoint pair s of monotonic functions. F or each functional term y f ⊣ f op ⇁ x and each P -comonoid v ∈ Ω ( y ) , the endoter m x f op ⊗ v ⊗ f ⇁ x is a P - comonoid ( f op ⊗ v ⊗ f ) ∈ Ω ( x ). So the direct image monotonic function P f restricts to P -comonoids. Denote this re striction by Ω ( y ) Ω f − → Ω ( x ) and call it the dir e ct image als o. In a n interior biposet P the direct image function has a right adjoint Ω ( y ) Ω f ← − Ω ( x ) called the inverse image monotonic function, and defined to b e the int erior Ω f ( u ) df = ( f ⊗ u ⊗ f op ) ◦ for each P -comono id u ∈ Ω ( x ). W e regard the direct and inv er se image op erators as “the vertical dialectical flow of predicates”. If we denote this adjointness by Ω ( f ) df = (Ω f ⊣ Ω f ), then the (vertical flow) como noid co ns truction Ω is a n indexed adjointness (dialectical base) P ⊣ Ω − → adj , mapping functional P -ter ms into the sub categor y of adj co ns isting of meet semilattices and adjoint pairs of monotonic functions. When P is an affirmation bisemilattice, the fact that the (vertical flow) comono id constr uction Ω is an indexed adjointness (dialectical base) P ⊣ Ω − → adj ca n equiv a len tly b e expr essed by the fact that there is an indexed ca tegory Ω P T ⊣ − → P ⊣ : ob jects of Ω P are pair s u : x or typed comonoids u ∈ Ω ( x ); arrows v : y f ⇁ u : x of Ω P are functional terms y f ⊣ f op ⇁ x in P satisfying Ω f ( u ) u iff v ⊗ f f ⊗ u iff v Ω f ( u ). F o r a to polog ical bipo set P , the indexed categ ory Ω P is a weak int ernal mo del for Milner’s calculus of conc ur ren t pro cesses without sync hronization (interaction). Milner’s calculus can be in terpreted in top ological bip osets as follows. “Milner’s Ca lculus” top ological bip o sets sets of actions A t yp es x (synchronization la b els) t yp ed pro cesses P : A t yp ed comonoids u : x (ob jects of Ω P ) action applica tio n a ; P tensor pro duct s ⊗ r nondeterministic choice P + Q bo olea n sum s ⊕ r synchronization pro duct P [] Q (not repr esen ted) restriction P | B inv ers e image Ω i ( u ) df = ( i ⊗ u ⊗ p ) ◦ where P : A and B ⊆ A for subtype y i ⊣ p ⇁ x morphism Q [ φ ] direct ima ge Ω f ( v ) df = ( f op ⊗ v ⊗ f ) where Q : B a nd B φ → A for functional term y f ⊣ f op ⇁ x recursion ~ x = ~ P ( ~ x ) monoidal clo s ure u • with fixp oint so lution fix ~ x ~ P ( ~ x ) (consideration mo dality) Although only a weak in ternal mo del, this gives the c orrect orientation for a mo re adequate mo del discussed later. F or any pair of functional P -terms y 0 f 0 ⊣ f op 0 ⇁ x 0 and y 1 f 1 ⊣ f op 1 ⇁ x 1 there is a (vertical) adjoint pair of monotonic functions P [ y 0 , y 1 ] P [ f 0 ,f 1 ] ⊣ P [ f 0 ,f 1 ] − → P [ x 0 , x 1 ] called the direc t/in v erse image of P -ter ms, with the direct image map defined by P [ f 0 ,f 1 ] ( y 0 y ⇁ y 1 ) df = f op 0 ⊗ y ⊗ f 1 and the inv erse image map defined by P [ f 0 ,f 1 ] ( x 0 x ⇁ x 1 ) df = f 0 ⊗ x ⊗ f op 1 . By defining P [ y 0 , y 1 ] to b e the P -homset and P [ f 0 , f 1 ] to be the adjo intness 6 P [ f 0 , f 1 ] df = ( P [ f 0 ,f 1 ] ⊣ P [ f 0 ,f 1 ] ), w e form a base ( P ⊣ ) 2 P − → adj for the (vertical) dialectical flow of arbitrary P -terms, where ( P ⊣ ) 2 df = P ⊣ × P ⊣ is the 2nd pow er of the ca tegory of functional terms P ⊣ . This extends the vertical dialectical flo w of endoter ms P ( f ) = ( P f ⊣ P f ) and the dialectical base P ⊣ P − → adj defined previously , since the diag ram P ⊣ ∆ P ⊣ − → ( P ⊣ ) 2 P ց P ւ adj commutes, where ∆ P ⊣ is the usual diagonal functor, the pro duct-pairing o f the ident ity functor on P ⊣ with itself; that is, P ( f ) = P [ f , f ]. Equiv alent to the dia lectical base ( P ⊣ ) 2 P − → adj is the indexed categ ory ⇁ P called the vertic al c ate gory of P -terms with sour ce-target indexing functor ⇁ P ∂ P − → ( P ⊣ ) 2 . An ob ject of ⇁ P is a P -term x = ( x 0 x ⇁ x 1 ). A morphism of ⇁ P , denoted by y F ⇒ x a nd called a vertic al arr ow o f P -terms, from a source P - ter m y = ( y 0 y ⇁ y 1 ) to a tar get P -term x = ( x 0 x ⇁ x 1 ), consists of a pair of functional P -terms y 0 f 0 ⊣ f op 0 ⇁ x 0 and y 1 f 1 ⊣ f op 1 ⇁ x 1 which satis fy the direct ima ge ineq ualit y P [ f 0 ,f 1 ] ( y ) x 0 ,x 1 x , or equiv alently the inv e r se image inequality y y 0 ,y 1 P [ f 0 ,f 1 ] ( x ). Note that vertical ar row F consists o f the pair h f 0 , f 1 i plus either of the above inequality constraints. The indexing functor ⇁ P ∂ P − → ( P ⊣ ) 2 is the pro duct-pairing of the s ource functor ⇁ P ∂ P 0 − → P ⊣ , where ∂ P 0 ( x 0 x ⇁ x 1 ) = x 0 and ∂ P 0 ( F ) = f 0 , and the target functor ⇁ P ∂ P 0 − → P ⊣ defined similar ly . Equiv alent to the ab o ve co mmuting squar e of dialectical bases, is the following commuting square of indexed ca tegories ˙ P ∆ P − → ⇁ P T P ↓ ↓ ∂ P P ⊣ ∆ P ⊣ − → ( P ⊣ ) 2 Equiv alent to this co mm uting square are the t wo identities ∆ P · ∂ P 0 = T P = ∆ P · ∂ P 1 . The combination of both the horizontal and vertical asp ects o f ⇁ P forms a double category , with zero-c e lls (ob jects) b eing P - type s x , one-cells (arrows) b eing P -terms x 0 x ⇁ x 1 , and t wo-cells (squar es) b eing vertical arrows of P -terms y F ⇒ x . Although we emphas iz e the ho rizon tal/internal aspect of bip o sets in this pa per, in the section on spannable bipo sets we brie fly discuss the vertical/exter nal asp ect with r espect to in teraction of concurrent pro cesses. Dialectical Syste m s. At the base lev el, a term-pr oces s r can interact (communicate) w ith itself iff it is an endoterm x r ⇁ x . B y identifying self-reference (rec ursion) with growing dynamic systems, the imp ortance of endoterms is emphasized. But there is another wa y in which an arbitrary term- proce s s y r ⇁ x can manifest self-interaction. It ca n pair itself with another term of the same type: tw o term-pro cesses o f the same type y s,r ⇁ x can or ganize themselves into a complemen tary whole. When view ed as a relational gr aph x s ↽ y r ⇁ x (a sp ecial r elational span) the pair has the potential fo r self-interaction. This se lf-in ter action is often ex- pressed a s a comp osite dialectical mo tion [Ke n t8 7] consisting of inverse flow a long one term and direc t flow along the o ther. Such a complemen tary pa ir (tw o working together as o ne) is called a diale ctic al system . In an arbitrary dialectical base B E − → Adj a diale ct ic al system S = ( y ι,o − → x ) is a graph in B , with inv ers e flow sp ecifier ι and direct flow sp ecifier o . The dialec tical interaction (complementary union) of the comp onen t terms o f a diale c tical system o ccurs thro ugh both source and target type - ports. The no tion of 7 r epr o duction in a dialec tica l system is sp ecified by the dia lectical flow (fixp oint ope r ator) ❣ ✂✁ ✄ o ι df = E ι · E o . This repr oduction op erator can b e in terpreted as the “p olar- turning str ucture” of the preSo cratic Gr eek philosopher Hera clitus [Hussey], and in Greek is render ed π αλιν τ ρoπ oζ αρµoν ιη . An ob ject φ ∈ P ( x ) is r epr o duc e d when it sa tisfies the fixp oint equatio n ❣ ✂✁ ✄ o ι ( φ ) = φ . [A philosophical note: The notion of complementary unio n (t wo working together in one) is no t that of “ s yn thesis”. Neither of the o pposites is “transfor med”. Indeed, with synt hesis, dialec tical motio n would cea s e! The notion of “ repro duction” is one of equilibr ium of mo tion, not lack of motion.] Here the yin-yang symbol ❣ ✂✁ ✄ o ι is use d as a reminder o f ancient dialectics; yin inv er se flow along ι and yang direct flow along o . Dialectica l systems are the “moto rs o f nature” specifying the dialectical motion of structured en tities, and a dialec tica l bas e provides the “motive power” for this motion (from the dialectical p oin t-of-view “motion” is synonymous with “tra nsformation”). Spans. F ro m the oppo site sta ndp oint to that a bov e, we might ask whether an a rbitrary endoter m ca n b e manifested as a dialectica l system. In dynamic sy tems this q ues tion can be rephra sed as “Ho w is change manifested as a dia lectical phenomenon?”. W e g iv e an answer to this questio n in the next few sections by axiomatizing contexts where ar bitrary terms can fa c tor in to functional spans. F or any catego ry C a C - sp an y c ρ x fro m y to x is a pair of C -arr o ws ρ = ( y r 0 ← r r 1 → x ) called the le gs o f the span, with common so ur ce C -ob ject r and targ et C -ob jects y and x . T erm entailmen t is defined in terms of morphisms of s pans: for an y para llel pair of spans y d σ , ρ x where σ = ( y s 0 ← s s 1 → x ) and ρ = ( y r 0 ← r r 1 → x ) , the order σ y x ρ holds when there exists a C -ar row s h → r whic h comm utes with the legs of the spans h · r 0 = s 0 and h · r 1 = s 1 . A s pan is p otentially a sp ecifier for a dia lectically co mposite direct flow (and a dialectically comp osite inv erse flow in the exact case). T erm entailmen t is only a preor de r . T o get a p oset we must quotient out in the usual fashion. Alternatively , we can dis cuss things in ter ms of equiv alence, wher e ρ ≡ σ iff bo th ρ σ and σ ρ , instea d of e qualit y . F or a n y tw o C -arr o ws y g → z and x f → w there is a vertical direct image of C -s pans b C [ y , x ] b C [ g,f ] − → b C [ z , w ], which is defined by b C [ g, f ] ( y r 0 ← r r 1 → x ) df = ( z r 0 · g ← r r 1 · f → w ). Initially , since we ar e not ass uming the existence of any co nstraint s o n the underlying category C (exactness), neither a tenso r pro duct in the horizontal asp ect nor an inv er se ima g e op erator in the v ertical a spect necessarily exist. An ex act c ate gory C is a category pos sessing canonica l finite limits. Let C be any exa ct categ ory , with 1 denoting the terminal o b ject (empty pro duct) in C ; so that there is a unique C -arr o w x 1 x → 1 fro m any C -ob ject x to 1. Horizo ntally the co llection of C -spans forms a bipo set (we ambiguously use the same notation b C fo r this). A type (an ob ject of b C ) is just a C -ob j ect, and a ter m y c ρ x (an a r row of b C ) is a C -span. T enso r pr o duct is pullback-compos itio n: for terms z c σ y and y c ρ x where σ = ( z s 0 ← s s 1 → y ) and ρ = ( y r 0 ← r r 1 → x ), the tens o r pr oduct term z d σ ⊗ ρ x is σ ⊗ ρ = ( z ˆ r 0 · s 0 ← − s ⊗ r ˆ s 1 · r 1 − → x ) wher e s ˆ r 0 ← s ⊗ r ˆ s 1 → r is the pullback of the opspan s s 1 → y r 0 ← r . The iden tity spa n at t yp e x is x x ← x x → x . T her e is an obvious inv olution on s pa ns, wher e ρ ∝ = ( x r 1 ← r r 0 → y ) for any span ρ = ( y r 0 ← r r 1 → x ). The constr uction c ( ) c a n be describ ed as either “external dialecticality” or “s pa nning”. F act 1 If C is an ex act c ate gory, then b C is an involutive bip oset. As usual, a span y c ρ x is a functional span when y ρ ⊗ ρ ∝ and ρ ∝ ⊗ ρ x . If ρ is a functional span and σ ≡ ρ , then σ is also a functional s pan. In analogy with the relative Y oneda embeddings of enrich ed functors as bimodules in enriched catego ry theory , arrows of an exa ct categ o ry C can be embedded as adjoin t pairs o f spans; that is, as functional spans. There is a cov ariant embedding C y 1 C − → b C of arrows a s spans: an y C - arrow y f → x is a span y d y 1 C ( f ) x where y 1 C ( f ) = ( y y ← y f → x ). There is a co n trav ar ian t embedding C op y 0 C − → b C 8 of arrows as spans: any C -a rrow y f → x is a spa n x d y 0 C ( f ) y where y 0 C ( f ) = ( x f ← y y → y ). These spans ar e adjoint y d y 1 C ( f ) ⊣ y 0 C ( f ) x and hence mutually in v olutive y 0 C ( f ) = y 1 C ( f ) ∝ . If we denote this adjunction by y C ( f ) df = (y 1 C ( f ) ⊣ y 0 C ( f )), then C y C − → b C ⊣ is a functor called the Y one da emb e dding o f C into b C ⊣ the categor y of functional spans. T erm ent ailment o n functional spans of this form reduces to equality: y C ( f ) y C ( g ) iff f = g . Also, y 1 C ( f ) y 1 C ( g ) op = y 0 C ( g ) iff f ⊗ g = y . So y C is a n em bedding , since it is bijective on ob jects and faithful. T ec hnical Lemma 1 Any functional sp an ρ is e quivalent to a Y one da sp an ρ ≡ y 1 C ( f ) . So for any exact c ate gory C , the Y one da emb e dding y C is actual ly an isomorphism C y C ∼ = b C ⊣ Pro of. Let y c ρ x b e any functional span, where ρ = ( y r 0 ← r r 1 → x ). The tensor pro ducts ρ ∝ ⊗ ρ and ρ ⊗ ρ ∝ are defined by means of the pullback spans r s 0 ← s s 1 → r and r t 0 ← t t 1 → r (these are also called the kernel pairs) of the opspans r r 1 → x r 1 ← r and r r 0 → y r 0 ← r , resp ectively . The counit ine q ualit y ρ ∝ ⊗ ρ x means that there is a C -ar ro w t h → x such that t 0 · r 1 = h = t 1 · r 1 . The unit inequalit y y ρ ⊗ ρ ∝ means that there is a C -arrow y k → s such that k · s 0 · r 0 = y = k · s 1 · r 0 . By de finitio n o f pullback, there is a unique C -arr o w y g → t such that g · t 0 = k · s 0 and g · t 1 = k · s 1 . Since r 0 · k · s 0 · r 0 = r 0 , b y definition of pullback, there is a unique C -a r row r p → t such that p · t 0 = r 0 · k · s 0 and p · t 1 = r . Define the C - arrow y f → x b y f df = g · h . Then r 0 · f = r 0 · g · h = r 0 · g · t 0 · r 1 = r 0 · k · s 0 · r 1 = p · t 0 · r 1 = p · h = p · t 1 · r 1 = r 1 . The equa lit y r 0 · f = r 1 means the span inequality ρ y 1 C ( f ). Also , g · t 0 · r 1 = g · h = f and g · t 0 · r 0 = k · s 0 · r 0 = y imply the span inequality y 1 C ( f ) ρ . So there is precisely one Y oneda span in each equiv alence cla s s of functiona l spans. W e us e this Y oneda span, or its C -arr o w, a s the re presen tative. Mor eo ver, y 1 C = C y C ∼ = b C ⊣ Inc − → b C and y 0 C = C op (y 1 C ) op − → b C op ( ) ∝ − → b C , so that y 1 C is essentially the inclusion b C ⊣ Inc − → b C and y 0 C , y 1 C and y C are interdefinable. W e refer to a n y of these equiv alent co nstructions as the Y one da emb e dding . An y C -arrow y f → x ha ving target x has tra ditionally been called a “sub ob ject” or “gener a lized element” of x in the lo cal cartesian co n text of top os theory [Seele y ]. Let C ↓ x denote s ubob jects of type x . An y exact categ ory C naturally defines a dialectical flow o f its own sub o b jects. Ea c h C -arrow y f → x specifie s by comp osition a direct-image monotonic function C ↓ y C f − → C ↓ x defined by C f ( w h → y ) df = h · f , and sp ecifies by pullback an inv erse-image monotonic function C ↓ y C f ← − C ↓ x defined by C f ( z g → y ) df = ˆ z ˆ g → y where the C -span y ˆ g ← ˆ z ˆ f → z is the pullback of the C -opspa n y f → x g ← z . Defining C ( x ) df = C ↓ x for each type x and C ( f ) df = ( C f ⊣ C f ) the direct/ in verse image adjointness for eac h C - arrow y f → x , mak es the exa ct categor y C a dialectical base C C − → adj . Given any t yp e x , a spa n-endoterm of type x is a C - endospan x c π x , where π = ( x p 0 ← y p 1 → x ) = y p 0 ,p 1 → x . A C -endospan is als o called a C - gr aph with “edges” C -ob ject y , “nodes ” C -ob ject x , “source ” C -arrow p 0 and “targ e t” C -arr o w p 1 . A C -endospan is p otentially a sp ecifier for dialectical flow. An endospan x c φ x of the for m φ = ( x f ← y f → x ) is a “diago nal span” , a C -gr aph with only self-lo op edges y on no des x . Since diagona l spans at x satisfy b oth partiality φ x and idemp otency φ = φ ⊗ φ , they are precisely the x -comonoids in the bip oset b C . Each endospan x c π x , where π = ( x p 0 ← y p 1 → x ) , has a n interior x d π ◦ x diago na l span (span-co monoid), which is the equalize r of the C - gr aph diagram y p 0 ,p 1 − → x , a nd consists o f the self-lo op 9 edges par t of the gr aph. So b C is an int erior bip oset. Recall that the usual direct/ inverse image vertical flow of como noids in the bip oset of C -spans fo r ms a dialectical bas e b C ⊣ Ω − → adj , with Ω ( x ) = Ω b C ( x ) denoting span-comono ids at any C -type x , a nd Ω ( ρ ) = (Ω ρ ⊣ Ω ρ ) deno ting the usual vertical flow of comonoids a t any functional span y c ρ x . C -sub ob jects y f → x at x can be iden tified with C -comono ids ∆ x ( f ) ∈ Ω b C ( x ) wher e ∆ x ( f ) = ( x f ← y f → x ). The op erator ∆ x is a generalized dia gonal op erator . This diagonal oper ator is a bijection C ↓ x ∆ x ∼ = Ω b C ( x ), inducing an order on x -sub ob jects C ↓ x which is the tr aditional or de r , and making ∆ x an order isomor phism. The direc t/in verse image adjoint pair s a nd diag onal inv erse pa ir s form a commuting sq ua re C ( y ) ∆ y ∼ = Ω ( y ) C( f ) ↓ ↓ Ω (y ( f )) C ( x ) ∆ x ∼ = Ω ( x ) for any C -arr ow y f → x , so that the Y oneda/diago nal pair y C / ∆ C is an isomorphism of dia lectical ba ses C y C ∼ = b C ⊣ C ց ∆ C ∼ = Ω ւ adj with the direct/ in v erse imag e flow C C − → adj isomo rphic via diagonal to the usual v ertical flo w of comonoids in the bip oset o f C -spans C y C ∼ = b C ⊣ Ω − → adj . This isomorphism of dialectical bases effectively translates the lo cal cartesia n co ntext of top os theor y into dialectical logic, and shows that dialectical lo gic subsumes top os theory in a very natura l fashio n. T erms in the bip oset of spans b C hav e the following in teresting hor iz o n tal decompo s ition prop ert y: any span y c ρ x whe r e ρ = ( y r 0 ← r r 1 → x ), factor s a s the tw o le g s pa n-ob jects ρ = r op 0 ⊗ r 1 = y 0 C ( r 0 ) ⊗ y 1 C ( r 1 ). W e now axio matize this decompos ition pro perty . Spannable Bip ose ts . Change in dynamic sy stems is repr e sen ted b y terms in bip osets and descr ibed as state-transitio n. Now terms and state-transitio ns a r e dialectical notions: to change state we must “leave” a current state and “arr iv e” at a next state. This so urce/target, leaving/arriving, starting/finishing tr ansition diale ctic , which is co ncretely rea lized in C - spans b C , will b e abstractly axiomatized here by the notion of spannable bip osets. Let P b e any bipo set with categ ory of functional terms P ⊣ . F or any pair of P -types y a nd x , an element y c ρ x in the p oset c P ⊣ [ y , x ] is a span of functional terms ρ = ( y r 0 ⊣ r op 0 ↽ r r 1 ⊣ r op 1 ⇁ x ), which is also called a functional span. Ther e is a canonical underlying P -term mono to nic function c P ⊣ [ y , x ] ♭ yx − → P [ y , x ], which “flattens” a functiona l span to a term ♭ y x ( y r 0 ⊣ r op 0 ↽ r r 1 ⊣ r op 1 ⇁ x ) df = y r op 0 ⊗ r 1 ⇁ x , mapping a span of functional terms to the tensor pr o duct of its leg s. F or the sp ecial case P = b C where C is exact, the underlying term functions ar e isomo rphisms c b C ⊣ [ y , x ] ♭ yx ∼ = b C [ y , x ]. In the p oset c P ⊣ , the (v ertical) direct imag e of functional spans c P ⊣ [ y , x ] c P ⊣ [ g,f ] − → c P ⊣ [ z , w ] is defined by c P ⊣ [ g, f ] ( y r 0 ↽ r r 1 ⇁ x ) df = ( z r 0 ⊗ g ↽ r r 1 ⊗ f ⇁ w ). In arbitr ary P , since ♭ z w ( c P ⊣ [ g, f ] ( ρ )) = g op ⊗ r op 0 ⊗ r 1 ⊗ f = P [ g, f ] ( ♭ y x ( ρ )) for any functional span ρ = ( y r 0 ⊣ r op 0 ↽ r r 1 ⊣ r op 1 ⇁ x ), we hav e the identit y c P ⊣ [ g, f ] · ♭ z w = ♭ y x · P [ g, f ] , which a s serts naturality of the underlying P -term op erator c P ⊣ [ , ] ♭ ⇒ P [ , ] betw een direct flows. W e will axiomatically ex tend this identit y to a co mm uting square of adjoint pairs. W e do this in t wo steps. 10 First of all, we ass ume the existence of r igh t adjoints c P ⊣ [ y , x ] ♯ yx ← − P [ y , x ] to the underlying P -term functions. So each P -ter m y r ⇁ x has an asso ciated overlying sp an of functional terms ♯ y x ( r ) = ( y r 0 ⊣ r op 0 ↽ r r 1 ⊣ r op 1 ⇁ x ), with ♭ y x ( ρ ′ ) r for e a c h functional span ρ ′ = ( y r ′ 0 ↽ r ′ r ′ 1 ⇁ x ) a nd ea ch P -ter m y r ⇁ x iff ( r ′ 0 ) op ⊗ r ′ 1 r iff there exists a functional ter m r ′ h ⊣ h ′ ⇁ r such that h ⊗ r 0 = r ′ 0 and h ⊗ r 1 = r ′ 1 iff ρ ′ ♯ y x ( r ). W e assume that the P -ter m underly ing ♯ y x ( r ) is r itself; that is, e a c h P -term factors through its a s socia ted functional span r = r op 0 ⊗ r 1 . So the a djoin t pair ♮ y x defined b y ♮ y x df = ( ♭ y x ⊣ ♯ y x ) is a reflective pair of monotonic functions with identit y co unit ♯ y x · ♭ y x = Id. W e also assume that the ov erlying span op erator ♯ includes a s sp ecial cas e s the Y oneda functional term embeddings, satisfying the “a x iom of functional extension” ♯ y x ( f ) = y 1 P ⊣ ( f ) ♯ xy ( f op ) = y 0 P ⊣ ( f ) for any functiona l term y f ⊣ f op ⇁ x ; that is, tha t ♯ y x ( y f ⇁ x ) = ( y y ⊣ y ↽ y f ⊣ f op ⇁ x ) and ♯ xy ( x f op ⇁ y ) = ( x f ⊣ f op ↽ y y ⊣ y ⇁ y ). Mor e abstrac tly , Inc y x · ♯ y x = y 1 P ⊣ ,y x and . When P = b C for exact C , the overlying span functions give the span decompo sition that motiv a ted this section ♯ C ,y x ( ρ ) = ( y y 0 C ( r 0 ) ← − r y 1 C ( r 1 ) − → x ), for a n y span y ρ ⇁ x where ρ = ( y r 0 ← r r 1 → x ); so that ♯ C ,y x = c y C y x the y x -th component c b C ⊣ [ y , x ] b y C yx ∼ = b C [ y , x ] of the yoneda isomorphism. If P is an inv o lutiv e bip oset P = h P , ( ) ∝ i , then we a ssume ♯ co mm utes with inv olutio n: ♯ y x ( r ) ∝ ≡ ♯ xy ( r ∝ ). Secondly , we assume the e x istence of a rig h t adjoint c P ⊣ [ g, f ] to the direct image of spans c P ⊣ [ g, f ] called the inverse image of spans, satisfying the “adjointness” axiom c P ⊣ [ g, f ] ( ρ ) σ iff ρ c P ⊣ [ g, f ] ( σ ) iff there exists a functiona l term r h ⊣ h ′ ⇁ s such that h ⊗ s 0 = r 0 ⊗ g and h ⊗ s 1 = r 1 ⊗ f for any tw o functiona l spans y ρ ⇁ x = ( y r 0 ⊣ r op 0 ↽ r r 1 ⊣ r op 1 ⇁ x ) a nd z σ ⇁ w = ( z s 0 ⊣ s op 0 ↽ s s 1 ⊣ s op 1 ⇁ w ). In par ticular, c P ⊣ [ f ,x ] ( x ) = ( y y ⊣ y ↽ y f ⊣ f op ⇁ x ) and c P ⊣ [ x,f ] ( x ) = ( x f ⊣ f op ↽ y y ⊣ y ⇁ y ). B y defining c P ⊣ [ g , f ] to be the adjointn ess c P ⊣ [ g , f ] df = ( c P ⊣ [ g, f ] ⊣ c P ⊣ [ g, f ] ) and c P ⊣ [ y , x ] to be the homset, we get a dialectical base P ⊣ × P ⊣ c P ⊣ − → adj . W e further assume that these direct/inv erse imag e and term/span adjoint pairs form a commuting sq uare c P ⊣ [ y , x ] ♮ yx − → P [ y, x ] c P ⊣ [ g, f ] ↓ ↓ P [ g , f ] c P ⊣ [ z , w ] ♮ z w − → P [ z , w ] for any tw o functional terms y g ⊣ g op ⇁ z and x f ⊣ f op ⇁ w , so that c P ⊣ ♮ ⇒ P is a morphism of bases of (vertical) dialectical flow. The inv er se asp ect as serts the “inv erse flow axiom” ♯ z w · c P ⊣ [ g, f ] ≡ P [ g, f ] · ♯ y x ; that is, c P ⊣ [ g, f ] ( ♯ z w ( s )) ≡ ♯ y x ( P [ g, f ] ( s )) = ♯ y x ( g ⊗ s ⊗ f op ) for any P -term z s ⇁ w . The ax iom of funct ional e x tension is equiv alent to the a xiom that “ ♯ pr eserves iden tities” ♯ xx ( x ) = ( x x ⊣ x ↽ x x ⊣ x ⇁ x ) = x , since if this holds then ♯ y x ( f ) = c P ⊣ [ f ,x ] ( ♯ xx ( x )) = c P ⊣ [ f ,x ] ( x ) = ( y y ⊣ y ↽ y f ⊣ f op ⇁ x ) and ♯ xy ( f op ) = c P ⊣ [ x,f ] ( ♯ xx ( x )) = c P ⊣ [ x,f ] ( x ) = ( x f ⊣ f op ↽ y y ⊣ y ⇁ y ). If σ = ( y s 0 ⊣ s op 0 ↽ s s 1 ⊣ s op 1 ⇁ x ) is a functional span and τ = ( y t 0 ⊣ t op 0 ⇁ t t 1 ⊣ t op 1 ↽ x ) is a functiona l opspan b et ween y a nd x , then σ ♯ y x ( t 0 ⊗ t op 1 ) iff σ c P ⊣ [ t 0 ,t 1 ] ( ♯ tt ( t )) iff σ c P ⊣ [ t 0 ,t 1 ] ( t ) iff c P ⊣ [ t 0 ,t 1 ] ( σ ) t iff ( t s 0 ⊗ t 0 ↽ s s 1 ⊗ t 1 ⇁ t ) ( t t ↽ t t ⇁ t ) iff there exis ts a functional term s h ⊣ h ′ ⇁ t such that h = s 0 ⊗ t 0 and h = s 1 ⊗ t 1 iff s 0 ⊗ t 0 = s 1 ⊗ t 1 . This states that the span overlying a n opspan is the pullba c k of the opspan. A bipo set P which satisfies the ab ove axioms is said to b e sp annable ; that is, a sp annable bip oset P is a bipo set for which: 11 1. there exist ov erlying spa n monotonic functions ♯ y x which ar e right adjoint left in verse to the underlying P -term monotonic functions ♭ y x and which extend the t wo Y o neda embedding s y 0 P ⊣ ,y x and y 1 P ⊣ ,y x ; 2. there exist inv erse ima ge monotonic functions c P ⊣ [ g, f ] for s pans which a re right adjoint to the direc t image monotonic functions c P ⊣ [ g, f ] ; and 3. the term/span r eflectiv e pairs ♮ y x df = ( ♭ y x ⊣ ♯ y x ) form a morphism of dialectical bases c P ⊣ ♮ ⇒ P . Prop osition 1 1. If C is an ex act c ate gory, then b C is a sp annable bip oset. 2. If P is a sp annable bip oset, then P ⊣ (the horizontal c ate gory of functional terms) is an exact c ate gory. So equiv alently , a sp annable bip oset P is a bipos et (1) whos e as s ocia ted category of functional ter ms P ⊣ is exact, a nd (2) whos e underlying P -term o pera tors ♭ y x hav e rig h t adjoints left inv er ses ♯ y x called ov erlying span oper ators, such tha t the reflec tiv e pairs of monotonic functions ♮ y x df = ( ♭ y x ⊣ ♯ y x ) for m a morphis m of bases of (vertical) dia lectical flow c P ⊣ ♮ ⇒ P . Given tw o functiona l spa ns σ = ( z s 0 ⊣ s op 0 ↽ s s 1 ⊣ s op 1 ⇁ y ) and ρ = ( y r 0 ⊣ r op 0 ↽ r r 1 ⊣ r op 1 ⇁ x ), the tensor pr o duct functional s pan is defined by σ ⊗ ρ df = c P ⊣ [ s 0 ,r 1 ] ( ♯ sr ( s 1 ⊗ r op 0 )). This span tenso r pr oduct is the usual definition of tensor pr o duct of s pa ns in exact categ o ries, and P -types and spans o f functional P -ter ms for m a double bip oset c P ⊣ . Prop osition 2 If P is a s p annable bip oset, t hen ⇁ P (the vertic al c ate gory of t erm arr ows) is an exact c ate gory. Pro of. So any bip oset P has an asso ciated category b ⇁ P of spans o f vertical arr o ws of P -terms, which is index ed by P -terms. A 2- sp an y R ✷ x , from sour ce P -term y = ( y 0 y ⇁ y 1 ) to target P -term x = ( x 0 x ⇁ x 1 ), is a pair of vertical arr o ws o f P -terms R = ( y G ⇐ z F ⇒ x ) called the le gs of the 2-spa n with co mmon source P -term z = ( z 0 z ⇁ z 1 ) and target P -terms y and x . T he vertical tensor pro duct S ✷ × R of t wo comp osable spans z S ✷ y and y R ✷ x is defined (as usual) by pullbac k then compo sition in ⇁ P . F or the sp ecial case P = b C where C is exact, a 2-span y R ✷ x , from s o urce C -span y = ( b 0 y 0 ← b y 1 → b 1 ) to target C -spa n x = ( a 0 x 0 ← a x 1 → a 1 ), is a pair of vertical a rrows of C -spans R = ( y G ⇐ z F ⇒ x ), where G is a pair of C -arrows c 0 g 0 → b 0 and c 1 g 1 → b 1 and F is a pair of C -arrows c 0 f 0 → a 0 and c 1 f 1 → a 1 such that ther e is a pair o f C -ar rows c g → b and c f → a which together for m a comm uting comp osite squa re of C - arrows b 0 y 0 ← − b y 1 − → b 1 g 0 ↑ g ↑ ↑ g 1 c 0 z 0 ← − c z 1 − → c 1 f 0 ↓ f ↓ ↓ f 1 a 0 x 0 ← − a x 1 − → a 1 The com bination of b oth the horizo n tal and vertical a s pects of b ⇁ P forms a double bip oset, with zero-cells (ob jects) being P -types x , one-c ells (ar rows) being P -terms x 0 x ⇁ x 1 , and t wo-cells (squares) b eing v ertical spans of P -ter ms y R ✷ x . If z s ⇁ y a nd y r ⇁ x ar e any t w o comp osable P -terms, then from this definition of s pan tensor pro duct we get ♯ z y ( s ) ⊗ ♯ y x ( r ) ♯ z x ( s ⊗ r ), which states that ♯ is lax functorial. The underlying P -term of the tensor pro duct s pa n is ♭ z x ( σ ⊗ ρ ) = ♭ z x ( c P ⊣ [ s 0 ,r 1 ] ( ♯ sr ( s 1 ⊗ r op 0 ))) = P [ s 0 ,r 1 ] ( ♭ sr ( ♯ sr ( s 1 ⊗ r op 0 ))) = P [ s 0 ,r 1 ] ( s 1 ⊗ r op 0 ) = s op 0 ⊗ s 1 ⊗ r op 0 ⊗ r 1 = ♭ z y ( σ ) ⊗ ♭ y x ( ρ ). So, the underlying P -term op erator 12 c P ⊣ ♭ P − → P on a spanna ble bip oset P is (hor izon tally) functorial from functiona l spans to arbitrar y ter ms. It is a morphism of bip osets, s inc e it pr eserves ter m joins. It is a “q uo tien t” morphism of bipo sets, since it is a full functor a nd bijective on ob jects. Theorem 1 The sp anning c onstru ction b ( ) is left adjo int to the functionality c onstruction ( ) ⊣ Exact Cate gories b ( ) ⊣ ( ) ⊣ − → Sp annable Bip osets forming a c or efle ction, with b ( ) emb e dding ex act c ate gories into sp annable bip osets, ( ) ⊣ c or efle cting sp annable bip osets onto exact c ate gories, unit c omp onents given by the Y one da isomorphisms C y C ∼ = b C ⊣ and c ounit c omp onents given by the underlying term bip oset morphisms c P ⊣ ♭ P − → P . 1.2 Sums Join Bisemi lattices. The structural as pect o f the semantics of diale c tical logic is b est defined in ter ms of bisemila ttices. A join bisemilattic e or semiexact bip oset is a bip oset whos e homsets ar e finitely c omplete (join-)semilattices and who se comp osition is finitely (join-) contin uous. Horizontally the term “ semilattice- v alued category” might b e indica ted, but v ertically from a bicategor ical viewp oint the term “bis e milattice” seems appro priate. In more detail, a join bisemilattice P = hh P , , ⊗ , Id i , ⊕ , 0 i consis ts of the data and axioms of a bipos et P = h P , , ⊗ , Id i plus the following. F or any tw o para llel terms y s,r ⇁ x there is a join term y s ⊕ r ⇁ x , where ⊕ is a binary op eration called (standar d) b o ole an sum , satisfying the usual adjointness condition s ⊕ r y ,x t iff s y ,x t and r y ,x t . Standa rd sum represents (a sp ecial case o f ) the “parallel combin ation” o f the tw o pro cesses s and r . Another, per ha ps more interesting, parallel combination is der iv ed from the notion o f type sum (defined below). F or any pa ir of types y a nd x there is an empty (or b ottom ) term y 0 y,x ⇁ x satisfying 0 y ,x r . The tensor pro duct is finitely join-contin uous (distributive w.r .t. finite joins ) on the right and the left, s ⊗ ( r 1 ⊕ · · · ⊕ r n ) = ( s ⊗ r 1 ) ⊕ · · · ⊕ ( s ⊗ r n ) and ( s 1 ⊕ · · · ⊕ s m ) ⊗ r = ( s 1 ⊗ r ) ⊕ · · · ⊕ ( s m ⊗ r ). The join v ⊕ u o f any tw o co monoids v and u of type x is a lso a c o monoid of type x . [Standardization prop ert y:] In a join bisemilattice P , the p oset of comono ids Ω ( x ) is a lattice with meet b eing the tenso r product ⊗ and join being the b oo lean s um ⊕ . F urther mo re, the meet distributes ov er the join, so that Ω ( x ) is a distributive lattice. This standardiza tion pr o perty means tha t the lo cal contexts (monoidal semilattices) of co monoids { Ω ( x ) | x a t yp e } are standard contexts (distr ibutive lattices), and shows why prop ositions (in terpreted as comonoids) a nd pro g rams (interpreted as ter ms) ar e s ubs umed by a sing le co ncept. A jo in bis e milattice with o ne ob ject (universal type) is called a monoidal join semilattic e . A c omplete Heyting c ate gory , abbr eviated cHc , is the s ame as a co mplete join bisemilattice; that is, a join bisemilattice H whose homsets are complete join semilattices (arbitra ry joins exist) and who se tensor pro duct is join contin uous (completely distributiv e w.r.t. joins). Since the homset H [ x, z ] is a complete lattice, and left tensor pro duct r ⊗ is co ntin uous, it ha s (and determines) a rig h t adjoint r ⊗ s y ,z t iff s x,z r – \ t called left tensor implic ation . Similar ly , the rig h t tensor pro duct ⊗ r has (and determines) a right adjoint t ⊗ r z ,x s iff t z ,y s/ – r called right t en sor implic ation . I f P is a join bisemilattice, then the opp osite bip oset P op is also a join bis e milattice. A morphism of join bisemilattic es P H → Q is a functor which pr eserves homset order and finite ho mset joins . An involutive join bisemilattic e P = h P , ( ) ∝ i is an inv olutive bip oset P where inv olution P op ( ) ∝ − → P is a morphis m of join bisemilattices; that is, preserves term joins, so that ( r ⊕ s ) ∝ = r ∝ ⊕ s ∝ for para llel ter ms y r,s ⇁ x , and 0 y ,x ∝ = 0 x,y . 13 An y dis tr ibutiv e lattice is a monoida l join semilattice, where tenso r pro duct coincides with lattice meet s ⊗ r df = s ∧ r . Any commutativ e monoid h M , ◦ , e i is a mono idal join semila ttice with the mo dified “par t (prefix) o rder” m n whe n there is a p ∈ M and a p ositive natural n um ber i ∈ N suc h that m ◦ p = n i . The category JSL of (finitely-complete) join semilattices and join-co n tinuous monotonic functions is a lar ge join bisemilattice, with tens o r pro duct ⊗ being function comp osition “ · ” and b o olean sum ⊕ being the join “ ∨ ” of join-co n tin uous monotonic functions. Rel is a cHc. A o ne-ob ject complete Hey ting categ ory is called a c omplete Heyting monoid . Given a n alphab et A , fo r mal A -langua ges P ( A ∗ ) is a co mplete Heyting mono id. More ge ner ally , every bip oset P has an as s ociated closur e subset c ate gory P ( P ) whic h is a cHc: ob jects a re P -t yp es, ar rows ar e subsets of P -terms y R ⇁ x when R ⊆ P [ y, x ], and homse t order is the clos ed-below order S R when S ⊆ ↓ R . Since every catego ry C is a bipo set with the identit y o rder on ho msets, the subset construction P ( C ) is a sp ecial case of the c lo sure subse t construction. In subset categories P ( C ) a comonoid of t yp e x is e ither the empt y endoterm x ∅ ⇁ x or the iden tity singleton x { x } ⇁ x , and these can b e interpreted as the truth-v alues false and true , so tha t Ω ( x ) is the complete Heyting algebr a Ω ( x ) ∼ = 2 . In a cHc, at e a c h type x the distributiv e lattice of co mo noids Ω ( x ) is actually a complete cartesia n Heyting mo noid; that is, a c o mplete Heyting algebra. Since interiors exist, for any tw o comono ids u , v ∈ Ω ( x ) we can define a lo cal standar d implic ation by u ⇒ v df = ( u – \ v ) ◦ = ( v / – u ) ◦ . Standard implication satisfies the fundamental adjointness: u ⊗ w v iff w u ⇒ v In clo sure subse t categ o ries P ( P ) a comonoid x W ⇁ x of type x is a closed- b elow subset W ⊆ P [ x, x ] of P -e ndo terms x w ⇁ x , which ar e subparts of the identit y w x and which factor (po s sibly trivially) w v ⊗ u int o tw o o ther endoterms v , u ∈ W . Since P ( P ) is a cHc, the lattice of P ( P )-comonoids Ω P (P ) x is a complete Hey ting algebra. Any P -comonoid x w ⇁ x is embeddable as the P ( P )-comonoid x ↓ w ⇁ x . So we can reg ard P ( P )-co mo noids as generalized P -comonoids called closur e subset P -c omonoids . Co monoids in join bisemilattices in gener al, but even mo re strongly in cHc’s, play the role of “loca lized truth v alues”. T yp e Sum s . The closure subset construction P ( P ) do es not capture the no tion of “r elational structures” completely . Although it intro duces nondeterminism on the ar r o ws, it leav es the ob jects alone. Type sums int ro duce distributivity on ob jects in a constructive fashion. Assume that w e a re in a join bisemilattice P . The empty typ e 0 is a special type such that for any type x there are unique terms b et ween x a nd 0 in either dir ection. So 0 is a n initial type, sa tisfying the condition 0 r ⇁ x implies r = 0 0 ,x ; and 0 is a terminal type, satisfying the co ndition x r ⇁ 0 implies r = 0 x, 0 . A t yp e that is b oth initial and terminal is a null t y pe. The null type 0 is the “empty t ype sum”, the s um o f the empty collection of types. F or any pair of types y and x , the b ottom term y 0 y,x ⇁ x is the co mposition 0 y ,x = 0 y , 0 ⊗ 0 0 ,x . The empty type 0 0 0 ,x ⊣ 0 x, 0 ⇁ x is the smallest s ubt yp e o f any type x , a universal b ottom subtype, and its asso ciated comonoid is the smallest comonoid 0 x ∈ Ω ( x ). Suppo se that P is a spanna ble bip o set. When n ull t yp e s exis t the ov er lying span oper ator maps empty P -terms to empt y functional spans: ♯ y x (0 y ,x ) = ( y 0 0 ,y ⊣ 0 y, 0 ↽ 0 0 0 ,x ⊣ 0 x, 0 ⇁ x ). Two subtypes z i ⊣ p ⇁ y a nd z ′ i ′ ⊣ p ′ ⇁ y ar e disjoint when their intersection in P ⊣ (whic h m ust also be a subtype) is the empty type ♯ z z ′ ( i ⊗ p ′ ) = ( z 0 0 ,z ⊣ 0 z , 0 ↽ 0 0 0 ,z ′ ⊣ 0 z ′ , 0 ⇁ z ′ ). This immediately implies the conditions i ⊗ p ′ = 0 z ,z ′ and i ′ ⊗ p = 0 z ′ ,z , whic h ar e equiv alent to the fact that the s ubt yp e c o monoids p ⊗ i and p ′ ⊗ i ′ are disjoint. In fact, these conditions ar e equiv alent to disjoin tness, sinc e the overlying span oper a tor maps empt y P -terms to empt y functional spans . In an arbitrary biposet P , where the intersection of s ubt yp es ma y not necessarily exist, we use these conditions to define disjointness: t wo subtypes z i ⊣ p ⇁ y a nd z ′ i ′ ⊣ p ′ ⇁ y are disjoint when i ⊗ p ′ = 0 z ,z ′ and i ′ ⊗ p = 0 z ′ ,z ; or eq uiv a len tly , when the subt y p e comono ids are disjo int ( p ⊗ i ) ⊗ ( p ′ ⊗ i ′ ) = 0 y . 14 Given tw o t ype s y a nd x in a join bisemila ttice P , the sum of y and x is a comp osite type y ⊕ x having y and x as disjoint s ubt yp es y i y ⊣ p y ⇁ y ⊕ x i x ⊣ p x ↽ x which cov er y ⊕ x . So y ⊕ x co mes equipped with tw o inje ction terms y i y ⇁ y ⊕ x i x ↽ x and tw o pr oje ction terms y p y ↽ y ⊕ x p x ⇁ x which s atisfy the “comonoid covering equation” ( p y ⊗ i y ) ⊕ ( p x ⊗ i x ) = y ⊕ x stating that the join of the sum-component subt ype co monoids cov ers the sum type, a nd s atisfy the “subtype disjointness eq ua tions” i y ⊗ p y = y , i y ⊗ p x = 0 y ,x , i x ⊗ p y = 0 x,y , and i x ⊗ p x = x , or the “c omonoid disjointness equa tion” ( p y ⊗ i y ) ⊗ ( p x ⊗ i x ) = 0 y ⊕ x . These conditions defining sum are equiv alent to the assertio n that the type y ⊕ x is bo th a copr oduct via the injectio ns and a pro duct via the pro jections of the types y and x . An o b ject which is b oth a pr o duct and a copr oduct of tw o other ob jects is called a bipr o duct . So type s ums are equiv alent to bipro ducts. Given any pair o f terms y t ⇁ z s ↽ x there is a unique ter m y ⊕ x [ t,s ] ⇁ z , called the type sum sour c e p airing o f t and s , which satisfies the so urce pairing conditions i y ⊗ [ t, s ] = t and i x ⊗ [ t, s ] = s . J ust define [ t, s ] df = ( p y ⊗ t ) ⊕ ( p x ⊗ s ). In particular, [ i y , i x ] = ( p y ⊗ i y ) ⊕ ( p x ⊗ i x ) = y ⊕ x . Thes e prop erties say tha t the sum y ⊕ x is a copro duct. When P has type sums, copr oduct copa iring op e r ators [ , ] are monotonic in b oth comp onents and preserve joins: if r 1 r 2 and s 1 s 2 then [ r 1 , s 1 ] [ r 2 , s 2 ]; and [ s 1 , r 1 ] ⊕ [ s 2 , r 2 ] = [ s 1 ⊕ s 2 , r 1 ⊕ r 2 ]. F or any term z q ⇁ w it is immedia te that [ t, s ] ⊗ q = [ t ⊗ q , s ⊗ q ] . Dually , given an y pair of terms y t ↽ z s ⇁ x there is a unique term z h t,s i ⇁ y ⊕ x , called the type sum tar get p airing o f t and s , which satisfies the target pairing c o nditions h t, s i ⊗ p y = t and h t, s i ⊗ p x = s . Jus t define h t, s i df = ( t ⊗ i y ) ⊕ ( s ⊗ i x ). In particular, h p y , p x i = ( p y ⊗ i y ) ⊕ ( p x ⊗ i x ) = y ⊕ x . These prop e rties s a y that the s um y ⊕ x is a pro duct. T arget pairing o perato rs h , i are monotonic on left and right. F or a n y term w q ⇁ z it is immedia te that q ⊗ h t, s i = h q ⊗ t, q ⊗ s i . A join bisemilattice P is sa id to be summ able when it has type sums; that is, when all finite type sums exist. The sum of an t wo ar bitrary P -ter ms y 2 s ⇁ y 1 and x 2 r ⇁ x 1 is the term y 2 ⊕ x 2 s ⊕ r ⇁ y 1 ⊕ x 1 defined by s ⊕ r = [ s ⊗ i y 1 , r ⊗ i x 1 ] = h p y 2 ⊗ s, p x 2 ⊗ r i = ( p y 2 ⊗ s ⊗ i y 1 ) ⊕ ( p x 2 ⊗ r ⊗ i x 1 ). The sum term s ⊕ r is a kind o f “super position” of the terms s a nd r . W e can view a summable bisemila ttice P as a genera lized distributed Petri net [MM ]. In the process interpretation of terms the sum term-pro c e ss s ⊕ r repre s en ts the complete pa rallelism of the term-pro cesses s and r . Three sp e cial cases of sum terms are o f in terest. Given any term r : 1. summing with the zero term 0 ⊕ r = p x 2 ⊗ r ⊗ i x 1 embeds a ter m x 2 r ⇁ x 1 in a larger type co n text (lo osely y 2 ⊕ x 2 r ⇁ y 1 ⊕ x 1 ); 2. summing with the iden tity (nop) term z ⊕ r = ( p z ⊗ i z ) ⊕ ( p y ⊗ r ⊗ i x ) a llo ws us to repr esen t the ar tificial int elligence notion of “frame”, where the context z outside of the lo cus of activ ity of a term-pro cess y r ⇁ x is maintained as “sta tus quo” (lo osely z ⊕ y r ⇁ z ⊕ x ); and 3. summing with itself 2 • r df = r ⊕ r = ( p 1 y ⊗ r ⊗ i 1 x ) ⊕ ( p 0 y ⊗ r ⊗ i 0 x ) allows us to define cop ow er s 2 • y 2 • r ⇁ 2 • x of a ter m y r ⇁ x where the cop o wer t yp es y i 1 y ⊣ p 1 y ⇁ 2 • y i 0 y ⊣ p 0 y ↽ y and x i 1 x ⊣ p 1 x ⇁ 2 • x i 0 x ⊣ p 0 x ↽ x are types summed with themselves. The sum oper ator ⊕ is a functor P × P ⊕ − → P . F or any tw o t yp es y and x , the sum y ⊕ x of y a nd x and the sum x ⊕ y o f x and y ar e isomo rphic, satisfying the “comm utative law” y ⊕ x ∼ = x ⊕ y , with the isomor phism mediated b y the m utually inv erse term isomorphisms x ⊕ y [ i x ,i y ] ⇁ y ⊕ x and y ⊕ x h p x ,p y i ⇁ x ⊕ y . F or an y three types z , y and x , the sum op eration satisfies the “asso ciative la w” ( z ⊕ y ) ⊕ x ∼ = z ⊕ ( y ⊕ x ). F or an y t yp e x , the sum op eration satisfies the “unit laws” 0 ⊕ x ∼ = x ∼ = x ⊕ 0. So the sum functor ⊕ is a symmetric monoidal functor, and a summa ble bisemilattice P = h P , ⊕ i is a symmetric monoidal catego ry . 15 Prop osition 3 If P is a joi n bisemil attic e, then P has typ e sums iff P ⊣ has c opr o ducts whic h ar e pr eserve d by the inclusion functor P ⊣ Inc − → P ; so that y ⊕ P x = y + P ⊣ x . Pro of. On the one hand, supp ose that y i y ⊣ p y ⇁ y ⊕ x i x ⊣ p x ↽ x is the c opro duct of types y and x in the category o f functional ter ms P ⊣ . Also, a s sume that y i y ⇁ y ⊕ x i x ↽ x is the copro duct of y and x in P . Then y i y ⊣ p y ⇁ y ⊕ x i x ⊣ p x ↽ x is a type sum in P with product pro jections p y = [ y , 0 xy ] and p x = [0 y x , x ]. On the other hand, supp ose that y i y ⊣ p y ⇁ y ⊕ x i x ⊣ p x ↽ x is a type sum in P . Then it is a copro duct in P ⊣ with copro duct copairings defined by [ g ⊣ g op , f ⊣ f op ] df = [ g , f ] ⊣ h g op , f op i for each pair of functional terms y g ⊣ g op ⇁ z and x f ⊣ f op ⇁ z . Prop osition 4 When the join bisemilattic e P is a sp annable bip oset, c opr o ducts in P ⊣ ar e pul lb acks: given two fun ctional terms y 2 g ⊣ g op ⇁ y 1 and x 2 f ⊣ f op ⇁ x 1 the c opr o duct inje ctions y 2 i y 2 ⊣ p y 2 ⇁ y 2 ⊕ x 2 i x 2 ⊣ p x 2 ↽ x 2 ar e the pul lb acks of the c opr o duct inje ct ions y 1 i y 1 ⊣ p y 1 ⇁ y 1 ⊕ x 1 i x 1 ⊣ p x 1 ↽ x 1 along the c opr o duct functional term y 2 ⊕ x 2 ( g ⊕ f ) ⊣ ( g op ⊕ f op ) ⇁ y 1 ⊕ x 1 . Pro of. First of all, i x 1 ⊗ ( g op ⊕ f op ) = g op ⊗ i x 2 . Secondly , if l ⊗ ( g ⊕ f ) = k ⊗ i x 1 for t wo functional terms z l ⊣ l op ⇁ y 2 ⊕ x 2 and z k ⊣ k op ⇁ x 1 , then ( l ⊗ p x 2 ) ⊣ ( i x 2 ⊗ l op ) is the unique functional ter m z h ⊣ h op ⇁ x 2 satisfying h ⊗ i x 2 = l a nd h ⊗ f = k . When the join bisemilattice P is a spannable bip oset, pullbacks in P ⊣ , as in a n y e x act categ ory C , preserve mo nomorphisms. No w monomorphisms in P ⊣ are identical to subtypes. So in P ⊣ pullbacks o f subtypes a re again subtypes . Also, pullbac ks of empt y subtypes are a gain empty subtypes . Since pullbacks are rig h t adjoint op erators, pullbacks pr eserve in tersections of s ubtypes . F act 2 When t he join bisemilattic e P is a sp annable bip oset, pu l lb acks in P ⊣ of disjo int s ubtyp es ar e again disjoint subtyp es. W e w ant pullbacks in P ⊣ to pres erv e type sums. A sp annable bisemilattic e P is a join bisemilattice which satisfies the following axioms: 1. P is a spannable bip oset; 2. P is a summable bisemilattice; and 3. pullbacks in P ⊣ of type s ums ar e type sums. Axiom 3 means tha t if y 2 i 2 ⊣ p 2 ⇁ y 2 ⊕ y 1 i 1 ⊣ p 1 ↽ y 1 is any t yp e s um, x f ⊣ f op ⇁ y 2 ⊕ y 1 is any functiona l term int o the sum, and ˆ y 2 i ˆ y 2 ⊣ p ˆ y 2 ⇁ x a nd ˆ y 1 i ˆ y 1 ⊣ p ˆ y 1 ⇁ x a re the pullba c ks of the sum subtypes y 2 i 2 ⊣ p 2 ⇁ y 2 ⊕ y 1 and y 2 i 2 ⊣ p 2 ⇁ y 2 ⊕ y 1 along f , then ˆ y 2 i ˆ y 2 ⊣ p ˆ y 2 ⇁ x i ˆ y 1 ⊣ p ˆ y 1 ↽ ˆ y 1 is a type sum. Semiexact Categori es. W e a dd co products to an exact catego r y C in order to get bo olean sums in b C . A semiexact c ate gory C is a categ o ry p ossessing cano nical finite limits and canonical finite co products. Since C ∼ = b C ⊣ , co pr oducts in C are (via Y o neda) copro ducts in b C ⊣ . W e wan t these to b e copr oducts in the larg er category b C . So w e requir e that a n y semiexact ca tegory s atisfy the following a x ioms. 1. Copro ducts are pa rtitions: (a) the initial ob ject is a universal b ottom subob ject; 16 (b) copro duct injections a re monomorphisms ; and (c) copro duct injections are pairwise disjoint. 2. Pullbacks c reate copr oducts: (a) co products are pullbacks; and (b) pullbacks of copro ducts a r e co products . Axiom 1(a) means tha t the unique C -ar row (empty copro duct cotupling) 0 0 x → x is a C -mo nomorphism. Axiom 1(b) is equiv alent to the axio m that the pullback of a n y copro duct injectio n along itself is the identit y . Axiom 1 (c) means that the pullbac k of distinct copro duct injections is the empty copro duct. Axiom 1(c) is equiv alent to the “cancella tion axiom”: y + x ∼ = x implies y ∼ = 0. Axiom 2(b) is redundant, since axio m 2(c) implies 2(b). Axiom 2 mea ns the following three ass ertions. [Nulla r y c a se:] Pullbacks of the zero co pro duct (initial ob j ect) are the zero co pr oduct: if z h → 0 is any C -a rrow into the empty copro duct, then z = 0 and h = 0. This is equiv alent to the axiom tha t pullbacks o f zero morphisms a long C -a rrows are zero morphisms: if z h → x is any C -arrow, then 0 0 z → z is the pullback of the empty copro duct cotupling 0 0 x → x alo ng h . [Binary cas e 2(a):] Co pro ducts a re pullbacks: given tw o C -ar r o ws y 2 g → y 1 and x 2 f → x 1 the copro duct injections y 2 in y 2 → y 2 + x 2 in x 2 ← x 2 are the pullbacks of the copr o duct injections y 1 in y 1 → y 1 + x 1 in x 1 ← x 1 along the copro duct C -a rrow y 2 + x 2 g + f − → y 1 + x 1 . [Bina ry case 2(b):] Pullbacks o f copro ducts are co pro ducts : if z h → y + x is a ny C -arr o w in to a bina ry copro duct, y h y ← ˆ y in ˆ y → z is the pullback of the copr oduct injection y in y → y + x h ← z along h , z in ˆ x ← ˆ x h x → x is the pullback of the copro duct injection z h → y + x in x ← x alo ng h , then z is a copr oduct ˆ y in ˆ y → z in ˆ x ← ˆ x c a lled the pul le db ack c opr o duct of ˆ y and ˆ x and h is the copro duct h y + h x of h y and h x ; in particular, when h = in y the pulledback copro duct is y y → y 0 0 ,y ← 0. F act 3 A xiom 2(b) is e quivalent to the axiom 2(b ′ ) pullbacks of copro duct cotuplings are copro duct cotuplings . Pro of. Axio m 2(b ′ ) means the follo wing. Supp o se y g → z f ← x is any C -opspan and w h → z is an y C - arrow int o the commo n targe t type z . W e can take the pullback o f b oth g and f along h : supp ose tha t spa n y ˜ h g ← ˜ y ˜ g → w is the pullback of the opspan y g → z h ← w , and that span x ˜ h f ← ˜ x ˜ f → w is the pullback of the o ps pan x f → z h ← w . F o rm the co product y + x and co nsider the copr oduct copair ing y + x [ g, f ] → z . T ake the pullback of [ g , f ] along h : supp ose that span y + x ˜ h ← g y + x g [ g, f ] → w is the pullback of the opspan y + x [ g, f ] → z h ← w . Then g y + x is the copr oduct g y + x = ˜ y + ˜ x with copro duct injections in ˜ y = h ˜ g , ˜ h g · in y i and in ˜ x = h ˜ f , ˜ h f · in x i , and g [ g , f ] is the copro duct copair ing g [ g , f ] = [ ˜ g , ˜ f ]. The pro of is straig h tfor w ard. Fir st, form the pullback y + x ˜ h ← g y + x g [ g, f ] → w o f the opspan y + x [ g, f ] → z h ← w . Second, for m the pullback y ˜ h g ← ˜ y f in y → g y + x of the opspa n y in y → y + x ˜ h ← g y + x . Then, by the pasting of pullbacks y ˜ h g ← ˜ y ˜ g → w is the pullback of the ops pan y g → z h ← w , where ˜ g is defined to b e ˜ g df = ˜ in y · g [ g , f ]. Also, by axiom 2(b) g y + x is the copro duct g y + x = ˜ y + ˜ x with copro duct injections in ˜ y = f in y and in ˜ x = f in x , and g [ g , f ] is the co product c opairing g [ g , f ] = [ ˜ g , ˜ f ]. Prop osition 5 If P is a sp annable bisemilattic e, then P ⊣ is a semiexact c ate gory. The limits in C ar e needed for defining the tensor pro duct ⊗ in the hor iz on tal asp ect of b C , a nd the copro ducts a r e neede d for defining the b oo lean sum ⊕ in the v ertical as pect. Since any s emiexact catego ry 17 is an exact categ ory , the horizo n tal asp ect of b C is already defined. The vertical asp ect of b C is defined as follows. F or a n y parallel pa ir of spans y σ,ρ ⇁ x wher e σ = ( y s 0 ← s s 1 → x ) and ρ = ( y r 0 ← r r 1 → x ), the b oole an sum is the span y σ ⊕ ρ ⇁ x where σ ⊕ ρ = ( y [ s 0 ,r 0 ] ← − s + r [ s 1 ,r 1 ] − → x ) with s + r the C - copro duct of s and r and [ s 0 , r 0 ] and [ s 1 , r 1 ] the C -copro duct cotuplings of the legs of the s pans. The botto m span y 0 yx ⇁ x betw een y and x is the initial span 0 y x = ( y 0 y ← 0 0 x → x ) where 0 is the initial C -ob ject and 0 y and 0 x are the unique C -arrows to y and x , r espectively . In a dditio n, there is a top span y 1 yx ⇁ x , whic h is precisely the pr o duct span 1 y x = ( y pr y ← y × x pr x → x ). Prop osition 6 If C is a semiexact c at e gory, then the (horizontal) c ate gory of sp ans b C is a jo in bisemilattic e. Pro of. The tensor pro duct of s pans dis tributes over the b o olean sum of spans by axiom 2 (b ′ ). Lemma 1 If C is a semiexact c ate gory, t hen b C ⊣ has c opr o ducts sinc e C ∼ = b C ⊣ and c opr o ducts in b C ⊣ ar e pr eserve d by t he inclusion functor b C ⊣ Inc − → b C , or e quivalently by the Y one da emb e dding C y 1 C − → b C . So b C has typ e sums with y ⊕ b C x = y + C x . Prop osition 7 If C is a s emiexact c ate gory, then b C is a sp annable bisemilattic e. The catego ry of C -spans b C is imp ortant in general top os theor y , a nd als o in the lo gic of CCS-like languages . The sp ecial case C = Set is our mos t fundamental “s pa nning” example o f dialectical flow. This is the cHc of spans of o rdinary functions Span = d Set . Since Se t is semiexact, Span is a spannable bisemilattice. Theorem 2 The sp anning c onstru ction b ( ) is left adjo int to the functionality c onstruction ( ) ⊣ Semiexact Cate gories b ( ) ⊣ ( ) ⊣ − → Sp annable Bisemilattic es forming a c or efle ction, with b ( ) emb e dding semiexact c ate gories into sp annable bisemilattic es, ( ) ⊣ c or efle cting sp annable bisemilattic es onto semiexact c ate gories. Prop osition 8 If C is a s emiexact c ate gory, then the Y one da emb e dding C y 1 C − → b C pr eserves finite limits. Prop osition 9 If P is a sp annable bisemila ttic e, t hen ⇁ P (the vertic al c ate gory of term arr ows) is a semiexact c ate gory. Pro of. In the vertical categ o ry ⇁ P the v ertical b o olean sum S ✷ + R of t w o parallel spans y S,R ✷ x is defined (as usua l) by copro duct and copro duct-copa iring in ⇁ P . The combination o f bo th the horizo ntal and vertical asp ects of b ⇁ P forms a double bisemilattice, with zero-cells (ob jects) being P -types x , one-cells (arrows) b eing P - ter ms x 0 x ⇁ x 1 , and tw o-cells (squar es) b eing vertical spans of P -ter ms y R ✷ x . F or a top ologica l spannable bisemila ttice P , the indexed catego ry Ω ⇁ P is a full int ernal/e xternal (2- dimensional) mo del for Milner’s calculus of concurrent pro cesses with in ter action (synchronization). Milner’s calculus can be in terpreted in spannable bisemilattices as follows. 18 “Milner’s Ca lculus” spannable bisemila ttices sets of actions A horizontal monoids m : a (synchronization la b els) t yp ed pro cesses P : A t yp ed vertical comonoids U : m (ob jects of Ω ⇁ P ) t yp ed vertical sub ob jects y F ⇒ m (ob jects of ⇁ P ⇓ m ) action applica tio n a ; P horizontal tensor pro duct V ⊗ U nondeterministic choice P + Q vertical b o olean sum V ✷ + U synchronization pr oduct P [] Q vertical tenso r pro duct V ✷ × U restriction P | B inv ers e image Ω I ( U ) df = (y 1 ( I ) ⊗ U ⊗ y 0 ( I )) ◦ where P : A and B ⊆ A for monoid monomorphism n I ⇒ m pullback ⇁ P I ( y F ⇒ m ) df = ˆ y ˆ F ⇒ n morphism Q [ φ ] direct ima ge Ω H ( U ) df = (y 0 ( H ) ⊗ U ⊗ y 1 ( H )) where Q : B and B φ → A for monoid morphism n H ⇒ m comp osition ⇁ P H ( y G ⇒ n ) df = y G · H ⇒ n recursion ~ x = ~ P ( ~ x ) monoidal clo s ure u • with fixp oint solution fix ~ x ~ P ( ~ x ) (consideration mo dality) Comonoid Neg ation. Two comonoids u : x and u ′ : x are said to b e disjoint , denoted by u⌣ x u ′ , when u ⊗ u ′ = u ′ ⊗ u = 0 x (term dis jo in tnes s ). Clearly , a collection o f comonoids is pairwise disjo in t iff the joins of any t wo disjoint sub collections a re disjoint. D efine the ne gation o f a como no id u ∈ Ω ( x ) to be the largest comonoid (if it exists) disjoint from u , v ⌣ x u iff v x ∼ u . In this s e nse, neg a tion is a lo cal b oo lean “complement” o f u . Negation is contrav a rian tly mono to nic v x u implies ∼ u x ∼ v , and hence is a monotonic function Ω ( x ) ∼ ( ) → Ω ( x ) op . In more detail, since dis join tness is a symmetrica l notion, v x ∼ u iff u⌣ x v iff u x ∼ v , nega tion is a self-adjoint monotonic function ∼ ( ) ⊣ ∼ ( ) op . Since negation ∼ ( ) is self- adjoint, it maps arbitrar y joins to meets ∼ ( ⊕ i u i ) = ⊗ i ( ∼ u i ), which in the binary case gives the DeMorgan’s law: ∼ ( v ⊕ u ) = ∼ v ⊗ ∼ u and in the nullary c ase gives the law: ∼ 0 x = x . Double neg ation ∼∼ ( ) is a lo cal clos ure oper ator: “ monotonic” u x v implies ∼∼ u x ∼∼ v , “in- creasing” u x ∼∼ u , and “idemp oten t” ∼∼ ( ∼∼ u ) = ∼ ∼ u . A como no id u ∈ Ω ( x ) is r e gular when it is double-negation c lo sed u = ∼∼ u ; or equiv alently , when u = ∼ v for some co mo noid v ∈ Ω ( x ). Denote the collection of regular comono ids in Ω ( x ) by ℜ ( x ). Then ℜ ( x ) = hℜ ( x ) , ⊗ , x, ∨ , ⊥i is a lattice, which is a meet-subsemilattice of the lattice Ω ( x ) with meets △ i u i in ℜ ( x ) iden tical to meets in Ω ( x ), a nd joins in ℜ ( x ) defined (following Glivenk o) as the double negatio n closure ∨ i u i = ∼∼ ( ⊕ i u i ) of joins in Ω ( x ). Double negation Ω ( x ) ∼∼ ( ) → ℜ ( x ) reflec ts ∼∼ ( ) ⊣ Inc ar bitrary co mo noids into r egular comono ids . The smallest and larg est r e g ular comonoids at x are ⊥ x df = ∼∼ 0 x = ∼ x a nd x = ∼ 0 x = ∼⊥ x , res pectively . F act 4 ℜ ( x ) = hℜ ( x ) , ⊗ , x, ∨ , ⊥ , ∼ ( ) i is a Bo ole an algebr a, for e ach P -typ e x . It is these re gular subtypes which are the appropria te “predicates” used in the classica l dialectical flow of predicate tra nsformers and in pr econdition/p ostcondition sema n tics. A lo c al ly classic al join bisemilattic e P = h P , ∼ ( ) i is a join bisemilattice P augmented with a lo c al ne gation op er ator ∼ ( ) on the la ttice of comonoids Ω ( x ) for each type x , satisfying the axiom v ⌣ x u iff 19 v x ∼ u . Each lo cal negation defines the Bo olean algebra o f reg ular comonoids ℜ ( x ) ⊆ Ω ( x ). This B o olea n algebra is a Heyting alge br a with implicatio n ⇒ x defined b y u ⇒ x v df = ∼ u ∨ v . Then the lo c al implic ation functor ℜ ( x ) co op ⇒ x − → MSL , defined by ⇒ x ( x ) df = ℜ ( x ) = hℜ ( x ) , ⊗ , x i and ⇒ x ( w ) df = Ω ( x ) w ⇒ ( ) − → Ω ( x ) , is a contrav a rian t join semilattice functor. An classic al inverse flow c ate gory h P , ✷ ( ) i co nsists of a lo cally classical join bisemilattice P = h P , ∼ ( ) i , and a contrav a rian t meet semilattice functor P co op ✷ ( ) − → MSL int o the categ ory o f meet semilattices, which is regular o n subtypes. In more detail, 1. ✷ x is a meet subse mila ttice of regula r comono ids ✷ x ⊆ ℜ ( x ) = hℜ ( x ) , ⊗ , x i for each type x ; 2. ✷ y ✷ r ← ✷ x is a morphism o f meet semila ttices for each term y r ⇁ x called the inverse flow sp ecified by r , with ✷ r ( x ) = y a nd ✷ r ( u ⊗ u ′ ) = ✷ r ( u ) ⊗ ✷ r ( u ′ ); 3. ✷ ( ) is co n tr a v aria ntly functorial, with ✷ x = Id ✷ x , and ✷ s ⊗ r = ✷ r · ✷ s ; 4. ✷ ( ) is a meet semilattice functor, (i) if s r then ✷ s ≤ ✷ r , (ii) ✷ 0 = ⊤ , a nd (iii) ✷ r ⊕ s = ✷ r ∧ ✷ s ; 5. ✷ ( ) is standard on subtypes , in that ✷ ( ) restricted to x -comonoids is the lo cal implication functor ⇒ x = Inc co op x · ✷ ( ) that is, subt yp e inv e rse flow ✷ x ✷ u ← ✷ x is just implica tion ✷ u ( u ′ ) = u ⇒ u ′ for e ac h comonoid u ∈ ✷ x . 20 2 Flo w Structures 2.1 Assertional Categories Heyting Categories. The full semantics of intuitionistic dia lectical logic is defined in terms o f Heyting categorie s [Kent88]. Co ncisely s peaking, a Heyting c ate gory is a closed bilattice; that is, a n bilattice H whose tensor pro duct ha s right a djoin ts on b oth left and righ t. The underlying bilattice r epresents the structura l asp ect of a Heyting c a tegory , whereas the closedness prop erty represents the asp ect of ho r izon tal dialectica l flow. In more detail, the flo w asp ect cons ists of the following data and axioms. F or an y tw o H -terms y r ⇁ x and z s ⇁ x with common target t yp e there is a compo site term z s/ – r ⇁ y b etw een their source types , defined by the dialectical axiom t ⊗ r z ,x s iff t z ,y s/ – r , stating that the binary op eration / – of right tensor impli c ation , is righ t adjoin t to tenso r pro duct on the rig h t. Righ t tens or implica tion / – , like all exp onentiation or division op erators including numerical ones, is cov aria n tly monotonic on the left and contrav ar ian tly monoto nic on the r igh t. This dialectical axiom, generaliz ing the deduction theor em of standar d logic, defines the formal semantics of tenso r implication / – in terms of tensor pro duct ⊗ . F ro m the dialectica l axio m easily follows the inference rule o f right mo dus p onens ( s/ – r ) ⊗ r s and the inference rule t ( t ⊗ r ) / – r . Also immediate from the axioms are the tr ansitiv e, reflexive, mixed asso ciative a nd unital laws: ( t/ – s ) ⊗ ( s/ – r ) ( t/ – r ), y ( r/ – r ), t/ – ( s ⊗ r ) = ( t/ – r ) / – s , ( r / – x ) = r . Dually , for any tw o H - terms y r ⇁ x and y t ⇁ z with common source type ther e is a co mposite term x r – \ t ⇁ z be t ween their ta r get t yp es, defined by the dialectica l axiom r ⊗ s y ,z t iff s x,z r – \ t , stating that the bina ry o peratio n – \ of left tensor implic ation , is right adjoint to tensor pro duct on the le ft. T og ether the left and right implica tions satisfy the mixed as socia tiv e law s – \ ( t/ – r ) = ( s – \ t ) / – r . F rom b oth the left and right mo dus p onens, we get the derived rules ( r/ – r ) – \ r = r = r / – ( r – \ r ). Since tensor pro duct is left adjoint on bo th left a nd right to tens o r implication, it pr eserves arbitrar y joins s ⊗ ( r ⊕ r ′ ) = ( s ⊗ r ) ⊕ ( s ⊗ r ′ ), s ⊗ 0 y ,x = 0 z ,x , ( s ⊕ s ′ ) ⊗ r = ( s ⊗ r ) ⊕ ( s ′ ⊗ r ) a nd 0 z ,y ⊗ r = 0 z ,x . Since tenso r implications are right adjoint to tensor pro duct, they preser v e arbitra ry meets r – \ ( t △ t ′ ) = ( r – \ t ) △ ( r – \ t ′ ), r – \ 1 y ,z = 1 x,z , ( s △ s ′ ) / – r = ( s/ – r ) △ ( s ′ / – r ) and 1 z ,x / – r = 1 z ,y . The tw o dialectical a xioms assert that the bilattice H is clo sed. Heyting c a tegories are ubiquitous. Any complete Heyting ca teg ory is a Heyting category ; in particular, subset catego r ies and distributer categ ories (defined below) a re Heyting categories. An y Heyting term y r ⇁ x defines a join-contin uous Heyting dir e ct image monotonic function H [ y , y ] H r − → H [ x, x ] defined by H r ( q ) df = r – \ ( q ⊗ r ) for endoterms y q ⇁ y , a jo in-con tinuous Heyting inverse image monotonic function H [ y , y ] H r ← − H [ x, x ] defined by H r ( p ) df = ( r ⊗ p ) / – r for endoterms x p ⇁ x . It is easy to chec k that direct a nd in v erse image is an adjoint pair of monotonic functions H ( y r ⇁ x ) = H [ y , y ] H r ⊣ H r − → H [ x, x ] for each Heyting term y r ⇁ x . L e t adj b e the category o f pr eorders and a djoin t pa ir s o f mono tonic functions. The construction H , mapping types to their p oset of endoterms H ( x ) = H [ x, x ] and mapping Heyting terms to their adjoint pair of direct/inv er se image adjunction, is a dialectical base H ⊣ H − → adj , mapping Heyting terms into the sub categor y of adj consisting of monoidal p osets and adjoint pairs of mo notonic functions. In a Heyting ca tegory H , the preco ndition/pos tcondition constraint v ⊗ r r ⊗ u is e q uiv a len t to the constraint v ( r ⊗ u ) / – r . This suggests that a g oo d definition for in verse subtype flow in an affirma tion Heyting ca tegory H would be Ω r ( u ) df = (( r ⊗ u ) / – r ) ◦ for each H -comono id u ∈ Ω ( x ). The mo notonic function Ω ( y ) Ω r ← − Ω ( x ) is called the Heyting inverse image monotonic function, and satisfies the Hoar e flow equiv a- lence (see definition below) v ⊗ r r ⊗ u iff v Ω r ( u ). F o r each term y r ⇁ x and each H -comonoid v ∈ Ω ( y ), the endoterm x r – \ ( v ⊗ r ) ⇁ x is not nec essarily an H -comonoid. So define the Heyting dir e ct image mo notonic 21 function b y Ω r ( v ) df = ( r – \ ( v ⊗ r )) ◦ . Heyting direct image Ω ( y ) Ω r − → Ω ( x ) is not nec essarily left adjoint to Heyting inv er se image. F o r any functional ter m y r ⇁ x in a Heyting ca tegory , since left r op -implication is equal to left r -pr oduct r op – \ ( ) = r ⊗ ( ) and right r - implica tion is equal to right r op -pro duct ( ) / – r = ( ) ⊗ r op , we hav e the a djoin t triples r op ⊗ ( ) ⊣ r op – \ ( ) = r ⊗ ( ) ⊣ r – \ ( ) ( ) ⊗ r ⊣ ( ) / – r = ( ) ⊗ r op ⊣ ( ) / – r op , which ar e inv olutively equiv a len t to each other . These a djoin t triples imply that the Heyting direct/inverse image monotonic functions H r ⊣ H r and Ω r , Ω r in a affirmation Heyting categ ory H extend the dir ect/in verse image monoto nic functions P r ⊣ P r and Ω r ⊣ Ω r in an a ffirmation bisemila ttice P . Dialectical Ob ject Flow. Let H b e any Heyting category . Assume the existence of a special type 1, called a sep ar ator of terms: for any tw o par allel terms y s,r ⇁ x , if ψ ◦ s = ψ ◦ r for all ter ms 1 ψ ⇁ y then s = r . A term 1 φ ⇁ x is called an obje ct of type x . An impor tan t example of o b jects o ccurs in r elational database theory , where the Heyting category H is the ca tegory o f mono ids a nd proc e sses [Kent88] of closed subsets of Σ- terms for some signature Σ, a mo no id m : x repres en ts a constrained databa se sc heme consisting of database scheme x and semantic constr ain ts m , and an m -o b ject is a database whic h satisfies that sc heme and those se ma n tic c o nstraint s. Let Θ ( x ) = H [1 , x ] denote the lattice of all o b jects of type x . T erms define a dialectical (bidirectional) flo w of ob jects whic h is expressed in terms of tensor pro duct and implication: for any term y r ⇁ x let Θ r = ( ) ⊗ r denote right tensor product by r defining a dir e ct obje ct flow Θ ( y ) Θ r − → Θ ( x ), and let Θ r = ( ) / – r denote right tensor implicatio n by r defining a n inverse obje ct flow Θ ( y ) Θ r ← − Θ ( x ). W e ident ify this dia le ctical flow of o b jects as the b ehavior of the term r . The separato r rule sta tes that terms are distinguished (and can b e ident ified) by their direct flo w b ehavior. Dir ect ob ject flow Θ ( y ) Θ r − → Θ ( x ) and inv e rse ob ject flow Θ ( y ) Θ r ← − Θ ( x ) form an a djoin t pair o f monoto nic functions Θ r ⊣ Θ r . Denoting this adjunction by Θ ( r ) = (Θ r ⊣ Θ r ), the obje ct c onc ept or flow dial e ctic is repr esen ted b y the dialectica l base H Θ − → adj , mapping t yp es to their ob ject lattice and terms to their dialectical b ehavior. This is the s ense in which Heyting terms sp ecify the dialectical motion of ob jects. In the genera l theory of dialectics, there are tw o natural mea nings fo r “ent ities in dialec tica l motion” : 1. subtyp es u ∈ Ω ( x ) ⊆ P [ x, x ]; and 2. obje cts φ ∈ Θ ( x ) = H [1 , x ]. Affirmation bisemilattices naturally sp ecify the v ertical dialectical flow of subt ype s , where a s Heyting ca teg ories na turally sp ecify the horizo n tal dialectical flow of ob jects. The ma in purp ose o f this pap er is to discuss a third kind o f dia le c tical flow; a (horizontal) dialectical flow o f subtypes which is a sp ecial case of ob ject flow, but extends vertical subt yp e flow from functiona l terms to arbitrary terms in a bisemilattice. Hoare T riples. F o r any source a nd ta r get co monoids v ∈ Ω ( y ) and u ∈ Ω ( x ) the term v r vu ⇁ u defined b y r vu df = v ⊗ r ⊗ u is c a lled the ( v , u )- t h subterm o f r . A P - c opr o c ess v : y r ⇁ u : x is a P -term y r ⇁ x which satisfies the external source constra in t v ⊗ r y ,x r saying that r restricts to the source comonoid v : y , and which satisfies the exter nal target constr ain t r y ,x r ⊗ u saying that r cores tricts to the ta rget comonoid u : x . The source/targ et restriction conditions c an b e r eplaced by the t w o equalities v ⊗ r = r and r = r ⊗ u ; or by the single equality r vu = v ⊗ r ⊗ u = r . Thus, the no tion of copro cess allows co monoids to function as identit y arrows, or ob jects, of s ome ca tegory . T o make this pr ecise we define the bipo set Ω ( P ), whose ob jects ar e P -comonoids and whose arrows are P -copr ocess es. The bip oset Ω ( P ) has certain completeness prop erties, and cor resp o nds to Lawvere’s “Cauchy-completion” [Lawv ere89]. 22 Given an y P -term y r → x , let F 0 ( r ) ⊆ Ω ( y ) denote the co llection F 0 ( r ) df = { v | v ⊗ r y ,x r } o f all comonoids a t the s o urce t ype y satisfying so ur ce restriction. Since F 0 ( r ) is closed ab ov e and closed under finite meets (= tensor pro ducts) it is a filter in the lattice Ω ( y ) called the sour c e fi lt er of r . In par ticular, for any c omonoid u ∈ Ω ( x ) the so urce filter is F 0 ( u ) = ↑ ( u ), the principa l filter generated by u . Similarly , the tar get filter F 1 ( r ) of r is the collec tion F 1 ( r ) df = { u | r y ,x r ⊗ u } ⊆ Ω ( x ) of a ll comonoids at x satis fying target corestriction, and for a n y comonoid u ∈ Ω ( x ) the target filter is the principal filter F 1 ( u ) = ↑ ( u ). Given t wo co mo noids v : y and u : x , a term y r ⇁ x is a copro cess v : y r ⇁ u : x iff v ∈F 0 ( r ) and u ∈F 1 ( r ). F or the fundament al case P = Rel o f sets a nd relations, a c omonoid U : X is a subset U ⊆ X and hence o ccurs a s a type itself, a nd an ordinar y relation satis fie s the source/ target constraints V ⊗ R ⊇ R and R ⊆ R ⊗ U iff R ⊆ V × U . So V : Y R ⇁ U : X iff V R ⇁ U . Then for functionality , V : Y R ⊣ S ⇁ U : X in Ω ( Rel ) iff V R ⊣ S ⇁ U in Rel iff R = graph( f ) fo r some unique function V f → U and S = R op . So Ω ( Rel ) ⊣ = Pfn the category of s ets and p artial functions . In a general join bisemila tice P , a functional term in Ω ( P ) is ca lled a p artial functional term in P , and the categ ory Ω ( P ) ⊣ is ca lled the ca tegory of pa rtial functional P -ter ms. Unfortunately , the categor y Ω ( P ) is no t as useful as one might desire; in particular, there is no canonical functor to the underlying c a tegory P of types and terms s ince identities are not preser v ed. But by s uitably weak ening the constraint v ⊗ r = r = r ⊗ u we g et a very useful a nd interesting categor y . A Ho ar e triple o r Ho ar e assertion v : y r ⇁ u : x , denoted traditio nally a ltho ugh imprecisely by { v } r { u } , co nsists o f a “flow sp ecifying” P -term y r ⇁ x a nd tw o P -comono ids, a “precondition” or sour c e como no id v ∈ Ω ( y ) and a “p ostcondition” or targe t comonoid u ∈ Ω ( x ), which satisfy the “prec o ndition/po s tcondition cons train t” v ⊗ r r ⊗ u . Compo sition o f Hoa re triples { w } s { v } ⊗ { v } r { u } = { w } ( s ⊗ r ) { u } is well-defined and { u } x { u } is the identit y Ho are triple at the como noid u : x . Also , there is a zero triple { v } 0 y ,x { u } fo r any preco ndition v ∈ Ω ( y ) a nd p ostcondition u ∈ Ω ( x ), a nd if { v } r { u } and { v } s { u } ar e tw o triples with the same precondition and p ostcondition then { v } ( r ⊕ s ) { u } is also a triple. So t yp ed comonoids as ob jects and Hoare triples as arrows form a join bisemilattice H ( P ) called the Ho ar e assertional c ate gory ov er P . Ther e is an o bvious underlying t yp e/term functor H ( P ) T P − → P which is a morphism of join bisemilattices. F or each type x in P , the fib er ov er x is the sub category T − 1 P ( x ) ⊆ H ( P ) of all co monoids and triples whic h ma p to x . The ob jects in T − 1 P ( x ) ar e the co monoids of t yp e x and the triples in T − 1 P ( x ) are of the for m { u ′ } x { u } , pairs of comonoids of type x satisfying u ′ u . Hence, the fib er ov er x is just the join semilattice (actually , lattice) of co mo noids T − 1 P ( x ) = Ω ( x ) . When P is an affirma tion bisemilattice, the fact that the (vertical flow) comonoid construction Ω is an indexed adjointness (dialectical base) P ⊣ Ω − → adj ca n equiv a len tly b e expr essed by the fact that there is an indexed adjointness Ω P T ⊣ − → P ⊣ : o b jects of Ω P are pairs u : x or typed comonoids u ∈ Ω ( x ) ; ar rows v : y f ⇁ u : x of Ω P are functional terms y f ⊣ f op ⇁ x in P satisfying Ω f u u iff v ⊗ f f ⊗ u iff v Ω f u . The indexed category Ω P T ⊣ − → P ⊣ is a subca tegory of H ( P ) s a tisfying Inc · T P = T ⊣ · Inc. The importa n t additional ax iom, which states that hH ( P ) , T P , P i is an indexed ca tegory (asserting certain optimality conditions on the fib ers of T P ), and defines the notio n of a “flow catego ry”, is discussed b elo w. Just as we can replace the category o f co monoids and co proc e sses Ω ( P ) b y the Hoa r e asser tional catego ry H ( P ) to g et b etter mathematica l pro p erties, so also we c a n replace the ca tegory of partial functional P -terms Ω ( P ) ⊣ by the catego ry H ( P ) ⊣ of relative par tial functional P -terms. An a rrow in H ( P ) ⊣ , a rela tiv e par tial functional P -term, is a functional term in H ( P ) and satisfies the conditions: functionalit y y f ⊗ f op and f op ⊗ f x , a nd partialness v ⊗ f f ⊗ u and u ⊗ f op f op ⊗ v . (when an inv olution exists, these tw o partialness conditions are equiv ale nt to the single condition v ⊗ f = f ⊗ u ; but in genera l v ⊗ f 6 = f ). It is easy to chec k that, if v : y f ⇁ u : x is a functional term in H ( P ), then v : y v ⊗ f ⊗ u ⇁ u : x is a partial functional ter m 23 in P . The sour c e ide al of r is the collection I 0 ( r ) df = { v ∈ Ω ( y ) | v ⊗ r = 0 } ⊆ Ω ( y ) of all preconditio ns which are “disjoint” fro m r , and the tar get ide al of r is the collection I 1 ( r ) df = { u ∈ Ω ( x ) | 0 = r ⊗ u } ⊆ Ω ( x ) of all p ostconditions which ar e disjoint fr om r . F or any P -ter m y r ⇁ x , define the r - flow r elation {} r {} ⊆ Ω ( y ) × Ω ( x ) by v {} r {} u when { v } r { u } . The flow r elation {} r {} has a dir e ct image monotonic function Ω ( y ) { ( ) } r {} − → F (Ω ( x )) where { v } r {} is the v - th tar get filter of r defined by { v } r {} df = { u ∈ Ω ( x ) | { v } r { u }} for any precondition v ∈ Ω ( y ). Then { v } r {} is a filter in the lattice Ω ( x ) having the same meets as Ω ( x ) , s ince { v } r { u ⊗ u ′ } iff { v } r { u } and { v } r { u ′ } . The flow relation {} r {} has a n inverse image mono tonic function I (Ω ( y ) ) {} r { ( ) } ← − Ω ( x ) where {} r { u } is the u - th sourc e ide al of r defined by {} r { u } df = { v ∈ Ω ( x ) | { v } r { u }} for any p o stcondition u ∈ Ω ( x ). Then {} r { u } is an ideal in the lattice Ω ( y ) having the sa me joins as Ω ( y ), since { v ⊕ v ′ } r { u } iff { v } r { u } and { v } r { u ′ } . A Ho ar e c otriple or dual H o ar e assertion v : y r ⇁ u : x , denoted also by } v { r } u { , co nsists of a flow sp ecifier y r ⇁ x , a pr econdition v ∈ Ω ( y ) and a po stcondition u ∈ Ω ( x ), which s atisfy the “ dual preco ndi- tion/p ostcondition constra int” v ⊗ r r ⊗ u . Typed comonoids as o b jects and Hoare cotriples as arrows form a dual join bisemilattice H co ( P ) called the dual H o ar e assertional c ate gory ov er P . All of the prop e rties of Hoare triples ho ld also for Hoare cotriples with the words “ ideal” and “filter” interc ha nged. In pa rticular, H co ( P ) is a join bisemilattice, a nd there is an o b vious underlying type/term functor H co ( P ) T P − → P which is a morphism o f join bisemilattices . F or e ac h type x in P , the fiber over x is T − 1 P ( x ) = Ω ( x ) op , the oppos ite of the lattice o f comonoids, since triples in T − 1 P ( x ) ar e of the form } u ′ { x } u { , pa irs o f comonoids of type x satisfying u ′ u . An involution P op ( ) ∝ − → P extends to an “inv olution on ass ertions” H co ( P ) op ( ) ∝ − → H ( P ); a pair of inv erse morphisms of jo in bisemilattices defining a n isomor phism H co ( P ) op ≡ H ( P ) and satis fying ( ) ∝ · T P = T P op · ( ) ∝ . F or any P -term y r ⇁ x , define the dual r - flow r elation }{ r }{ ⊆ Ω ( y ) × Ω ( x ) by v }{ r } { u when } v { r } u { . The flow r elation }{ r }{ has a dir e ct image monoto nic function F (Ω ( y )) }{ r } ( ) { ← − Ω ( x ) where }{ r } u { is the u - th sour c e fi lter defined by } { r } u { df = { v ∈ Ω ( x ) | } v { r } u { } for any postco ndition u ∈ Ω ( x ). Then }{ r } u { is a filter in the lattice Ω ( y ) ha ving the sa me meets as Ω ( y ). The flow relation }{ r }{ has an inverse image monotonic function Ω ( y ) } ( ) { r }{ − → I (Ω ( x )) where } v { r }{ is the v - th tar get ide al of r defined by } v { r }{ df = { u ∈ Ω ( x ) | } v { r } u { } for any precondition v ∈ Ω ( y ). Then } v { r }{ is an ideal in the la ttice Ω ( x ) having the same joins as Ω ( x ). F acts 1 The sour c e and tar get filters and the sour c e and tar get ide als ar e the dual x -th sou rc e filter, the y -t h tar get filter, the 0 -t h sour c e ide al, and t he dual 0 - t h tar get ide al, r esp e ctively: F 0 ( r ) = }{ r } x { F 1 ( r ) = { y } r {} I 0 ( r ) = {} r { 0 } I 1 ( r ) = } 0 { r }{ The other four p ossible c ombinations ar e trivial: } { r } 0 { = Ω ( y ) = {} r { x } , and { 0 } r {} = Ω ( x ) = } y { r }{ . As we shal l se e later, we c an axiomatize the notions of domain, r ange, kernel and c okernel via existenc e of the fol lowing me et s of fi lt ers and joins of ide als: domain ∂ 0 ( r ) = V F 0 ( r ) r ange ∂ 1 ( r ) = V F 1 ( r ) kernel ∅ 0 ( r ) = W I 0 ( r ) c okernel ∅ 1 ( r ) = W I 1 ( r ) 2.2 Flo w Categories Direct Flow Categories. F or ea ch type x in P , the lattice o f comonoids Ω ( x ) is a (o ne ob ject) join sub-bisemilattice of P , and the inclusion functor Ω ( x ) Inc x − → P is a mo rphism of join bisemilattices. T ensor 24 pro duct, which is lattice meet in Ω ( x ), fo r ms a lo c al c onjunction funct or Ω ( x ) ⊗ x − → JSL into the category of join semilattices, defined by ⊗ x ( x ) df = Ω ( x ) = h Ω ( x ) , ⊕ , 0 i and ⊗ x ( u ) df = Ω ( x ) ( ) ⊗ u − → Ω ( x ). Conjunction is a morphism of join bis e mila ttices. This example is a sp ecial case of the following c onstruct. An indexe d join semilattic e h P , ✷ ( ) i consists of: 1. a join bisemilattice P , and 2. a mo r phism of join bisemilattices P ✷ ( ) − → JSL to the sp ecial join bisemilattice JSL . In more detail, (a) ✷ x is a join semilattice for each type x ; (b) ✷ y ✷ r → ✷ x is a morphism of join semila ttices for each term y r ⇁ x called the dir e ct flow sp ecified by r , with ✷ r (0 y ) = 0 x and ✷ r ( v ⊕ v ′ ) = ✷ r ( v ) ⊕ ✷ r ( v ′ ); (c) ✷ ( ) is functorial, with ✷ x = Id ✷ x , and ✷ s ⊗ r = ✷ s · ✷ r ; (d) ✷ ( ) is a join semilattice functor, (i) if r s then ✷ r ≤ ✷ s , (ii) ✷ 0 = ⊥ , and (iii) ✷ r ⊕ s = ✷ r ∨ ✷ s . Equiv alently , an indexed join semilattice is a join bisemilattice morphism H T → P fro m so me join bisemilattice H called the underlying typ e/term functor , which as a functor is an indexed ca tegory (an o pfibration). This underlying t ype/ term functor has as left adjoin t 0 P ⊣ T P the b ottom functor (join bisemilattice mo rphism) P 0 P − → H ( P ) mapping types a s 0 P ( x ) df = 0: x a nd terms as 0 P ( y r ⇁ x ) df = 0 : y r ⇁ 0: x . This is a co r eflectiv e pa ir of functors with 0 P embedding P into H ( P ) a nd T P coreflecting H ( P ) o nto P . A morphism of indexe d join semilattic es h P , ✷ P, ( ) i H − → h Q , ✷ Q, ( ) i is a morphism of join bisemilattices P H − → Q which pre s erv es flow H · ✷ Q, ( ) = ✷ P, ( ) . Equiv a len tly , a mo rphism of indexed join semilattices is a morphis m of join bisemila ttices P H − → Q , which commutes with the underlying t ype/ term functors T P · H = T Q . A dir e ct flow c ate gory h P , ✷ ( ) i is a n indexed join semilattice, which is (3) standard on s ubt yp es: (a) ✷ x is a join subsemilattice of co mo noids ✷ x ⊆ Ω ( x ) = h Ω ( x ) , ⊕ , 0 i for each type x ; (b) ✷ ( ) restricted to x -comonoids is the lo cal conjunction functor Inc x · ✷ ( ) = ⊗ x ; that is, subtype direct flow ✷ x ✷ u → ✷ x is just conjunction ✷ u ( u ′ ) = u ′ ⊗ u for each c o monoid u ∈ ✷ x . More precisely , the inclus io n ✷ x ⊆ Ω ( x ) should b e replace by a coreflective pair of monotonic functions which embed ✷ x int o Ω ( x ) and coreflect Ω ( x ) back to ✷ x . F or any functional term y f ⊣ f op ⇁ x direct flow a long f is called existential quantific ation a long f and denoted by ∃ f df = ✷ f , whereas direc t flow along f op is called either subst itution or inverse image along f and denoted by sub f df = ✷ f op . Thus, there is a dialectical bas e P ⊣ ✷ ( ) − → adj defined on functiona l ter ms y f ⊣ f op ⇁ x by ✷ f df = ( ∃ f ⊣ sub f ). Como noids in ✷ x and conjunction form a direct flo w ca tegory h ✷ x , ⊗ x i for each t yp e x . A morphism of dir e ct flow c ate gories h P , ✷ P, ( ) i H − → h Q , ✷ Q, ( ) i is a morphism of indexed join semilattices. In particula r, inclus ion h ✷ x , ⊗ x i Inc x − → h P , ✷ ( ) i is a morphism o f direct flow catego ries. A c ontr avariant dir e ct flow c ate gory h P , ✸ ( ) i co nsists of a join bisemilattice P , and a join semilattice functor P op ✸ ( ) − → JSL , such that h P op , ✸ ( ) i is a cov a rian t direct flow catego ry . An involutive dir e ct fl ow c ate gory P = h P , ✸ ( ) , ✷ ( ) i consists o f an involutiv e join bisemilattice P = h P , ( ) ∝ i , a contrav ar ian t di- rect flow categor y P = h P , ✸ ( ) i , and a cov a riant direct flow c ategory P = h P , ✷ ( ) i , where inv olution h P op , ✸ ( ) i ( ) ∝ − → h P , ✷ ( ) i is a mor phism of direct flow categ ories, so that inv olution s a tisfies the co ndition: ✷ r ∝ = ✸ r for a ll terms y r ⇁ x . In particular , ✷ p = ✸ p for a ll self-inv olutive endoterms x r ⇁ x , whic h includes all sub ob jects and a fortiriori all comono ids. A join bise mila ttice P has dir e ct Ho ar e flow when for any term y r ⇁ x and a n y precondition v ∈ Ω ( y ), there is a p o stcondition ✷ r ( v ) ∈ Ω ( x ) ca lled the str ongest p ostc ondition of r which s atisfies the ax io m ✷ r ( v ) u iff v ⊗ r r ⊗ u iff ( v : y r ⇁ u : x ) ∈ A r( H ( P )) for any postcondition u ∈ Ω ( x ). So, direct Hoare flow can be expressed as the meet ✷ r ( v ) = V { u ∈ Ω ( x ) | v ⊗ r r ⊗ u } . This axiom states that ✷ r ( v ) = V x { v } r { } for any po stcondition v ∈ Ω ( y ), or equiv a len tly tha t the v -th target filter of r is the pr incipal filter { v } r {} = ↑ x ( ✷ r ( v )). So the dir ect image function factor s { ( ) } r {} = ✷ r op · ↑ x as direct flow follo wed by principal filter, a nd that direct flow factors as direct imag e follow ed by meet (when meets exist for all filters of co monoids), since the meet op erator 25 F (Ω ( x )) ∧ x − → Ω ( x ) op forms a reflective pair V x ⊣ ↑ x with the principa l filter op erator Ω ( x ) op ↑ x − → F (Ω ( x )). Then for any tw o comp osable P -terms z s ⇁ y and y r ⇁ x the inequality ✷ s ⊗ r ( w ) ✷ r ( ✷ s ( w ) ) holds for any comonoid w ∈ Ω ( z ) . Since we wan t this to b e equality , we must also as sume that the axio m ✷ r ( ✷ s ( w ) ) ✷ s ⊗ r ( w ) holds for any co monoid w ∈ Ω ( z ). W e a lso a ssume tha t the dir ect Hoare flo w op erator ✷ ( ) is monotonic: if r s then ✷ r ✷ s . Some identities for the direct flow op erator ✷ ( ) are: ✷ u ( u ′ ) = u ′ ⊗ u for all como noids u ∈ Ω ( x ), in pa rticular ✷ x = Id for an y type x ; ✷ s ⊗ r ( w ) = ✷ r ( ✷ s ( w ) ) for tw o co mposable P -terms z s ⇁ y and y r ⇁ x ; ✷ r ( v ) = 0 iff v ⊗ r = 0 iff v ∈I 0 ( r ), or equiv a le n tly I 0 ( ) = ✷ ( ) · ker, stating that the so urce ideal I 0 ( r ) is the kernel o f the direct flo w function ✷ r . So, a mo ngst o ther things, hH ( P ) , T P , P i is an indexed category . A join bisemilattice P ha s r anges when for any P -term y r ⇁ x there is a r ange p ostc ondition ∂ 1 ( r ) ∈ Ω ( x ) which sa tisfies the axioms ∂ 1 ( r ) u iff r r ⊗ u for any p ostcondition u ∈ Ω ( x ) ∂ 1 ( s ⊗ r ) = ∂ 1 ( ∂ 1 ( s ) ⊗ r ) for any comp osable P -ter m z s ⇁ y if r s then ∂ 1 ( r ) ∂ 1 ( s ) for any para llel P -ter m y s ⇁ x The first axiom is e q uiv a len t to ∂ 1 ( r ) = V { u ∈ Ω ( x ) | r r ⊗ u } . It immediately implies that ∂ 1 ( s ⊗ r ) ∂ 1 ( r ) and r r ⊗ ∂ 1 ( r ) ; hence also implies ∂ 1 ( s ⊗ r ) ∂ 1 ( s ⊗ ∂ 1 ( s ) ⊗ r ) ∂ 1 ( ∂ 1 ( s ) ⊗ r ) , which is half of the second a xiom. The first axiom states that ∂ 1 ( r ) = V F 1 ( r ) ∈ F 1 ( r ) is the b ottom of the ta rget filter of r , or equiv alently tha t the target filter of r is the principal filter F 1 ( r ) = ↑ ∂ 1 ( r ) . Some identities for the range op erator ∂ 1 are: “subtypes a re their own ra nge” ∂ 1 ( u ) = u for a n y comonoid u ∈ Ω ( x ); “the range of a subterm is the subterm of the range” ∂ 1 ( r ⊗ u ) = ∂ 1 ( r ) ⊗ u fo r any term y r ⇁ x and any p ostcondition u ∈ Ω ( x ); and “o nly zer o has empt y range” ∂ 1 ( r ) = 0 x iff r = 0 y ,x for any term y r ⇁ x . If P has direct Hoare flow ✷ ( ) , then it has ranges ∂ 1 defined to be the direct flow of the top (identit y ) preco ndition ∂ 1 ( r ) df = ✷ r ( y ) for any term y r ⇁ x . Conv er sely , if P has r anges, then it has direct Hoa re flo w defined to b e the range of the tensor pro duct (guarded ter m) ✷ r ( v ) df = ∂ 1 ( v ⊗ r ); which states that dire ct flow is the tar get readout of the int eraction of a source condition pro cess v with the g eneral pro cess r . A dir e ct Ho ar e flow c ate gory is a join bisemilattice which has direc t Hoare flow, o r eq uiv a len tly , rang es. Prop osition 10 A join bisemilattic e P is a dir e ct Ho ar e flow c ate gory iff the asso ciate d functor H ( P ) T P − → P is an indexe d join semilattic e hH ( P ) , T P , P i . In fact, any dir e ct H o ar e flow c ate gory is a dir e ct flow c ate gory. A join bisemilattice P ha s dual dir e ct Ho ar e flow when for any term y r ⇁ x a nd any po stcondition u ∈ Ω ( x ), there is a precondition ✸ r ( u ) ∈ Ω ( y ) called the we akest dual pr e c ondition of r which sa tisfies the axiom v ✸ r ( u ) iff v ⊗ r r ⊗ u iff ( v : y r ⇁ u : x ) ∈ Ar( H co ( P )), for any pr econdition v ∈ Ω ( y ), or ✸ r ( u ) = V { v ∈ Ω ( y ) | v ⊗ r r ⊗ u } . This axiom states that ✸ r ( u ) = V y }{ r } u { for a n y po stcondition u ∈ Ω ( x ), o r equiv alently that the u -th source filter of r is the principal filter } { r } u { = ↑ y ( ✸ r ( u )). So the dual direct image function factor s }{ r } ( ) { = ✸ r op · ↑ y as direct flow follo wed by principal filter, and that direct flo w fac tors as direc t image follow ed by meet (when meets e x ist for all filters of comono ids). Then for any tw o comp osable P - terms z s ⇁ y and y r ⇁ x the inequality ✸ s ⊗ r ( u ) ✸ s ( ✸ r ( u )) holds for a n y como no id u ∈ Ω ( x ). Since we wan t this to be equality , we m ust a lso ass ume that the axiom ✸ s ( ✸ r ( u )) ✸ s ⊗ r ( u ) 26 holds for a n y comonoid u ∈ Ω ( x ). A join bisemilattice P has domains when for a ny P -term y r ⇁ x ther e is a domain pr e c ondition ∂ 0 ( r ) ∈ Ω ( y ) which sa tisfies the axioms v ∂ 0 ( r ) iff v ⊗ r r iff v ∈F 0 ( r ) ∂ 0 ( s ⊗ r ) = ∂ 0 ( s ⊗ ∂ 0 ( r ) ) for any precondition v ∈ Ω ( y ), a nd any comp osable P -term z s ⇁ y . The firs t ax iom states that ∂ 0 ( r ) = V F 0 ( r ) ∈ F 0 ( r ) is the b ottom of the sour c e filter of r , o r equiv alently that the s ource filter of r is the principal filter F 0 ( r ) = ↑ ∂ 0 ( r ) . Some identities for the domain oper ator ∂ 0 are: “s ubt yp es a re their own domain” ∂ 0 ( u ) = u for any comonoid u ∈ Ω ( x ); “the domain of a s ubter m is the subterm o f the domain” ∂ 0 ( v ⊗ r ) = v ⊗ ∂ 0 ( r ) for any ter m y r ⇁ x and any precondition v ∈ Ω ( y ); and “o nly zero has empty domain” ∂ 0 ( r ) = 0 y iff r = 0 y ,x for a ny term y r ⇁ x . A term y r ⇁ x is total w he n its domain is the en tire source t yp e ∂ 0 ( r ) = y . An y functional term y f ⊣ f op ⇁ x is total, since the counit inequality y f ⊗ f op implies y = ∂ 0 ( y ) ∂ 0 ( f ⊗ f op ) = ∂ 0 ( f ⊗ ∂ 0 ( f op )) ∂ 0 ( f ⊗ x ) = ∂ 0 ( f ⊗ x ) = ∂ 0 ( f ) y by the compo site term axiom ab o ve. Given any tw o total terms z s ⇁ y a nd y r ⇁ x , the comp osite term z s ⊗ r ⇁ x is a lso to tal, since ∂ 0 ( s ⊗ r ) = ∂ 0 ( s ⊗ ∂ 0 ( r ) ) = ∂ 0 ( s ⊗ y ) = ∂ 0 ( s ) = z . T o tal terms are close abov e w.r .t. ter m entailmen t o rder. Since functional terms (in par ticular, identit y terms) ar e total, a nd the compo site of total terms are also total, total terms form a bip oset P † , a subbip oset of P , P ⊣ ⊆ P † ⊆ P , which is the homset or der closure of P ⊣ . The empty term ⊥ y ,x is nev er total for y 6 = 0. So P † is a subbipos et P , which preserves ho mset joins but usually do es not hav e a b ottom. If P has dual dire c t Hoa re flow ✸ ( ) , then it ha s domains ∂ 0 defined to be the dual dir ect flow of the top (identit y) p ostcondition ∂ 0 ( r ) df = ✸ r ( x ) for a n y term y r ⇁ x . Conv er sely , if P has domains, then it has dual direct Hoar e flow defined to b e the domain of the tensor pro duct ✸ r ( u ) df = ∂ 0 ( r ⊗ u ). A c ontr avaria nt dir e ct Ho ar e fl ow c ate gory is a join bisemila ttice which has dual direct Hoar e flo w, or equiv alently , do mains. An involutive dir e ct Ho ar e flow c ate gory P = h P , ( ) ∝ , ✷ i co ns ists o f an involutiv e join bisemilattice P = h P , ( ) ∝ i , a nd a cov aria n t dir e c t Ho a re flow catego ry P = h P , ✷ ( ) i . There is an equiv alent contrav a r ian t direct Hoar e flow category P = h P , ✸ i defined by ✸ df = ( ) ∝ · ✷ , so that inv olution satisfies either of the equiv alent co nditions: ✷ r ∝ = ✸ r or ∂ 1 ( r ∝ ) = ∂ 0 ( r ) for all terms y r ⇁ x . Prop osition 11 Any involutive dir e ct Ho ar e flow c ate gory is an involutive dir e ct flow c ate gory. In verse Flow Categories. A lo c al ly c artesian close d join bisemilattic e ( lc c join bisemilattic e ) P = h P , ⇒i is a join bisemilattice P augmented with a lo c al implic ation op er ator ⇒ which makes each lattice of comono ids Ω ( x ) into a Heyting algebr a for each type x , by satisfying the dia lectical a xiom v ⊗ w x u iff v x w ⇒ u . The lo c al implic ation functor Ω ( x ) co op ⇒ x − → MSL , defined by ⇒ x ( x ) df = Ω ( x ) = h Ω ( x ) , ⊗ , x i and ⇒ x ( w ) df = Ω ( x ) w ⇒ ( ) − → Ω ( x ), is a con trav ariant join semilattice functor, since (i) ⇒ x ( x ) = Id Ω ( x ) , (ii) ⇒ x ( v ⊗ u ) = ⇒ x ( u ) · ⇒ x ( v ), (iii) if v u then ⇒ x ( v ) ≤ ⇒ x ( u ), (iv) ⇒ x (0) = ⊤ , and (v) ⇒ x ( u ⊕ v ) = ⇒ x ( u ) ∧ ⇒ x ( v ). An inverse flow c ate gory h P , ✷ ( ) i consis ts of a lcc join bisemilattice P = h P , ⇒i , and a contra v aria n t meet semilattice functor P co op ✷ ( ) − → MSL into the categ o ry of meet semilattices, which is standar d on s ubt yp es. In mor e detail, 1. ✷ x is a meet subsemilattice o f c o monoids ✷ x ⊆ Ω ( x ) = h Ω ( x ) , ⊗ , x i for each type x ; 2. ✷ y ✷ r ← ✷ x is a morphism of meet semilattices for each term y r ⇁ x calle d the inverse fl ow sp ecified by r , with ✷ r ( x ) = y a nd ✷ r ( u ⊗ u ′ ) = ✷ r ( u ) ⊗ ✷ r ( u ′ ); 27 3. ✷ ( ) is co n tr a v aria ntly functorial, with ✷ x = Id ✷ x , and ✷ s ⊗ r = ✷ r · ✷ s ; 4. ✷ ( ) is a meet semilattice functor, (i) if s r then ✷ s ≤ ✷ r , (ii) ✷ 0 = ⊤ , a nd (iii) ✷ r ⊕ s = ✷ r ∧ ✷ s ; 5. ✷ ( ) is standard on subtypes , in that ✷ ( ) restricted to x -comonoids is the lo cal implication functor ⇒ x = Inc co op x · ✷ ( ) that is, subtype inv er se flow ✷ x ✷ u ← ✷ x is just implication ✷ u ( u ′ ) = u ⇒ u ′ for e ac h comonoid u ∈ ✷ x . F or any functional term y f ⊣ f op ⇁ x inv erse flow along f is ca lled either substitu tion or inverse image a long f and denoted b y sub f df = ✷ f . wher eas inv er se flow a lo ng f op is called un iversal quantific ation along f a nd denoted b y ∀ f df = ✷ f op . Thus, there is a dia le c tical base ( P ⊣ ) op ✷ ( ) − → adj defined on functional terms y f ⊣ f op ⇁ x by ✷ f df = (sub f ⊣ ∀ f ). Comonoids and implication form an inv er se flow categ ory h ✷ x , ⇒ x i fo r each type x . A morphism of inverse flow c ate gories h P , ✷ P, ( ) i H − → h Q , ✷ Q, ( ) i is a mo rphism of join bisemilattices P H − → Q which pre s erv es flow H co op · ✷ Q, ( ) = ✷ P, ( ) . So inclusio n h ✷ x , ⇒ x i Inc coop x − → h P , ✷ ( ) i is a morphism of inv erse flow catego ries. A c ont r avariant inverse flow c ate gory h P , ✸ ( ) i consists of a join bis emilattice P , and a meet semilattice functor P co ✸ ( ) − → MSL , s uc h that h P co , ✸ ( ) i is a cov ar ian t inv erse flow categ ory . An lcc join bisemilattice P has inverse Ho ar e flow when for any P -term y r ⇁ x and any p ostcondition (target como no id) u ∈ Ω ( x ), there is a pr econdition (sourc e comonoid) ✷ r ( v ) ∈ Ω ( y ) called the we akest (lib er al) pr e c ondition of r which s atisfies the ax io ms (dual to the direct flow case) v ✷ r ( u ) iff v ⊗ r r ⊗ u iff ( v : y r → u : x ) ∈ Ar( H ( P )) ✷ s ⊗ r ( u ) ✷ s ( ✷ r ( u )) for a n y como noid v ∈ Ω ( y ), and any co mposa ble P -term z s ⇁ y . The first axiom states that ✷ r ( u ) = W { v ∈ Ω ( y ) | v ⊗ r r ⊗ u } . In addition, a n y inv er se Hoare flo w must satisfy the closure compatibilit y axiom ✷ r ( u ¬ ¬ ) = ✷ r ( u ) for any comonoid u ∈ Ω ( x ), where u ¬ is the bo olean complemen t u ¬ df = u ⇒ 0 x . Some identities for ✷ ( ) are: ✷ u ( u ′ ) = u ⇒ u ′ for all comonoids u ∈ Ω ( x ); ✷ s ⊗ r ( u ) = ✷ s ( ✷ r ( u )) for t w o comp osable P -terms z s ⇁ y and y r ⇁ x ; ✷ r ( u ) = y iff r r ⊗ u iff u ∈F 1 ( r ). A lcc join bisemilattice P has kernels when for a n y P -ter m y r ⇁ x there is a kernel pr e c ondition ∅ 0 ( r ) ∈ Ω ( y ) which sa tisfies the axioms v ∅ 0 ( r ) iff v ⊗ r = 0 iff v ∈ I 0 ( r ) ∅ 0 ( s ⊗ r ) = ∅ 0 ( s ⊗ ∅ 0 ( r ) ¬ ) for any precondition v ∈ Ω ( y ), and any comp osable P -ter m z s ⇁ y . The first axiom states that ∅ 0 ( r ) = W I 0 ( r ) ∈ I 0 ( r ), o r equiv alently that the source ideal of r is the principal ideal I 0 ( r ) = ↓∅ 0 ( r ) . So the s ource idea l op erator factors ∅ 0 ( r ) · ↑ y = I 0 () = ✷ ( ) · ker as kernel followed by principal ideal { ( ) } r {} = ✷ r op · ↑ x and that kernel factor s a s s o urce ideal follo wed b y join ∅ 0 = I 0 () · W y (when joins exist for a ll ideals of como no ids), since the join op erator I (Ω ( y )) ∨ y − → Ω ( y ) forms a reflective pair W y ⊣↓ y with the principal ideal op erator Ω ( y ) ↓ y − → I (Ω ( y )). (so the kernel of ✷ r is the s ource idea l I 0 ( r ), whic h matches the fact that the kernel of r is the join o f the sour ce ideal W y I 0 ( r )). Some identities for the kernel op erator ∅ 0 are: “kernel is standar d (negatio n) o n subtypes” ∅ 0 ( u ) = u ¬ for a n y como noid u ∈ Ω ( x ); “ k ernel transla tes guar ds to implications” ∅ 0 ( v ⊗ r ) = v ⇒∅ 0 ( r ) for any guarded 28 term y v ⊗ r ⇁ x ; a nd “only zero has top kernel” ∅ 0 ( r ) = y iff r = 0 y ,x for a ny term y r ⇁ x . A ter m y r ⇁ x is we akly total when its kernel is the empty comonoid ∅ 0 ( r ) = 0 y . If P has inv er se Hoare flow ✷ ( ) , then it has kernels ∅ 0 defined to be the inverse flo w of the b ottom (zero) p ostcondition ∅ 0 ( r ) df = ✷ r (0 x ) for any term y r ⇁ x . Con versely , if P has kernels, then it has inv erse Hoa re flow defined to b e the k ernel of the tensor pro duct ✷ r ( u ) df = ∅ 0 ( r ⊗ u ¬ ). A inverse Ho ar e flow c ate gory is a lcc join bisemilattice which has inverse Hoare flow, o r eq uiv a len tly , kernels. Prop osition 12 Any inverse Ho ar e flow c ate gory P is a inverse flow c ate gory h P , ✷ ( ) i . Dialectical Fl o w Categories. A c ovariant diale ctic al flow c ate gory h P , ✷ i , or diale ctic al c ate gory for short, consis ts of an affirmation bisemilattice P , and a dialectical base P ✷ − → adj of como noids, such that the direct flow asp ect h P , ✷ ( ) i is a direct flow categ ory . The inv erse flow a spect h P , ✷ ( ) i is an inv erse flow categor y with lo cal implication defined to b e interior of inv erse flow v ⇒ u df = ✷ v ( u ) ◦ for co mo noids v , u ∈ Ω ( x ), since w ⊗ v u iff ✷ v ( w ) u iff w ✷ v ( u ) iff w ✷ v ( u ) ◦ . Note: the inv erse flow ✷ v ( u ) alone satis fies ✷ v ( u ) x and ✷ v ( u ) = ✷ v ( u ) ∧ ✷ v ( u ) for comonoids v , u ∈ Ω ( x ). A morphism of diale ctic al c ate gories h P , ✷ P i H − → h Q , ✷ Q i is a mo r phism of join bisemilattices P H → Q s uc h that H is both a morphism of direct flow categories h P , ✷ P, ( ) i H − → h Q , ✷ Q, ( ) i , and a morphis m of inv erse flow categ ories h P , ✷ P, ( ) i H − → h Q , ✷ Q, ( ) i . Comonoids and conjunction/implication form a one-ob ject dialectica l categ ory h ✷ ( x ) , ⊗ x ⊣ ⇒ x i for each type x . So inclusion h ✷ ( x ) , ⊗ x ⊣ ⇒ x i Inc x − → h P , ✷ i is a morphism o f dia lectical c a tegories for ea c h t yp e x in P . A dia le ctic al Ho ar e flow c ate gory is an affirmatio n bisemilattice which has direct/ in verse Hoare flo w, or equiv alently , range s a nd kernels. Prop osition 13 Any dia le ctic al Ho ar e flow c ate gory is a diale ctic al flow c ate gory. When a dialectical Hoare flow catego ry has a n inv o lution, it has domains, kernels, ra nges and co k ernels for any terms y r ⇁ x . The domain and kernel a r e disjoint for a n y term y r ⇁ x , since ∅ 0 ( r ) ⊗ r = 0 y ,x implies ∂ 0 ( ∅ 0 ( r ) ⊗ ∂ 0 ( r ) ) = ∂ 0 ( ∅ 0 ( r ) ⊗ r ) = ∂ 0 (0 y ,x ) = 0 y implies ∅ 0 ( r ) ⊗ ∂ 0 ( r ) = 0 y . How ev er, they usually do not cov er the so urce type ∅ 0 ( r ) ⊕ ∂ 0 ( r ) 6 = y . Disjoint ness of do main and k ernel implies that, if r is total then r is weakly total. F urthermore, if y r ⇁ x is w eakly total then s ⊗ r = 0 z ,x implies s = 0 z ,y for all terms z s ⇁ y (this is often an a lternate definition of “ totalness”). A c ontr avariant diale ctic al flow c ate gory h P , ✸ i consists of an affirmatio n bisemilattice P , and a dialectical base P op ✸ − → adj , such that h P op , ✸ i is a cov ariant dia lectical categ ory . An involutive diale ctic al flow c ate gory P = h P , ( ) ∝ , ✷ i consists of an inv olutive affirmation bisemilattice P = h P , ( ) ∝ i , and a cov ar ia n t dia lectical flow ca tegory P = h P , ✷ i . Defining ✸ by ✸ df = ( ) ∝ · ✷ mak es P = h P , ✸ i into a contra v ariant dialectical flow categ ory , where inv olution h P op , ✸ i ( ) ∝ − → h P , ✷ i is a morphism o f dialectical flow ca tegories; so that inv olution satisfies the c o ndition ✷ r ∝ = ✸ r , or the equiv alent condition ✷ r ∝ = ✸ r , for all terms y r ⇁ x . F acts 2 L et y f ⊣ f op ⇁ x b e any functional term in a diale ctic al flow c ate gory P . 1. When P = h P , ✷ i is a c ovariant diale ctic al flow c ate gory, inverse f -flow is e qual to dir e ct f op -flow ✷ f = ✷ f op , and we have the “squar e” adjoint triple ✷ f ⊣ ✷ f = ✷ f op ⊣ ✷ f op 2. When P = h P , ✸ i is a c ontr avariant diale ctic al flow c ate gory, inverse f op -flow is e qual to dir e ct f -flow ✸ f op = ✸ f , and we have the “diamond” adjoint triple 29 ✸ f op ⊣ ✸ f op = ✸ f ⊣ ✸ f 3. When P = h P , ( ) ∝ , ✷ i is an involutive diale ctic al flow c ate gory with ✸ = ( ) ∝ · ✷ , the “squar e” and “diamond” adjoint triples ab ove ar e identic al. Either of these thr e e c ases justifies the c ommon notation ∃ f ⊣ sub f ⊣ ∀ f Hyp erdo ctrines. W e discuss here the v ery impor tan t example of “dialectical functional spans (h yp erdoc- trines)”. The “action” of a term-pr o cess y r ⇁ x is concentrated in and lo calized to tw o “ loci o f activity”, a so urce subtype called the domain(-of-definition) of r and a target subt ype called the r ange of r . These lo ci are p olar wa ys to compute the “effect” or “rea d-out” of r , and define dialectica lly oppo sed predica te transfor ma tions. So term-pro cesses r b ecome dia lectical predicate tra nsformers. W e assume that w e are in a spanna ble join bisemilattice P . F or any t yp e x let c Ω ⊣ ( x ) denote x -comonoids in the join bisemilattice c P ⊣ . These ar e diag onal functional spa ns of the form φ = ( x f ⊣ f op ↽ y f ⊣ f op ⇁ x ), and c a n be identified with functional terms y f ⊣ f op ⇁ x into x . By definition of c Ω ⊣ ( x ), the under lying P -term o pera tor c P ⊣ [ x, x ] ♭ xx − → P [ x, x ] restricts to comono ids: for an y diagonal functional s pan φ as ab ov e , the underlying P -term is ♭ x ( φ ) = ♭ xx ( φ ) = f op ⊗ f , the como no id asso ciated with the functional term y f ⊣ f op ⇁ x . So ♭ x is the asso ciate d c omonoid op erator . Analogo us to the term/span reflective pair ♮ xx = ( ♭ xx ⊣ ♯ xx ), we assume the existence of a rig h t a djoin t left inv erse c Ω ⊣ ( x ) ♯ x ← − Ω ( x ) to the ass ociated comono id op erator ♭ x . This means e xistence o f a r eflectiv e pair c Ω ⊣ ( x ) ♮ x − → Ω ( x ) o f mo notonic functions ♮ x df = ( ♭ x ⊣ ♯ x ). W e assume that the reflective pair ♮ x and the ter m/span reflective pair ♮ xx commute with the inclusion/interior coreflec tive pairs, for ming a comm uting squar e c Ω ⊣ ( x ) ♮ x − → Ω ( x ) Inc ⊣ ( ) ◦ ↓ ↓ In c ⊣ ( ) ◦ c P ⊣ [ x, x ] ♮ xx − → P [ x, x ] for a n y t yp e x . This implies that ♯ x m ust b e defined by ♯ x = Inc · ♯ xx · ( ) ◦ , and must satisfy the equality ♯ x · ♭ x = Id; so that for any x -sub ob ject y f ⊣ f op ⇁ x and any x -c o monoid u ∈ Ω ( x ), w e hav e the equiv alenc e ♭ x ( y f ⊣ f op ⇁ x ) u iff ( y f ⊣ f op ⇁ x ) ( x e ⊣ e op ⇁ x ) wher e ♯ x ( u ) = z e ⊣ e op ⇁ x and e op ⊗ e = u iff there is a functiona l term y h ⊣ h op ⇁ z such that f = h ⊗ e and e op ⊗ h op = f op . So we can interpret ♯ x ( u ) to b e the “la rgest” x - sub o b ject who s e asso ciated comonoid is u . In terpreting in terms o f g raphs, for an y P -comonoid u ∈ Ω ( x ) with ov e r lying s pan ( P ⊣ -graph) ♯ xx ( u ) = ( x p 0 ⊣ p op 0 ↽ y p 1 ⊣ p op 1 ⇁ x ) we must ha ve ♯ x ( u ) = z e ⊣ e op ⇁ x = ( x e ⊣ e op ↽ z e ⊣ e op ⇁ x ) the equalize r (self-lo ops) of this P ⊣ -graph. Moreover, e op ⊗ e = p op 0 ⊗ p 1 = u . So u sp ecifies s e lf-loops for P ⊣ -graphs. Let C b e a semiex act categor y that ha s epi-mono factorizations w hich are preser v ed b y pullback. A C -span τ = ( y t 0 ← t t 1 → x ) is total when the source leg t t 0 → y is an epimorphism. T otal spans are clo s ed under identit ies a nd tenso r pro ducts, and hence fo rm a subca teg ory of spans. C -ar rows, as C -spa ns via Y oneda, are total. The domain o f any s pa n ρ = ( y r 0 ← r r 1 → x ) is the C -monomor phism d r m 0 → y , or more precisely the s ubtype d r y 1 C ( m 0 ) ⇁ y , where r 0 = e 0 · m 0 is the epi- mo no factoriza tion of r 0 through the image C -ob ject d r . The totalization of any span ρ = ( y r 0 ← r r 1 → x ) is the span ρ † = ( d r e 0 ← r r 1 → x ). Clear ly , y 0 C ( m 0 ) ⊗ ρ † = y 1 C ( m 0 ) op ⊗ ρ † = ρ and y 1 C ( m 0 ) ⊗ ρ = ρ † . T otal spans have the following prop erty: if σ ⊗ ρ = 0 z x for some span z σ ⇁ y , then σ = 0 z y . 30 Our approa c h re g ards the notion of doma in- of-definition as fundamental, and defines totalness as a derived notion. The domain subtyp e of any term y r ⇁ x is the sour ce subtype ∂ 0 ( r ) = d r i r ⊣ p r ⇁ y w hich satisfies the ax io ms: (1) “minimality” z ∂ 0 ( r ) iff p ⊗ i ⊗ r = r for any so urce subtype z i ⊣ p ⇁ y ; (2) “comp osition” ∂ 0 ( s ⊗ r ) = ∂ 0 ( s ⊗ p r ) for any c o mposa ble term z s ⇁ y ; and (3) “mono tonicit y” r r ′ implies ∂ 0 ( r ) ∂ 0 ( r ′ ) for any parallel term y r ′ ⇁ x . Define the totalization of r to b e the r -subterm r † df = i r ⊗ r . A term y r ⇁ x is total when its do main is the larg est sour ce subtype, the entire source type ∂ 0 ( r ) = y . Some identities for the doma in op erator ∂ 0 are: types are their own doma in ∂ 0 ( x ) = x ; the totalizatio n is total, since ∂ 0 ( r † ) = ∂ 0 ( i r ⊗ r ) = ∂ 0 ( i r ⊗ p r ) = ∂ 0 ( d r ) = d r ; functional terms y f ⊣ f op ⇁ x are total, since the counit inequality y f ⊗ f op implies y = ∂ 0 ( y ) ∂ 0 ( f ⊗ f op ) = ∂ 0 ( f ⊗ p f op ) ∂ 0 ( f ⊗ x ) = ∂ 0 ( f ) y ; in particular, subtypes are tota l ∂ 0 ( y i ⊣ p ⇁ x ) = y ; domain subt yp es are their own domain, since ∂ 0 ( p r ) = ∂ 0 ( p r ⊗ d r ) = ∂ 0 ( p r ⊗ r † ) = ∂ 0 ( r ) = d r ; only zero has empty domain ∂ 0 ( r ) = 0 ⊥ 0 ,y ⊣⊥ y, 0 ⇁ y iff r = 0 y ,x for any term y r ⇁ x ; and given any tw o tota l terms z s ⇁ y and y r ⇁ x , the comp osite term z s ⊗ r ⇁ x is a lso total, since ∂ 0 ( s ⊗ r ) = ∂ 0 ( s ⊗ p r ) = ∂ 0 ( s ⊗ y ) = ∂ 0 ( s ) = z . The domain sub obje ct of any term y t ⇁ x is the so urce sub ob ject d t i d ⊣ p d ⇁ y where the ter m t ha s non-nil ac tion. The do main sub ob ject (if it exists) is the “sma lle st” so urce s ubob ject such that the term t is recov erable from the asso ciated subter m by the identit y t = ( p d ⊗ i d ) ⊗ t ; so that, t v ⊗ t iff ♭ y ( d t i d ⊣ p d ⇁ y ) v iff ( d t i d ⊣ p d ⇁ y ) ♯ y ( v ) for any so urce comonoid v ∈ Ω ( y ). The a s socia ted t -subterm t † = i d ⊗ t is called the totalization of t . The term t and its totalizatio n t † are equiv alent by the identit ies ( t = p d ⊗ t † = P [ i d ,x ] ( t † ) t † = i d ⊗ t = P [ i d ,x ] ( t ) ) . A ter m t is total w he n its do ma in sub ob j ect is the tota l source type d t = y ; and then t † = t . T otal ter ms are close ab ov e w.r.t. term ent ailment order. Since functional terms (in particula r, ide ntit y terms) are total, a nd the co mposite of total terms are als o tota l, total terms form a bip oset P † , a subbip oset of P , P ⊣ ⊆ P † ⊆ P , which is the homset order clo s ure o f P ⊣ . So P † is a subbip oset P , which pr eserves homset joins but usually do es not hav e a b ottom. T otal terms in Heyting ca tegories hav e b een suggested [Hoare] (although no t by that na me) as go od mo dels for prog rams (brief discussion in the section on Heyting categorie s). Concurrent with the development of this pap er, an a lg ebraic theory for the “laws o f prog amming” has bee n a dv o cated [Hoa re ], whose axioms ar e es s en tially those for Heyting c a tegories; or more pr ecisely , Hey ting categorie s (in pa rticular, cHc) with a ffirmation/considera tion modalities and domain subtypes. But most of the “laws of prog ramming” can b e in terpreted in the categ ory of spans b C of a semiexact categor y C . In the prog ram in terpretation, a rbitrary C -spa ns repres e nt prog am sp ecifications, total C -spa ns represe nt progra ms, and either arbitra ry or monomor phic subt yp e s (either C -arr o ws or C -monomor phisms) represent conditions. T yp es repre s en t lo cal contexts for local states o f the system. Span entailmen t order is in terpreted as a measure of “ nondeterminism” with ρ σ a sserting that ρ is more deterministic than σ . The top span y 1 yx ⇁ x , which is the pr oduct span, represe n ts the worst (most nondeterministic) program, and C - a rrows (as spa ns v ia Y oneda) repr esen t fully deterministic (minimally no ndeter ministic) progra ms. The b ottom (initial) span y 0 y,x ⇁ x , although deter ministic, is no t a pr ogram since its domain-of-definition is empty . The totalization d r ρ † ⇁ x of a span y ρ ⇁ x is the leas t deterministic program (on the doma in-of-definition) of that sp ecification. In s ummary , the “Laws of P rogramming” ca n be interpreted in categ o ries of spans as follows. 31 “Laws of Pr ogramming” categorie s of spans progra m sp ecifications S spans y ρ ⇁ x progra ms P tota l spans y τ ⇁ x conditions b comonoids φ ∈ Ω ( x ) subtypes y f → x nondeterminism order P ⊆ Q span entailmen t order ρ σ sequential comp osition P ; Q tensor pro duct σ ⊗ ρ nondeterministic c hoice P S Q bo olea n sum σ ⊕ ρ SKIP , the nop II ident ity (ob jects-as-spans) x x ⇁ x ABORT , the w orst progr am ⊥ top span y 1 yx ⇁ x conditional or branch P ⊳b⊲Q derived expr ession ( v ⊗ ρ ) ⊕ ( ∼ v ⊗ σ ) if b then P els e Q where ∼ v df = ( v ⇒⊥ y ) iteration or while -lo op b ∗ P deriv ed expressio n ( u ⊗ ρ ) • ⊗ ∼ u while b do P where ( ) • is the consideration mo dality In this pap er these la ws (concer ning str ucture a nd flow in categor ies of spa ns) ar e connected with the older progra m semantics which uses Hoar e triples. Given any C -arrow y h → x , comp osition defines a direct image monotonic function Sub ( y ) ∃ ∗ h − → Sub ( x ) where ∃ ∗ h ( z g → y ) = g · C h , and an in verse image monotonic function Sub ( y ) sub ∗ h ← − Sub ( x ) wher e sub ∗ h ( w f → x ) = ˆ w ˆ f → y the pullback of f a long h . It is easy to c hec k that b C has b oth domains a nd ranges, with ∂ 0 ( ρ ) = ( y r 0 ← r r 0 → y ) and ∂ 1 ( ρ ) = ( x r 1 ← r r 1 → x ) fo r any span ρ = ( y r 0 ← r r 1 → x ) ; so it has direct Hoare flow ✷ ρ defined by ✷ ρ ( ψ ) df = ∂ 1 ( ψ ⊗ ρ ) = ∃ ∗ r 1 (sub ∗ r 0 ( g )) for a ny y -comonoid ψ = ( y g ← z g → y ). With the obvious involution b C is an inv o lutiv e dir ect Hoare flow category ; so it has dual direct Hoa r e flow ✸ ρ defined by ✸ ρ ( ψ ) = ✷ ρ op ( ψ ) = ∂ 0 ( ρ ⊗ φ ) = ∃ ∗ r 0 (sub ∗ r 1 ( f )) for any x -comono id φ = ( x f ← w f → x ). By assuming lo cal c a rtesian clo s ure, we c a n prov e [F reyd] that b C is standard ca rtesian. When b C = h b C , ✷ ( ) i is a direct flow categ ory , the direc t flow along a n y ter m y ρ ⇁ x dec omposes a s ✷ ρ = ✷ r op 0 ⊗ r 1 = ✷ r op 0 · ✷ r 1 = s ub r 0 · ∃ r 1 , and sa tisfies the “B ec k co ndition” ∃ f · sub g = ✷ f · ✷ g op = ✷ f ⊗ g op = ✷ ˆ g op ⊗ ˆ f = ✷ ˆ g op · ✷ ˆ f = sub ˆ g · ∃ ˆ f for the pullback s pan y ˆ g ← ˆ x ˆ g → z o f any opspan y f → x g ← z , and when b C = h b C , ✷ ( ) i is a inv er se flow categ ory , the in verse flow along a ny term y ρ ⇁ x deco mposes a s ✷ ρ = ✷ r op 0 ⊗ r 1 = ✷ r 1 · ✷ r op 0 = sub r 1 · ∀ r 0 , and satisfies the “Beck condition” ∀ g · sub f = ✷ g op · ✷ f = ✷ f ⊗ g op = ✷ ˆ g op ⊗ ˆ f = ✷ ˆ f · ✷ ˆ g op = sub ˆ f · ∀ ˆ g . Generalizing from this, a hyp er do ct rine ( of c omonoids) h C , ∃ , sub , ∀i consists o f (1) a se miexact category C , and (2) t wo connected dialectical bases C C ( ) − → adj and C op C ( ) − → adj , where C f = Sub ( y ) ∃ f ⊣ sub f − → Sub ( x ) and C f = Sub ( x ) sub f ⊣∀ f − → Sub ( y ) for any C -arrow y f → x , which s atisfy either of the equiv a len t “Beck conditions” a bov e. Suppo se that P is a s pannable dialectica l flow categ o ry . Flow alo ng arbitrary P -terms factors in to flow along functional P -terms: ✷ r = ✷ r op 0 ⊗ r 1 = ✷ r op 0 · ✷ r 1 = sub r 0 · ∃ r 1 for any term y r ⇁ x with o verlying span of functional ter ms ♯ y x ( r ) = ( y r 0 ⊣ r op 0 ↽ r 01 r 1 ⊣ r op 1 ⇁ x ), since ea c h P -term fa c tors through its asso ciated functional span r = r op 0 ⊗ r 1 . This decomp osition of flo w 32 ✟ ✟ ✟ ✟ ✟ ✟ ✯ ❍ ❍ ❍ ❍ ❍ ❍ ❥ ✲ • • • sub r 0 ∃ r 1 ✷ r P ( y ) P ( x ) P ( r 01 ) corres p onds to the followin g diag ram of [Lawvere89 ] ✟ ✟ ✟ ✟ ✟ ✟ ✯ ❍ ❍ ❍ ❍ ❍ ❍ ❥ ✲ • • • starting finishing doing start finish do W e automatically satisfy a g eneralized “ Bec k c o ndition”. Prop osition 14 1. If P is a sp annable diale ctic al flow c ate gory, then P ⊣ is a hyp er do ctrine of c omonoids. 2. If C is a hyp er do ct rine of c omonoids, then b C is a sp annable diale ctic al flow c ate gory. Theorem 3 The sp anning c onstru ction b ( ) is left adjo int to the functionality c onstruction ( ) ⊣ Hyp er do ctrines of Comonoi ds b ( ) ⊣ ( ) ⊣ − → Sp annable Diale ct ic al Flow Cate gories forming a c or efle ction, with b ( ) emb e dding hyp er do ctrines into sp annable diale ctic al flow c ate gories, ( ) ⊣ c or e- fle cting sp annable dial e ctic al flow c ate gories onto hyp er do ctrines. 33 A Matrices There is a cHc with bipro ducts M ( R ) a sso ciated with the closed p oset of reals R = h [0 , ∞ ] , ≥ , + , 0 , ∧ , ∞i , whose ob jects ar e sets X , Y , Z , · · · , whose mo r phisms Y φ ⇁ X are Y × X -indexed collections of rea ls φ = { φ y x | y ∈ Y , x ∈ X } (that is, real- v alued characteristic functions Y × X φ → [0 , ∞ ]), whose compos itio n Z ψ ◦ φ ⇁ X for morphisms Z ψ ⇁ Y and Y φ ⇁ X is p oin twise addition ( ψ ◦ φ ) z x df = V y ∈ Y [ ψ z y + φ y x ], and whose identit y X X ⇁ X at X is defined b y X x ′ x = 0 if x ′ = x, = ∞ otherwise. T erms Y φ ⇁ X ca n b e view ed as fuzzy re lations , where φ y x measures the degr ee of membership in φ , with φ y x = 0 asserting full (cris p) mem b ership ( y , x ) ∈ φ and φ y x = ∞ as serting full nonmem b e r ship ( y , x ) 6∈ φ . F or the co mplete (cartesian) closed p oset of bo olean v alues 2 = h{ 0 , 1 } , ≤ , ∧ , 1 , ∨ , 0 i the asso ciated cHc with bipro ducts is M ( 2 ) = Rel the category of o rdinary relations. More g enerally , every cHc H has an as socia ted matrix c ate gory M ( H ), whose ob jects are H -ve ct ors X = h X , | | X i whe r e X is a n index ing (no de) set and X | | X → Ob j ( H ) is a (typing) function, whose a r rows Y R ⇁ X are H - matric es wher e R is a Y × X - index ed collec tion of H -terms R = | y | Y r yx ⇁ | x | X | y ∈ Y , x ∈ X (in other words, a generalized Ar( H )-v alued characteristic functions Y × X r → Ar ( H ) compatible with sour ce and target), whose ho mset order is p oint wise order ( s y x ) ( r y x ) when s y x r y x for all y ∈ Y and x ∈ X , whose comp osition is matrix tensor product ( S ◦ R ) z x = S z Y ◦ R Y x = W y ∈ Y ( s z y ◦ r y x ) “ matrix tensor pr o duct ” for co mposa ble matrices Z S ⇁ Y and Y R ⇁ X , who se identit y at X is the diago nal matrix X X ⇁ X defined as ident ity H - terms X xx = | x | X | x | X ⇁ | x | X on the diagonal and zero (bottom) H - terms X x ′ x = | x ′ | X 0 ⇁ | x | X off the diagona l, and whose matrix tensor implications are ( S/ – R ) z y = S z X / – R y X = V x ∈ X ( s z x / – r y x ) “ right matrix tensor implic ation ” and ( R – \ T ) xz = R Y x – \ T Y z = V y ∈ Y ( r y x – \ t y z ) “ left matrix tensor implic ation ”. Matrices Y R ⇁ X can b e viewed as fuzz y H -r elations . F or any cHc H , the matrix catego ry M ( H ) is a complete Heyting category for w hich bipro ducts (type sums) exist. The sum of an a rbitrary indexed collection of H - t y pes is pr ecisely the bipro duct of an H -vector. Given any H -vector X = h X , | | X i , the su m typ e of X is the comp osite H -type ⊕X having {| x | X ι x ⊣ π x ⇁ ⊕X | x ∈ X } as a pair wise disjoin t collection of subtypes which co ver ⊕X . So the type ⊕X , and its comp onen t injections ι x and pro jections π x , satisfy the “c o monoid covering axiom” W x ∈ X ( π x ◦ ι x ) = ⊕X , and the “ subt ype disjointness axio ms ” ι x ◦ π x ′ = x if x = x ′ , = 0 x,x ′ otherwise, or the “comonoid pairwise disjointness axioms” ( π x ′ ◦ ι x ′ ) ∧ ( π x ◦ ι x ) = 0 ⊕X for x ′ 6 = x . Assume H is a cHc with bipro ducts. The t yp e sum op erator is a sum functor M ( H ) ⊕ → H , which maps each H -vector X = h X, | | X i to its underlying su m typ e ⊕X , and maps ea ch H -matrix Y R ⇁ X where R = ( r y x | y ∈ Y , x ∈ X ) to its sum term ⊕Y ⊕ R ⇁ ⊕X defined by ⊕ R df = W y ∈ Y ,x ∈ X ( π y ◦ r y x ◦ ι x ) the sum o f all the internal subterms of (internalized term entries in) R . The ( Y , X )-th comp onent of the sum functor ⊕ is a join-contin uous monotonic function M ( H )[ Y , X ] ⊕ Y , X − → H [ ⊕Y , ⊕X ]. The category H can be embedded in to the category o f matrices M ( H ) by the singleton functor H {} − → M ( H ), which embeds sca la r o b jects ( H -type s ) a s H -vectors x 7→ { x } = h 1 , x i and embeds scalar arrows ( H -ter ms) as H - matrices r 7→ { r } = { y r ⇁ x } . This functor is clearly fully-faithful, since for t wo fixed t ype s y and x , there is a bijection H [ y , x ] ∼ = M ( H )[ { y } , { x } ]. Also, the compos ition of singleton with sum is the ident ity functor {} · ⊕ = Id H . This implies that the sum functor is surjective on ob jects. Let Y and X b e any tw o H -vectors, and le t ⊕Y r ⇁ ⊕X be any H -term. T he matrix Y ( r ) X Y ⇁ X defined by ( r ) X Y df = {| y | Y r yx ⇁ | x | X | y ∈ Y , x ∈ X } , where r y x df = ι y ◦ r ◦ π x is the ( y , x )-th external subterm of r , is called the de c omp osition matrix of r . (The exter nal r -subterms | y | Y r yx ⇁ | x | X are equiv alent and in bijection with the internal r -subterms | y | Y r ′ yx ⇁ | x | X defined by r ′ y x df = π y ◦ r y x ◦ ι x = ( π y ◦ ι y ) ◦ r ◦ ( π x ◦ ι x ) for y ∈ Y 34 and x ∈ X , and r is the jo in r = W y ∈ Y W x ∈ X r ′ y x . These in ternal subterms a re predominant in topo matrices (next sectio n). Such decompositio ns, esp ecially w.r.t. top ological ba ses of comono ids (next s ection), give an int ernal r e presen tation of cHc’s as distributor catego ries.) This defines a p artition jo in-con tinuous monotonic function H [ ⊕Y , ⊕X ] # Y , X − → M ( H )[ Y , X ], wher e # Y , X ( r ) df = ( r ) X Y . Moreov er, by the co monoid cov ering axioms for bipro ducts, any H -term ⊕Y r ⇁ ⊕X is recov erable from its decomp osition matrix ( r ) X Y by apply ing the sum functor ⊕ Y , X (# Y , X ( r )) = ⊕ Y , X (( r ) X Y ) = W y ∈ Y ,x ∈ X r y ,x = r . This means that the sum functor is full (surjective on arr o ws). Conv ersely , by the subtype disjoint ness axioms for bipr oducts, an H - matrix Y R ⇁ X is recov erable fro m its sum ter m ⊕ R by a pplying the partition function # Y , X ( ⊕ Y , X ( R )) = R . This means that the sum functor is faithful (injective on arrows). So for tw o fixed vectors Y and X , the par tition and sum mono to nic functions are inv er se to each other, a nd define an isomor phis m H [ ⊕Y , X ] ∼ = M ( H )[ Y , X ]. Lemma 2 The sum functor M ( H ) ⊕ → H is fu l ly-fa ithful and su rje ctive on obje ct s. A ma trix Y R ⇁ { x } is called a c olumn H -ve ctor . If ⊕Y r ⇁ x is any term, then the Y - sour c e de c omp osition of r is the c o lumn vector Y ] r [ Y ⇁ { x } defined by ] r [ Y df = | y | Y r yx ⇁ x | r y x = ι y ◦ r , y ∈ Y . The Y - sour c e c otupling of a column v ector Y R ⇁ { x } , where R is the Y - indexed collection of terms | y | Y r yx ⇁ x | y ∈ Y , is the H -term ⊕Y [ R ] Y ⇁ x defined b y [ R ] Y df = W y ∈ Y ( π y ◦ r y x ). The source decomp osition and cotupling op erations a re inv erse to each other, with [] r [ Y ] Y = r and ][ R ] Y [ Y = R . Dually , a matrix { y } R ⇁ X is called a r ow H -ve ctor . If y r ⇁ ⊕X is any term, then the X - tar get de c omp osition of r is the r o w vector { y } i r h X ⇁ X defined by i r h X df = y r yx ⇁ | x | X | r y x = r ◦ π x , x ∈ X . The X - tar get tupling of a row vector { y } R ⇁ X , where R is the X -indexed collection of terms y r yx ⇁ | x | X | x ∈ X , is the H -term y h R i X ⇁ ⊕X defined by h R i X df = W x ∈ X ( r y x ◦ ι x ). The target decomp osition and tupling oper ations are inverse to each other, with hi r h X i X = r and ih R i X h X = R . An y H -vector X decomp oses the iden tity term ⊕X ⊕X ⇁ ⊕X in either of tw o ways: as the source de- comp osition column vector X ι X ⇁ { ⊕X } defined by ι X df = ] x [ X = | x | X ι x ⇁ ⊕X | x ∈ X , o r as the tar get decomp osition row vector { ⊕X } π X ⇁ X defined by π X df = i x h X = ⊕X π x ⇁ | x | X | x ∈ X . Moreover, the iden- tit y matrix a t X decomp oses as ι X ◦ π X , and the ident ity matrix at { ⊕X } deco mposes as π X ◦ ι X , so that X ι X ⇁ { ⊕X } and { ⊕X } π X ⇁ X are inv erse matrices. Since ι X and π X are in verse pa irs, they are adjoint pairs in b oth dire c tions X ι X ⊣ π X ⇁ { ⊕X } and { ⊕X } π X ⊣ ι X ⇁ X . So , given an y term ⊕Y r ⇁ x , (1) the term r and its s ource deco mp osition ] r [ Y are expressible in terms of ea c h other via the direct and in verse left flow expressions ] r [ Y = ι Y ◦ { r } = π Y – \ { r } and { r } = π Y ◦ ] r [ Y = ι Y – \ ] r [ Y , a nd (2) the ter m r and its target decomp osition i r h X are expr essible in terms o f each o ther via the direc t and inv er se r igh t flow ex pressions i r h X = { r } ◦ π X = { r } / – ι X and { r } = i r h X ◦ ι X = i r h X / – π X . F urthermore, g iv en any tw o H -vectors Y and X , (1) a term ⊕Y r ⇁ ⊕ X and its decomp osition matrix # Y , X ( r ) = ( r ) X Y are expressible in ter ms of each other via the direct flow expr essions r = π Y ◦ # Y , X ( r ) ◦ ι X and # Y , X ( r ) = ι Y ◦ { r } ◦ π X , and (2) a n H -matrix Y R ⇁ X and its s um term ⊕Y ⊕ R ⇁ ⊕X are expressible in terms of each other via the direct flow ex pr essions R = ι Y ◦ { ⊕ R } ◦ π X and ⊕ R = π Y ◦ R ◦ ι X . F or ea c h vector X the matrix isomo rphism { ⊕X } π X ⇁ X is the X -th comp onent o f a “ counit” natural isomorphism π : ⊕ · {} = ⇒ Id M ( H ) , since { ⊕ R } ◦ π X = π Y ◦ R . Theorem 4 F or every cHc H with bipr o ducts, the singleton and su m functors form a c ate goric al e quiva- lenc e {} ⊣ ⊕ b etwe en H and its c ate gory of matric es M ( H ) , with identity unit Id H = { } · ⊕ and n atur al isomorphi sm c oun it π : ⊕ · {} = ⇒ Id M ( H ) . 35 F or a n y term y t ⇁ x , since the so urce t yp e y is the direct sum y = d t ⊕ k t and the tar g et t ype x is the direct sum x = r t ⊕ c t , the term t ca n b e e x pressed as the 2 × 2 matrix t = t • • 0 d t ,c t 0 k t ,r t 0 k t ,c t ! where t • • is bo th total and cototal. Every c ategory C has an asso ciated distributor c ate gory D ( C ) defined by D ( C ) df = M ( P ( C )). In more detail, D ( C ) is the category , whose o b jects a r e distribute d C -obje cts or C - ve ctors X = h X, | | X i a s above, whose a rrows Y R ⇁ X a re distribute d C -arr ows o r C - distributors where R ⊆ Y × Ar( C ) × X is a digraph betw een the underly ing no de sets consis ting of compa tible triples: if ( y , r , x ) ∈ R then | y | Y r → | x | X is a C - arrow, whose tensor pr oduct is defined point wise a s ( S ◦ R ) z ,x df = S y ∈ Y [ S z y ◦ R y x ], and whose identit y at X is the C -distributor X df = { ( x, | x | X , x ) | x ∈ X } ⊆ X × Ar( C ) × X cons isting (on the diago nal) of all the C -identities indexed by X . The ( y , x )-th fib er of a D ( C )-term Y R ⇁ X , defined b y R y x df = { y r ⇁ x | r ∈ R } , is a P ( C )-term y R yx ⇁ x , a nd R is the disjoin t union R = ` y ∈Y ,x ∈X R y x of its P ( C )-term fiber s. F or an y categ ory C , the dis tr ibutor ca tegory D ( C ) is a complete Heyting ca tegory for whic h bipro ducts (type sums) exist. The distributor categor y genera lizes the “state s pace construction” from a utomaton theory . In distr ibutor categorie s D ( C ) a c o monoid W of type X is ess en tially a sub ob ject (subset) W ⊆ X , a nd so Ω X ∼ = P ( X ). More generally , e v ery bipos e t P has an asso ciated closur e distributor c ate gory D ( P ) df = M ( P ( P )), whose ob jects, ar rows, tenso r pro duct and identities are a s a bov e, and who s e homset order is the p oint wise closed- below or der. Given any set of attributes o r sorts A , a signature Σ = { Σ y ,a | y ∈ multiset( A ) , a ∈ A } over A determines a term categor y T Σ , the initial alg ebraic theory o ver Σ, who se ob jects are m ultisubsets of A (ar ities, tuplings, etc.) a nd whose arrows ar e tuples of Σ- terms. A par allel pa ir o f arrows Y S,R ⇁ X in the distributor ca tegory D ( T op Σ ) is a Horn clause logic progr am, whose pre dica te names a re X - nodes, w ho se clause names are Y -nodes, whose cla use-head atoms are (w.l.o.g.) co llected together as S , whose clause-b ody atoms are collected tog e ther as R , and whos e asso ciated fixp oin t o pera tor is the inv er se/direct flow comp osite (( ) / – R ) ◦ S defined on Herbrand interpretations with database scheme X . In muc h of the logic of dialectica l pro cesses (in particula r, for Gira rd’s completeness theor em) c lo sure subset catego ries suffice. How ever, for the constr ain t dialectic, the full nondeterminism and pa rallelism of distributor categories is essen tial. 36 Summary The most imp ortant impro vemen t made by dia lectical logic ov er dynamic logic is in the cor rect a nd r igorous treatment of subtypes. It is a ser ious conceptua l err or [Koze n] to vie w dynamic log ic as a tw o-s orted structure: one so rt b e ing progr ams and the o ther sort b eing prop o sitions. The cen tral viewp oint of dialectica l logic is that predicates (here called subt ype s , o r mo r e precisely , c omonoids ) ar e sp ecial lo cal idempotent kinds of progra ms (here ca lled t erms or pr o c esses ), which b y their idemp oten t and coreflexive nature form the standard logical structure of Heyting a lgebra in the intuitionistic cas e or B oolea n algebra in the classica l case. The t wo dynamic log ic op erations of progr a m sequencing and predicate co njunction are co m bined int o the one (hor izon tal) dialectical log ic oper ation of tensor pr o duct o f terms, and the tw o dynamic log ic op erations of pr ogram summing and predicate disjunction ar e combined into the one (vertical) dialectica l log ic op eration of b o ole an s u m . Now, tensor pr oduct and b oole a n sum ar e glo bal o peratio ns on ter ms. In addition, dialectical logic has complement op erations called t ensor implic ations and tensor ne gation [Kent88], whic h are also glo ba l. In contrast to these, dialectical pr ogram sema ntics, introduces lo cal complement op erations called standar d implic ation and standar d ne gation . The global op eration of tensor implication (negation) is replaced by the lo cal standa rd implica tion (nega tion) a nd direct/inv erse flow. Global pro ducts and co products of pr econdition/p ostcondition a ssertions are defined in ter ms of bipr o d- ucts in the indexing catego ry underlying a dialectical flow ca tegory . Bipro ducts mo del the semantic notion of “type sum”. Completely g eneral axioms for domains-of-definition and ra nges , and their negatio n duals kernels and c okernels , c a n be given, whic h ar e equiv alent to predicate transformer axioms, and do not r e- quire the notion of type sum. A nice progr am semantics has a lr eady b een given [Manes] which is based upo n the notions of sums and bikernels , but one o f the purp oses of this pap e r is to show that dialectical progra m s eman tics, the standa rd logical semantics of “relationa l structures”, do es not require sums and only indirectly requires bikernels. Iter ates , the dialectica l log ic rendition of the “co nsideration mo dality” of linear log ic [Girard], are defined a s freely gene r ated monoids, and dialectical categor ies with cons ide r ation mo dalit y are in tro duced to ensure the ex istence of itera tes. The imp ortant do ctrine of linea r logic, para- phrased by the statement that “the familiar c o nnectiv e o f standar d negatio n factors in to t wo o peratio ns: line ar ne gation , whic h is the purely neg ativ e part of negation; and the mo dality of course , which ha s the meaning of r eaffirmation”, is verified in dialectica l logic , since the loca l o pera tion of standa rd implicatio n (standard neg ation) of subtypes factors into the global o peratio n of tensor implication (tenso r negation) follow ed b y como noidal supp ort , the dialectical logic rendition of the “a ffirmation mo dality” of linear log ic. T erm hom-set completeness defines the no tion of top olo gy of subtyp es , thereby ma king further co n tact with the affirma tion mo dalit y . In such complete semantics, top ologized ma trices of terms are de fined and shown to b e (ca tegorically) equiv alent to sing le terms via the in verse op erations of “par titio ning ” and “summing”. With the intro duction of type sums a nontop ological matrix theory is develop ed, where ordinary matrices of terms are defined and s hown to b e (categ orically) equiv alent to terms with biproducts. In summary , with dia lectical progr am se ma n tics we hop e to unify s ma ll-scale and large-sca le progr am semantics by giving a concr ete foundation for the obser v ation that “pr econdition/p ostcondition asser tions are similar in struc tur e to relational database constraint s”. I am now exploring the clos e connection betw een the functional a spect of dialectical program sema n tics a nd Martin- L ¨ of t yp e theory giv en via lo cally cartesian closed categories [Seeley]. F urthermo r e, ther e is a strong connection b etw een dialectical program semantics and algebr aic and tempor al lo gic mo dels o f reg ulation in feedback control systems [W o nham]. 37 Con ten ts 1 Base Structures 2 1.1 T ens ors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Bip o sets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Adjoin t Pairs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Comonoids/Affir ma tion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Monoids/Co ns ideration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Dialectical Flo w. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Dialectical Systems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Spans. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Spannable Bip osets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.2 Sums . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Join Bisemila ttices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Type Sums. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Semiexact C a tegories. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Comonoid Nega tion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 2 Flow Structures 21 2.1 Assertio nal Ca tegories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Heyting Ca tegories. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Dialectical Ob ject Flow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Hoare T riples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 2.2 Flow Catego ries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Direct Flow Categor ies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Inv er s e Flow Categ ories. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Dialectical Flo w Categor ies. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Hyper doctr ines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 A Matrices 34 38 References [F reyd] P . F reyd, Asp ects of T op oi. Bull. Austr al. Ma th. So c. 7 (1972 ), 1-76. [Girard] J.Y. Girard, Linear Logic. Theor etical Computer Science 50 (1 987) 1-102 ; T echnical Rep ort (1986), Equip e de L ogique Mathematique, UER de Mathematiques, Univ ersite Paris VI I. [Gray] J. Gray , Fibred a nd Cofibr ed Categ ories. C o nference on Catego rical Algebr a (196 5). [Hoare] C.A.R. Hoare, An Axiomatic Basis for Computer Progra mming . Comm. ACM 12 (1967), 516- 580. [Hussey] E . Hussey , The Pr eSo cr atics (197 2), Scribner. [Hyland] J.M.E. Hyland, P .T. Johnstone and A.M. Pitts, T rip os Theory . Math. Pro c. Camb. Phil. So c. 88 (1980), 205-232 . [Kent87] R.E. Kent, Intro duction to Dialectical Nets. 25th Allerton Conference o n Communication, Con- trol and Co mputing, Monticello, Illino is (1987). [Kent88] R.E. Kent, The Logic of Dialectica l Pro cesses. 4th W orkshop on Mathematical F o unda tions o f Progr amming Seman tics, Bo ulder, Colo rado (1 9 88). [Kozen] D. K ozen and J. Tiury n, L ogics of P r ograms. T echn ical Rep o rt CS-8 7-172 Computer Science Dept., W as hington Sta te Universit y (1987). [Lawv ere69] F.W. Lawvere, Adjoin tness in F oundatio ns . Dialectica 23 (196 9 ), 281- 296. [Lawv ere89] F.W. La wvere, Qualitative Distinctions b et ween some T op oses of Generalize d Gr aphs. Co n tem- po rary Mathematics 92 (19 89), 261-2 99. [Manes] E. Ma nes, Assertiona l Categor ies. 3 rd W or kshop on Mathematical F oundations of Pro gramming Semantics, T ula ne University , New Orleans, Louisiana (198 7). Lecture Notes in Computer Sci- ence 298 , Spring er-V erlag , Berlin. [MM] J. Meseguer and U. Mo n tanari, Petri Nets ar e Mono ids. T echnical Rep ort SRI-CSL-8 8-3, SRI Int ernationa l (19 89). [Pratt] V.R. Pratt, Seman tical Consideratio ns on Floyd-Hoare Logic. Pr oc. 17th IEEE Symp. F ound. Comput. Sci. (19 76), 109- 1 21. [Seeley] R.A.G. Seeley , Lo cally Cartesian Clos ed Categ o ries and Type Theory . Math. Pro c. Camb. Phil. So c. 9 5 (19 84), 33 -48. [Segerburg ] K. Seg erburg, A Completeness Theorem in the Mo dal Logic of Progra ms. Not. Amer. Math. So c. 2 4 (19 77). [W onham] W.M. W onham, Lo g ic and La nguage in Co ntrol Theory . P le na ry lecture in Pro ceedings 2 5th Allerton Conference on Communication, Control, and Co mputing (19 87), 1-3. 39
Original Paper
Loading high-quality paper...
Comments & Academic Discussion
Loading comments...
Leave a Comment