Skip to content

About

LMPL: Language Model Pseudocode Language — a requirements language for LLM-mediated code translation

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

LMPL: Language Model Pseudocode Language

Structured pseudocode for LLM-mediated work.

LMPL describes computations, workflows, and translation targets at the level an LLM can reliably understand and act on. It can specify code to be generated, procedures for an LLM to perform directly, or contracts for tool-mediated work.

Source (SAS, R, SPSS, ...)
    -> lift: read source, write structured pseudocode
LMPL
    -> inspect, add contracts, flag semantic gaps
    -> lower: read LMPL, write target code
Target (Python, SQL, Kotlin, ...)

LMPL is consumed by a language model rather than a traditional runtime. The model may lower it to code, perform it through reasoning, execute it through tool calls, build helper artifacts, or use it as an inspection document.


Repository Map

This repo has one core thesis and several applications of that thesis. The directory layout keeps those concerns separate.

core/
    language-reference.md       The LMPL language definition
    grammar.ebnf                Formal grammar
    semantics.md                Formal semantics
    architecture.md             How core and extensions relate
    examples.md                 Core worked examples

extensions/
    profiles/                   Domain vocabularies layered on core LMPL
    translation-guides/         Standards and guides for language <-> LMPL translation

applications/
    sas-to-python/              Concrete application of LMPL as a SAS -> Python pivot
    agent-procedure/            Concrete application of LMPL as an LLM procedure

principles/
    lmpl/                       Positioning principles and testable theses

research/
    competitive-landscape.md
    competitive-landscape-response.md

Use core/ when you want to understand LMPL itself. Use extensions/ when you want to add vocabulary or translation knowledge without changing core. Use applications/ when you want to see the core thesis applied to a domain or translation path. Use principles/ when you want the rationale, boundaries, and empirical claims behind the design.


Why

Direct LLM translation from source to target clusters errors. The translator must simultaneously parse source semantics, understand target idioms, select libraries, and bridge abstraction gaps in one step.

LMPL breaks this into two smaller tasks. Lifting captures what the source code does as language-neutral structured pseudocode. Lowering expresses that pseudocode in the target's native patterns. The intermediate representation gives you a place to inspect business logic, add contracts, document semantic gaps, and verify intent before code is generated.

The same structured pseudocode is also useful when the LLM is not generating code at all. A skill, runbook, or agent workflow can use LMPL-style procedures to tell the model what to do: read files, verify preconditions, call tools, halt on failed gates, build temporary checkers, and report results.


Key Ideas

Contracts Are the Correctness Mechanism

When the implementation is probabilistic, contracts become the validation layer. require, ensure, invariant, and assert are not decoration; they catch translation errors.

require all values in patients.age are non-negative
ensure no_duplicates(result, key: patient_id)
invariant total_debits == total_credits for every journal entry

Contracts in LMPL become assertions in the generated code. They travel from model-consumable procedure to implementation.

Semantic Gaps Are First-Class

The hardest translation bugs are semantic: the code runs but computes the wrong answer because languages disagree on meaning. LMPL makes these visible.

@semantic_change:
    "SAS sorts missing values before all non-missing values.
     pandas sorts NaN after all non-NaN values by default.
     Use na_position='first' in sort_values()."

Natural Language Is a Feature

LMPL allows natural language inside structured pseudocode, for example filter(where: the customer has not been flagged for deletion). When the consumer is an LLM, this is a design feature rather than a parsing failure.

Missing vs. Null

LMPL distinguishes missing from null. missing means a value should exist but was not observed, as in SAS . or R NA. null means absence by design, as in SQL NULL or Python None. This distinction is a common source of subtle migration bugs.

Consumption Intent Is Explicit

LMPL separates what is described from how the LLM should consume it:

  • specify — inspect or review intended behavior
  • translate — generate a target artifact
  • perform.internal — resolve directly through model reasoning
  • perform.tool_call — act through available tools
  • perform.tool_build — build a helper artifact or tool before acting
  • perform.auto — choose the least powerful sufficient performance strategy
  • auto — choose the overall consumption mode from context

Extension Mechanisms

LMPL extends along two axes.

Translation Guides teach an LLM how to translate between a language and LMPL. Each Language Guide covers a language's relationship to LMPL in both directions. See extensions/translation-guides/standard.md.

Domain Profiles add domain-specific types, annotations, and semantic rules on top of core LMPL. Profiles add vocabulary; they do not replace the core language. See extensions/profiles/.


Start Here


Status

LMPL is a v0.3 specification. The language is defined. The core thesis, that structured pseudocode improves LLM-mediated translation and procedure execution, is plausible but empirically unvalidated.

What exists:

  • Complete language reference with formal grammar and semantics
  • Five domain profiles: agentic, financial, infrastructure, ML, security
  • Translation Guide standard
  • Competitive landscape analysis
  • SAS-to-Python worked application material
  • Agent procedure worked application material

What's next:

  1. Extract the SAS Language Guide from existing specification material.
  2. Build an orchestration skill or MCP server for lift, validate, and lower.
  3. Run empirical validation against direct translation and plain natural-language summaries.
  4. Add a second Language Guide to test the compositional translation model.

License

TBD

About

LMPL: Language Model Pseudocode Language — a requirements language for LLM-mediated code translation

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages