VIEW THIS AS

Auto mode follows the Route Engine until you choose a viewpoint.

YOU ARE HERE

ROUTE CHECK

CONNECTED TO

WHAT NEXT

Use the canonical route for this room, or HELP if you are unsure.

Vocabulary Coding and Engineering | Semantic Type Errors: When Correct Words Belong to the Wrong Category

Two university researchers compare a printed variable dictionary with a structured dataset on a laptop in a library data lab.

A system can process every word correctly and still produce a dangerous answer by treating the right-looking information as the wrong kind of thing. “Positive” can refer to a screening result, a confirmed diagnosis, or favourable feedback. “Approved” can refer to editorial review, a financial authorisation, or permission to publish. The numeral 40 might mean degrees Celsius, degrees Fahrenheit, kilometres, a score, or a count. In each example, a sentence or data field may look syntactically valid while its interpretation is incorrect. Vocabulary Coding and Engineering calls these semantic type errors: category mismatches that occur when information is used under assumptions it does not satisfy.

The concept borrows the discipline of type checking in computer programming, without pretending natural-language meaning can always be assigned one perfect formal type. The TypeScript Handbook explains how programming languages use types to constrain operations, while the W3C Shapes Constraint Language (SHACL) supports validating RDF data graphs against specified constraints. Those tools provide technical inspiration, not an automatic test for truth, intent, ethics or legality. This guide shows where typing can prevent category errors in AI answers, health information, public services, research, contracts and the international exchange of data, and where human interpretation must remain central.

  • Word zoom: A shared label does not prove two things belong to the same category.
  • Number zoom: Quantity, unit, population and measurement method must travel together.
  • Record zoom: A status such as “approved” needs a precisely named approval kind.
  • Software zoom: Type checks catch some invalid operations, not every mistaken fact.
  • AI zoom: The fluent use of a word can conceal a category mistake.
  • Institution zoom: Schema and terminology owners decide which classifications apply.
  • Society zoom: Small category errors can affect large groups when automated systems scale.

The first example: 40 is not a complete measurement

Suppose a fictional sensor sends the number 40 to an operations centre. One team assumes Celsius and issues a high-temperature warning. Another interprets Fahrenheit and reports a much cooler temperature. Neither team mistyped the number. The message lost its unit and the conditions of measurement. A system that accepts any number in a generic field has confused the numerical representation with the physical quantity.

A safer record stores 40 with the explicit unit, sensor identity, observation time, relevant calibration information and expected range. For some applications it should also include uncertainty. This is the first layer of semantic type safety: a value should not be used without the context needed to interpret it.

Zoom 1: what programming types actually do

A type can constrain which operations apply to a value. In TypeScript, a variable declared as a string is not automatically interchangeable with a number. Types can identify object properties and permitted shapes, helping developers detect some mismatches before software runs. The TypeScript Handbook’s introductory guide describes types such as string, number, Boolean, arrays and object types.

However, a generic number type does not inherently distinguish kilograms from pounds, nor is a correct type declaration evidence that the value came from an accurate sensor. A system can be free of syntax errors and still implement a defective policy. The analogy with language therefore needs additional semantic constraints and source verification.

Zoom 2: a field’s name is not a sufficient type

A database column called result may store a laboratory screening status, a school mark, a legal ruling or a software test outcome. The word is too broad to tell a downstream program what operations are valid. Even “positive” has different implications depending on whether a test measures an antibody, a product review or a clinical screening.

Vocabulary engineers can repair the interface by distinguishing screening_result, diagnostic_status and customer_sentiment, with each field linked to a defined source and interpretation. Such naming is not enough by itself; the type rules and actual workflow must match the stated meanings.

Zoom 3: the category mistake behind “positive means diagnosed”

A person may receive a positive result from a screening programme. A flawed summary converts that status into “the person is confirmed to have the disease.” The word positive is used correctly within the source’s screening domain but incorrectly promoted to a diagnostic conclusion. A screening test and a diagnosis are different kinds of result, with different evidentiary contexts.

A safer explanation preserves the test name, purpose, limitations and recommended next step from the responsible medical source. It should not infer a diagnosis from an isolated label. The practical type rule is to prevent a screening-status field from being substituted for a confirmed diagnosis without an authorised clinical process.

Zoom 4: “verified” is not a universal credential

A platform may mark an email address as verified after a link is clicked. Another service may call an identity verified only after checking government identification under a specific process. A third may use the word for a fact-checking status. If software combines these into verified=true without a method identifier, it can grant inappropriate confidence or access.

A robust record specifies verification subject, method, authority, date, evidence and expiration status. The important question is not “is it verified?” but “what exactly has been verified, by which procedure, for which use?” Types that express those distinctions can reduce silent substitutions.

Zoom 5: obligations and recommendations have different types

“The user may request review” states a permission. “The user must request review” imposes an obligation. “The user should request review” may be a recommendation in a technical context. A language model converting all three to “required action” changes what people think they owe or can choose.

The IETF RFC 2119 defines requirement keywords for documents that explicitly adopt its conventions. It does not settle every legal interpretation, but it demonstrates the value of distinguishing requirements from options. A typed handover can record modal force as a separate field rather than burying it inside a string.

Zoom 6: evidence, interpretation and authority should not share one type

  • Observation: A recorded event, measurement or source statement.
  • Inference: A conclusion drawn from evidence under identified assumptions.
  • Hypothesis: A proposed explanation requiring further testing.
  • Recommendation: Advice about a possible action, subject to context.
  • Authorisation: Permission issued by someone entitled to grant it.
  • Determination: A decision by the competent body under the relevant rule.
  • Historical record: An account of what was stated or decided at a past time.

A system may correctly store an inference that a parcel was delivered. It must not automatically treat that inference as a final adjudication of a customer dispute. A source statement can be valuable evidence yet not authorise the program to transfer funds. Semantic type safety protects these boundaries even when the same topic appears in all seven categories.

Zoom 7: a type error in legal and public reporting

A charge is not a conviction, a complaint is not a court finding, and a settlement is not always an admission of liability. These distinctions do not depend on the author choosing more polite words. They concern different procedural types. A headline calling an arrested suspect a convicted offender is not merely imprecise; it attributes a legal status the record may not support.

High-impact publishing can use explicit procedural fields: alleged, investigated, charged, tried, convicted, acquitted, appealed and status unknown. Each should be jurisdiction-specific and date-aware. A legal-status type should never be inferred solely from emotional wording or a photograph of an arrest.

Zoom 8: statistical types are equally important

A dataset describes “30% growth.” Does that mean an increase of 30% relative to the starting value, an increase of 30 percentage points, or a change in a count? A separate report uses “90th percentile” and another “90% correct.” These figures are not interchangeable even though they all contain percentages.

A numerical record needs a named measure, unit, denominator, population and period. A dashboard should not silently compare means with medians or rates with counts. A type check can flag incompatible units or missing fields, but domain experts still need to assess whether the underlying measurements are comparable.

Zoom 9: what SHACL checks in a knowledge graph

W3C SHACL provides a language for describing constraints that RDF graphs should satisfy. A shape can require certain properties, value types or cardinalities for a class of nodes. For example, a domain-specific graph might require that every recorded official decision refer to a governing source and a decision date. Structural validation can catch missing links before downstream analysis.

However, SHACL conformance does not mean that the cited law is correctly interpreted, the source is authentic or a decision is fair. The validation contract must make that limitation explicit. A syntactically conforming graph can contain false or outdated claims.

Zoom 10: concept identity versus entity identity

W3C SKOS can relate similar concepts across vocabularies, while OWL supports much stronger statements of identity between individuals. Two terms mapping to close concepts is not the same as two customer records representing the same person. Mixing these relationship types can cause a database to merge histories or incorrectly infer eligibility.

The W3C OWL 2 Primer illustrates how ontology languages represent classes, properties and individuals. The conceptual lesson is to name what relationship a link actually asserts: same individual, same class, close concept, broader category or uncertain possible match. A graph’s edge label carries consequential semantics.

Zoom 11: the risk of broad and narrow categories

One service defines “resident” as anyone ordinarily living in a district. Another uses resident for a particular statutory status. An AI that maps these words as exact equivalents may give someone the wrong benefit guidance. Even a technically valid record can be semantically wrong when the concept has moved between jurisdictions.

A safer system records the source domain and allows explicit broader, narrower or unresolved mappings. When the rules are legally consequential, the responsible authority rather than a generic translator must determine which definition applies. Interoperability should not be purchased by erasing differences.

Zoom 12: null is not false

A database lacks evidence that a customer’s address was verified. A Boolean field of false could mean the verification failed, has not been attempted or expired. These are different situations. Replacing them with one value may trigger an inappropriate denial or a misleading notice.

A better state model may include not assessed, pending evidence, assessed and verified, assessed and not verified, expired and disputed. More states increase complexity, but they can accurately represent procedural differences the single field concealed. As always, the categories require clear definitions and a correction route.

Zoom 13: time is part of the type

A document marked “approved” may have been approved under a different standard or for a specific time period. Treating the status as timeless can turn a past fact into an invalid present permission. The meaning-bearing type should include source version, effective interval and any conditions for renewal or expiry.

A temporal database can help reconstruct when a field was changed, while the real-world effective date may require separate data. A schema that records only the database update time cannot automatically establish when a law or policy was actually binding.

Zoom 14: type safety does not decide social values

Some classifications concern legitimate public disagreement: “reasonable accommodation”, “fair treatment”, “harm” or “intelligence”. A rule engine can apply the precise criteria chosen by an authorised institution. It cannot prove that those criteria are morally correct merely because it applies them consistently.

An ethical governance process should publish the source and scope, invite relevant review and allow people to challenge erroneous classifications under applicable rules. Semantic type checking is a tool for reducing mistakes, not a method for making contested social values disappear.

Zoom 15: interface boundaries are where type errors spread

One software team sends a value to another service. The first defines “complete” as data received; the second interprets it as data validated. When the two systems share a generic JSON property called complete, the discrepancy can remain hidden until money moves or records are closed.

The integration contract should specify states and provide included, excluded and boundary examples. The recipient should reject unknown values or require clarification rather than silently assume that the newest source field has the expected meaning. This mirrors defensive programming while preserving the fact that humans must authorise the shared definition.

Zoom 16: test invalid substitutions deliberately

A good semantic-type test suite includes values intentionally taken from the wrong category: a date where a duration is expected, a screening result offered as a diagnosis, an editorial approval used as payment authorisation, and a close concept match used as a same-person identity link. The system should reject or flag the substitution for review.

It also needs acceptable cases, so that the validator does not simply refuse every unusual expression. A well-explained synonym, a properly converted measurement or a reviewed translation may be safe. Testing should cover both false acceptance and false rejection.

Zoom 17: AI-generated explanations need a type ledger

A large language model may produce an answer with fluent grammatical confidence that obscures whether each claim is a source quotation, inference, suggestion or required action. A structured review can attach those types to the key propositions in the final message, with source links and limits where needed.

The NIST Generative AI Risk Management Profile identifies misleading and confidently inaccurate outputs as relevant risks. A semantic type ledger is one proposed method for catching unsupported promotion from source claim to fact, from possibility to certainty or from suggestion to authorisation. It cannot replace source verification and human review.

A semantic type-safety card

  • Concept: Exact term, source definition and domain.
  • Data type: The structural representation permitted by software.
  • Semantic type: Measurement, status, observation, inference, instruction or authority.
  • Unit and population: Relevant measure, group and time period.
  • Scope: Where and when this type is valid.
  • Valid operations: Which decisions can safely use the value.
  • Forbidden substitutions: Similar-looking categories that must not be exchanged.
  • Source evidence: How the value was obtained and checked.
  • Review state: Confirmed, uncertain, disputed or superseded.
  • Correction: Who may change the meaning or repair a wrong classification.

Seven questions to detect a semantic type error

  1. Does this term refer to a person, category, observation, opinion, approval or final decision?
  2. Are the value’s unit, denominator, measurement method and time defined?
  3. Does the source’s authority extend to this particular use?
  4. Was a broader, narrower or merely similar concept treated as identical?
  5. Was missing information silently converted into an explicit negative result?
  6. Did an AI promote tentative evidence into a diagnosis, law or binding instruction?
  7. Can the recipient test a counterexample and challenge a wrong classification?

Frequently asked questions

What is a semantic type error?

Here it means using information as though it belonged to a different meaning category, such as treating a screening result as a diagnosis or a draft approval as payment authorisation. It is an explanatory concept, not a single formal error class in every programming language.

Does TypeScript prevent every type error in real life?

No. It helps check the declared structure and operations of program values. Incorrect assumptions, runtime inputs, measurement units and domain meanings still require design and validation.

Would SHACL tell us whether an AI answer is true?

No. SHACL checks RDF graphs against declared constraints. It cannot guarantee that the source data are factual, that the right law was applied or that an outcome is fair.

Why are missing values dangerous?

Because “not checked”, “unknown”, “failed verification” and “not eligible” may need different actions. A single false Boolean can conceal these distinctions.

Conclusion: the right word must also be the right kind of thing

At the word zoom, “positive” or “approved” can represent several statuses. At the record zoom, an underspecified field can confuse them. At the software zoom, an automated rule can make the mistake repeatedly. At the civilisational zoom, a category error can shape rights, measurements and reputations. Vocabulary Coding and Engineering gains power by asking not only whether a phrase is fluent, but whether each claim has the correct semantic type, evidence, scope and authority. Strong typing cannot settle every human disagreement, but it can make many dangerous substitutions visible before they scale.

Sources and further reading

Editorial note: “Semantic type error” is used as an applied analogy across language and computing. It does not indicate that programming type systems can solve all legal, scientific or ethical categorisation questions. All examples are fictional and intended for educational illustration.