Skip to content

Commit 0a8f306

Browse files
committed
kitchenspeak: scaffold experimental DSL with class v1.0 spec
Adds kitchenspeak/ as an experimental teaching DSL for advanced type theory (linearity, session types, refinement, effect systems, postulated oracles) in the domestic-kitchen orchestration domain. Contents: - SPEC.adoc class's v1.0 specification, reproduced verbatim as the authoritative requirements artefact for the term. - grammar.ebnf class EBNF (Section A, verbatim) plus three additive patches (Section B): ceremony_decl body, dyadic <~> bind as a top-level step, mission-scoped resources. - COMMENTARY.adoc separate type-theoretic companion mapping each of the seven types onto standard foundations and naming each proof obligation. Does not overwrite class vocabulary. - examples/poached-egg.ks the minimum KitchenSpeak program that exercises Linear + Tropical + Echo together, heavily commented as a teaching artefact. - README.adoc directory orientation. - languages/kitchenspeak.md matching short-card in the house pattern. Status: CLASS PROJECT, specification-only at v1.0. Not part of the core ten-language portfolio. https://claude.ai/code/session_0118688cwQ4a7YZQVvaUewPd
1 parent df858ab commit 0a8f306

6 files changed

Lines changed: 913 additions & 0 deletions

File tree

kitchenspeak/COMMENTARY.adoc

Lines changed: 257 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,257 @@
1+
// SPDX-License-Identifier: PMPL-1.0-or-later
2+
// Copyright (c) 2026 Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
3+
= KitchenSpeak — Type-Theoretic Commentary
4+
:toc:
5+
:toclevels: 3
6+
:icons: font
7+
8+
[NOTE]
9+
====
10+
This is a *companion* to `SPEC.adoc`, not an edit of it. The class's
11+
specification is authoritative for the term. This document maps each of the
12+
class's seven types onto standard type-theoretic foundations, names the
13+
terminological overlaps with existing mathematical usage, and marks the
14+
load-bearing proof obligations the class will need to discharge.
15+
16+
It is written to support teaching — not to correct the spec.
17+
====
18+
19+
== How to read this document
20+
21+
For each of the seven types, we give four things:
22+
23+
. *What the class said* — the informal description from `SPEC.adoc`.
24+
. *Formal foundation* — the standard type-theoretic construct it lines up
25+
with.
26+
. *Proof obligation* — what the target proof assistant (Agda, in this
27+
curriculum) actually needs to discharge.
28+
. *Terminological note* — where the class's vocabulary overlaps with
29+
pre-existing mathematical usage, so nobody is ambushed later.
30+
31+
A final section treats the three production-mandatory syntactic constructs
32+
(`max_duration`, `on_fail`, `proving`) as what they structurally are:
33+
well-founded recursion witnesses, total case-splits on failure, and named
34+
existential witnesses.
35+
36+
== The seven types
37+
38+
=== Tropical ( `~` )
39+
40+
*What the class said.* Handles range and gradients (temperature, power).
41+
Prevents "binary overheat." Carries a `slope` and a `threshold`.
42+
43+
*Formal foundation.* A refinement type over a physical quantity with units,
44+
equipped with a rate-of-change bound. In mainstream terminology: *units of
45+
measure* (à la F#) plus a *bounded-derivative refinement*. The setpoint
46+
operator `~` is best read as "approach value `v` with slope at most `s`,"
47+
not as a propositional equality.
48+
49+
*Proof obligation.* Given a setpoint `~ v slope s`, the emitted control
50+
trajectory must remain inside a safe envelope: at no time `t` does the
51+
quantity exceed a forbidden threshold. In Agda, this is a refinement proof
52+
on a time-indexed stream, typically discharged by a termination-with-measure
53+
argument on a bounded integrator.
54+
55+
*Terminological note.* "Tropical" already names a real field of mathematics:
56+
the *tropical semiring* (min, +) and *tropical geometry*. The class's usage
57+
is metaphorical — tropical climate, ramping temperature — and has nothing
58+
to do with min-plus algebra. Worth saying once in class so nobody gets
59+
ambushed when they meet the other tropical.
60+
61+
=== Linear ( `<-` )
62+
63+
*What the class said.* Handles resource consumption. Prevents ingredient
64+
duplication or hallucination. Tracks state via "consumption arrows."
65+
66+
*Formal foundation.* *Girard's linear logic*, specifically the multiplicative
67+
fragment. Each linear resource inhabits a type that must be used exactly
68+
once. Operationally: a linear variable is consumed on use. The state
69+
transitions `Egg[State:Raw] -> Egg[State:Cracked]` are a typestate
70+
refinement on top of linearity.
71+
72+
*Proof obligation.* For every program point, the linear context contains
73+
exactly the resources not yet consumed. A resource used twice is a type
74+
error; a resource left unused at the end of `orchestrate` is a leak. Agda's
75+
standard way of expressing this is a linear monad or a quantitative type
76+
theory encoding.
77+
78+
*Terminological note.* The class writes the formal domain as "Affordance."
79+
That is *Donald Norman's HCI term* for what an object invites the user to
80+
do, not linear logic's formal content. The poetic bridge — an egg *affords*
81+
being cracked — is lovely, but keep the linear-logic sense in mind for the
82+
proofs.
83+
84+
=== Choreographic ( `sync` )
85+
86+
*What the class said.* Handles concurrency and sequencing. Orchestrates
87+
multiple Chef Actors (Oven, Hob, Robot) without deadlocks.
88+
89+
*Formal foundation.* *Session types* / *choreographic programming* (Honda,
90+
Yoshida, Carbone; Montesi). A `sync(A, B)` block is a multiparty session
91+
barrier: the global choreography specifies what each actor does, and the
92+
local projections are what each hardware persona actually executes. The
93+
optional `proving @witness_id` clause names the *barrier-release witness*.
94+
95+
*Proof obligation.* Deadlock-freedom and progress. In the session-typed
96+
setting: every actor's local projection is compatible with the global
97+
choreography, and the projection is well-typed.
98+
99+
*Terminological note.* None significant. The class's "Process Calculus"
100+
entry in the type table is correct territory.
101+
102+
=== Echo ( `@` )
103+
104+
*What the class said.* Handles sensor feedback — the witness. Acoustic,
105+
visual, thermal sensor streams that confirm the physical world matches the
106+
instruction.
107+
108+
*Formal foundation.* A *postulated oracle* that inhabits a proposition
109+
about the physical world. `@acoustic_signature == "rolling_boil"` is not
110+
derivable inside the proof system; it is a hypothesis supplied by a sensor
111+
pipeline. Formally, each echo-type comes with a *soundness postulate* that
112+
says "if the classifier emits `rolling_boil`, the pot is in fact at a
113+
rolling boil." Agda represents this as a `postulate`, Coq as an `Axiom`.
114+
115+
*Proof obligation.* The proof *assumes* the classifier is sound and
116+
discharges the surrounding control flow. The classifier itself is
117+
*unverified* — an honest teaching moment about the boundary between proven
118+
and postulated. Separate, higher-assurance work (out of scope for
119+
KitchenSpeak v1.0) would replace each echo-postulate with a verified
120+
classifier or an empirical soundness bound.
121+
122+
*Terminological note.* The class's "Witness / Predicate" entry is right.
123+
Emphasise the *postulated* nature in class.
124+
125+
=== Dyadic ( `<~>` )
126+
127+
*What the class said.* Handles explicit binding. Locks two resources into a
128+
single logical unit (e.g. Flour + Water become Dough).
129+
130+
*Formal foundation.* *Tensor product* in a linear / monoidal type theory:
131+
`Flour ⊗ Water` is a new linear resource that the binding actor consumes to
132+
produce `Dough`. In linear-logic notation:
133+
134+
Flour ⊗ Water ⊢ Baridi_Robot : Dough
135+
136+
where the two inputs on the left are consumed and the single output on the
137+
right is emitted. Dyadic binding is therefore an ordinary rule in linear
138+
logic, not a new formalism.
139+
140+
*Proof obligation.* The tensor's two factors are both consumed (linearity),
141+
and the Dough resource now carries the union of their relevant typestate
142+
metadata (provenance).
143+
144+
*Terminological note.* The class writes the formal domain as "Binary
145+
Relation." In standard usage, a binary relation is a subset of A×B — a
146+
*predicate*, not a *constructor*. Tensor product is closer to a
147+
*constructor*: given `a : A` and `b : B`, it builds a new value `a ⊗ b :
148+
A ⊗ B`. The distinction is a clean teaching moment: relations observe,
149+
constructors build.
150+
151+
=== Ceremonial ( `ceremony` )
152+
153+
*What the class said.* Handles social context and pacing. Overrides
154+
hardware aggression based on occasion. Declared at the `orchestrate` block
155+
level.
156+
157+
*Formal foundation.* An *ambient effect context* — most naturally encoded
158+
as a *reader monad* over the choreography, or as a *row of effect labels*
159+
in an algebraic-effects system. A ceremony *does not* change the linear
160+
resource count; it changes the *pace*, *alert level*, and *priority* with
161+
which the underlying choreography executes.
162+
163+
*Proof obligation.* Ceremonies must be *separated* from linearity: they are
164+
permitted to tighten termination bounds and re-prioritise, but not to
165+
duplicate or discard linear resources. In effect-system terms, ceremony
166+
effects commute with linear-resource effects.
167+
168+
*Terminological note.* "Contextual Logic" in the class's table is a fair
169+
informal gloss on reader / ambient-effect.
170+
171+
=== Primitive
172+
173+
*What the class said.* Raw SI units that talk to the hardware APIs. Mass
174+
(g), Temp (°C), Torque (Nm), Viscosity (Pa·s), Time (s).
175+
176+
*Formal foundation.* *Units of measure* as in F# / Fortress / Frink — a
177+
phantom type per physical dimension, with multiplicative combinators. An
178+
expression of type `°C` cannot be compared for equality with an expression
179+
of type `s`.
180+
181+
*Proof obligation.* All arithmetic on primitives preserves dimension. The
182+
Agda encoding is straightforward with indexed types; the subtlety is
183+
choosing a numeric carrier — rationals (with units) are usually enough and
184+
avoid the constructive-reals rabbit hole.
185+
186+
*Terminological note.* "Primitive type" in everyday PL usage means `int`,
187+
`bool`, etc. Here it means something closer to "dimension-indexed physical
188+
quantity." Not wrong — worth naming.
189+
190+
== The three production-mandatory constructs
191+
192+
=== `max_duration` — termination witness
193+
194+
Every `step` carries a `max_duration`. Structurally this is a *well-founded
195+
measure* on the implicit `until`-loop: the controller cannot run forever,
196+
because wall-clock time is a decreasing measure under a fixed bound. In
197+
Agda, this is the standard argument that makes `until` total.
198+
199+
=== `on_fail { ABORT | RECOVER | WARM }` — total failure handler
200+
201+
Every `step` specifies an `on_fail` behaviour. Structurally this is a
202+
*total case-split* on the failure branch: no step can get *stuck*, because
203+
every failure branch is inhabited by a named recovery mode. This makes the
204+
`sync_block` a total function into `{success} ⊎ {aborted, recovered,
205+
warmed}`.
206+
207+
=== `proving @witness_id` — named existential witness
208+
209+
The optional `proving` clause on a `sync_block` names the echo-postulate
210+
that certifies block completion. Structurally this is an *existential
211+
witness binder*: the block is total iff there exists a sensor event
212+
satisfying `@witness_id` within the block's `max_duration`. The postulate
213+
supplies the witness; the grammar makes its name explicit.
214+
215+
== Why each type earns its keep in the curriculum
216+
217+
A single sentence per type, for use in class:
218+
219+
* *Tropical.* You can feel the difference between a refinement type and a
220+
raw numeric when you watch a chocolate tempering curve go wrong.
221+
* *Linear.* You cannot uncrack an egg.
222+
* *Choreographic.* The oven and the hob have to coordinate or the eggs
223+
scramble before the bacon crisps.
224+
* *Echo.* The proof that cooking is happening is that the pot is making
225+
the right noise.
226+
* *Dyadic.* Once flour and water have met, neither exists any more; dough
227+
does.
228+
* *Ceremonial.* Sunday lunch is paced differently from combat rations, and
229+
both are valid modes of the same choreography.
230+
* *Primitive.* 180 is not a temperature until you know what unit it's in.
231+
232+
== Deliberately out of scope for v1.0
233+
234+
* A formal lexer specification (`actors`, `action`, `params`, `metric`,
235+
`comparison`, `value`, `time`, `error_handle` are placeholder
236+
nonterminals).
237+
* A verified classifier story for echo-types. v1.0 treats every `@witness`
238+
as postulated.
239+
* Nested `sync_block` / `bind_step` inside a `sync_block`.
240+
* A committed choice between Agda and Coq as the proof target. `SPEC.adoc`
241+
§4 names both ("Cook (Gallina)") but §6 uses Agda-specific terminology
242+
("Yellow unproven goals"). This document uses Agda throughout for
243+
pedagogical tractability; the decision can be revisited.
244+
* A committed wire protocol. `SPEC.adoc` §5 names HomeConnect, SmartThings,
245+
and Tuya; Matter and MQTT are candidates for a later HAL revision.
246+
247+
== Recommended reading for the class
248+
249+
* Philip Wadler, _Linear Types can Change the World_ (1990) — the
250+
original motivation for linear logic in programming.
251+
* Kohei Honda, Nobuko Yoshida, Marco Carbone, _Multiparty Asynchronous
252+
Session Types_ (POPL 2008) — the choreographic type-theory baseline.
253+
* Conor McBride, _I Got Plenty o' Nuttin'_ — quantitative type theory, a
254+
modern treatment of linearity that generalises cleanly.
255+
* Andrej Bauer, _What is algebraic about algebraic effects and handlers?_
256+
— effect systems without category theory prerequisites, for the
257+
ceremonial chapter.

kitchenspeak/README.adoc

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
// SPDX-License-Identifier: PMPL-1.0-or-later
2+
// Copyright (c) 2026 Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
3+
= KitchenSpeak
4+
:toc:
5+
:icons: font
6+
7+
A formally-verified, hardware-agnostic orchestration DSL for the domestic
8+
kitchen. Translates culinary expert intent (Chef Personas) into
9+
machine-executable actions for MQTT/Matter-class appliances, while
10+
maintaining physical and digital safety through a multi-layered type
11+
system.
12+
13+
*Status:* CLASS PROJECT. Specification stable at v1.0; grammar and worked
14+
examples are in active development. Not intended for deployment on actual
15+
kitchen hardware. Experimental companion to the other languages in this
16+
repository.
17+
18+
== Origin
19+
20+
KitchenSpeak is an experimental DSL designed as a teaching vehicle for
21+
advanced type theory (linearity, session types, refinement types, effect
22+
systems, dependent types) in an applied, tangible domain. The v1.0
23+
specification was written by the student cohort themselves as a
24+
requirements-engineering exercise under a second instructor, and offered
25+
to the type-theory stream as the target language for the term's proof
26+
work.
27+
28+
== What's in this directory
29+
30+
[cols="1,3"]
31+
|===
32+
| File | What it is
33+
34+
| `SPEC.adoc`
35+
| The class's v1.0 specification, reproduced verbatim. Authoritative
36+
requirements artefact for the term.
37+
38+
| `grammar.ebnf`
39+
| The class's grammar (Section A) plus three minimal additive patches
40+
(Section B) closing productions that the class referenced but did not
41+
define, and constructs illustrated in worked examples that had no
42+
production at all. Every patch is marked; nothing rewrites the class's
43+
work.
44+
45+
| `COMMENTARY.adoc`
46+
| Type-theoretic companion. Maps each of the class's seven types onto
47+
standard foundations (linear logic, session types, refinement types,
48+
effect systems, units of measure, postulated oracles) and names each
49+
load-bearing proof obligation. Separate from `SPEC.adoc` by design — the
50+
class's vocabulary is not overwritten.
51+
52+
| `examples/poached-egg.ks`
53+
| Worked example. The minimum KitchenSpeak program that exercises all
54+
three of Linear (the egg), Tropical (the water temperature), and Echo
55+
(the visual witness). Heavily commented as a teaching artefact.
56+
|===
57+
58+
== The seven types
59+
60+
From `SPEC.adoc` §2, with formal foundations elaborated in `COMMENTARY.adoc`:
61+
62+
* *Tropical* (`~`) — range and gradient. Refinement type over a quantity
63+
with a bounded derivative.
64+
* *Linear* (`<-`) — resource consumption. Linear logic; an egg cannot be
65+
used twice.
66+
* *Choreographic* (`sync`) — concurrency and sequencing. Session-typed
67+
multiparty barriers.
68+
* *Echo* (`@`) — sensor feedback. Postulated oracle that witnesses the
69+
physical world.
70+
* *Dyadic* (`<~>`) — irreversible binding. Tensor product in linear
71+
logic; flour and water become dough.
72+
* *Ceremonial* (`ceremony`) — social context. Ambient effect /
73+
reader-monad-style pacing and priority.
74+
* *Primitive* — SI-unit-indexed physical quantities.
75+
76+
== The three production-mandatory constructs
77+
78+
Every `step` in a KitchenSpeak program carries:
79+
80+
* `max_duration` — a wall-clock timeout. Termination witness.
81+
* `on_fail` — one of `ABORT`, `RECOVER`, `WARM`. Total failure handler.
82+
* `proving` (on the enclosing `sync`) — names the echo witness that
83+
certifies block completion. Existential witness binder.
84+
85+
Together these make every `sync_block` a total function into
86+
`{success} ⊎ {aborted, recovered, warmed}`, with termination discharged
87+
by a well-founded measure on the timeout.
88+
89+
== Mission invariants (SPEC.adoc §6)
90+
91+
* *Zero Scams* — all echoes resolve against local sensors; no cloud
92+
round-trips for safety-critical witnesses.
93+
* *Chef Orchestration* — multi-actor `sync` across heterogeneous hardware.
94+
* *Agda-Proven* — zero unresolved goals in the core proof library for
95+
the canonical recipes (Dough, Emulsion, Sear).
96+
97+
== Quick tour
98+
99+
Read in this order for a 20-minute orientation:
100+
101+
. `SPEC.adoc` §1–§3 — what the class built and why.
102+
. `examples/poached-egg.ks` — the smallest program that exercises
103+
Linear + Tropical + Echo together.
104+
. `grammar.ebnf` — Sections A then B.
105+
. `COMMENTARY.adoc` §The seven types — formal foundations, one per type.
106+
107+
== Deliberately out of scope for v1.0
108+
109+
* A lexer specification (the placeholder nonterminals in `grammar.ebnf` §O3
110+
are deferred to a later revision).
111+
* A verified classifier story for echo-types — v1.0 treats them as
112+
postulated.
113+
* A committed choice between Agda and Coq. `SPEC.adoc` §4 names both;
114+
`COMMENTARY.adoc` uses Agda throughout for pedagogical tractability.
115+
* A committed wire protocol. `SPEC.adoc` §5 names HomeConnect, SmartThings,
116+
Tuya; Matter and MQTT are candidates for a later HAL revision.
117+
118+
== Relationship to other languages in this repository
119+
120+
KitchenSpeak is *experimental* and not part of the core ten-language
121+
portfolio described in `EXPLAINME.adoc`. It shares design DNA with
122+
several siblings:
123+
124+
* Linear semantics are related to `affinescript/` and `ephapax/`.
125+
* Session-typed choreography overlaps with `anvomidav/`'s real-time
126+
model.
127+
* Effect / ceremony separation echoes `eclexia/`'s constraint-propagation
128+
approach.
129+
* Resource-counting discipline is cousin to `contractiles/`.
130+
131+
None of these dependencies are hard — KitchenSpeak is a self-contained
132+
teaching DSL.

0 commit comments

Comments
 (0)