Type Checking Program Code using SHACL (Extended Version)
Pith reviewed 2026-05-25 11:23 UTC · model grok-4.3
The pith
Deriving SHACL shapes from queries lets a lambda calculus type-check RDF code and prove it avoids runtime errors.
A machine-rendered reading of the paper's core claim, the machinery that carries it, and where it could break.
Core claim
TyCuS derives SHACL shapes from queries and integrates data shapes and query shapes as types into a lambda-calculus. The system supplies formal rules for this integration together with a proof of type safety. A programmer can therefore process RDF data with simplified, type-checked code that will not encounter run-time errors on valid graphs, except for the cases type checking cannot prevent such as accessing empty lists.
What carries the argument
TyCuS, the type system that extracts SHACL shapes from queries, merges them with data shapes, and uses the result as types inside a lambda calculus to guarantee safety.
If this is right
- Programmers can omit explicit checks for missing or multi-valued attributes whenever the shapes guarantee their presence and cardinality.
- Type safety is preserved under the actual semantics of query evaluation on RDF graphs.
- The same code works without modification on any graph that satisfies the combined shapes.
- The only remaining runtime exceptions are those that shapes cannot rule out, such as empty-list accesses.
Where Pith is reading between the lines
- The derivation of shapes from queries could be applied to other constraint languages that operate on graph data.
- Embedding the same mechanism inside existing languages that process RDF might allow static checking of real query code.
- Separating constraints from processing logic may reduce the amount of defensive code needed when data schemas evolve.
Load-bearing premise
Shapes derived from queries can be soundly combined with data shapes to form a type system whose safety proof holds for actual RDF graphs and query evaluation semantics.
What would settle it
A concrete program, query-derived shape, data shape, and valid RDF graph where the program passes the type checker yet still produces a runtime error during query evaluation.
Figures
read the original abstract
It is a strength of graph-based data formats, like RDF, that they are very flexible with representing data. To avoid run-time errors, program code that processes highly-flexible data representations exhibits the difficulty that it must always include the most general case, in which attributes might be set-valued or possibly not available. The Shapes Constraint Language (SHACL) has been devised to enforce constraints on otherwise random data structures. We present our approach, Type checking using SHACL (TyCuS), for type checking code that queries RDF data graphs validated by a SHACL shape graph. To this end, we derive SHACL shapes from queries and integrate data shapes and query shapes as types into a $\lambda$-calculus. We provide the formal underpinnings and a proof of type safety for TyCuS. A programmer can use our method in order to process RDF data with simplified, type checked code that will not encounter run-time errors (with usual exceptions as type checking cannot prevent accessing empty lists).
Editorial analysis
A structured set of objections, weighed in public.
Referee Report
Summary. The paper introduces TyCuS for type-checking code that queries RDF graphs validated by SHACL shapes. It derives SHACL shapes from queries, integrates these with data shapes as types into a λ-calculus, and claims to provide formal underpinnings together with a proof of type safety. The goal is to allow simplified code that avoids runtime errors when processing flexible RDF data (except for cases such as empty lists).
Significance. If the type-safety proof is valid and the query-shape derivation is shown to preserve the semantics of actual RDF graph matching and SPARQL evaluation, the work would supply a useful formal bridge between SHACL validation and typed programming languages. The explicit construction of a typed λ-calculus and the stated proof are strengths that could support safer RDF processing.
major comments (1)
- [section on integration into lambda calculus] Section on integration into lambda calculus: the type-safety proof is presented for the abstract TyCuS λ-calculus, yet no separate soundness lemma is described that relates query-derived shapes back to the operational semantics of SPARQL query evaluation on concrete RDF graphs; without this link the safety guarantee does not transfer to the intended practical use case.
minor comments (1)
- [Abstract] Abstract: the parenthetical remark on 'usual exceptions' for empty lists could be expanded to clarify the precise boundary of the safety guarantee.
Simulated Author's Rebuttal
We thank the referee for the careful reading and the identification of this gap. We address the single major comment below.
read point-by-point responses
-
Referee: Section on integration into lambda calculus: the type-safety proof is presented for the abstract TyCuS λ-calculus, yet no separate soundness lemma is described that relates query-derived shapes back to the operational semantics of SPARQL query evaluation on concrete RDF graphs; without this link the safety guarantee does not transfer to the intended practical use case.
Authors: We agree that the current presentation does not contain an explicit soundness lemma relating the query-derived shapes to the operational semantics of SPARQL. The derivation of shapes from queries is defined so that satisfaction of the derived shape corresponds to the query result, but we have not stated and proved the required preservation property with respect to concrete SPARQL evaluation. In the revised manuscript we will add a soundness lemma (in the section on integration into the λ-calculus) that establishes: if a SPARQL query Q evaluated on a graph G yields a result that satisfies the shape derived from Q, then the corresponding TyCuS type is preserved under the operational semantics of the calculus. This will make the transfer of the type-safety guarantee explicit. revision: yes
Circularity Check
Independent formal type-safety construction; no reductions to inputs by definition
full rationale
The paper defines a lambda-calculus embedding of SHACL shapes (both data shapes and query-derived shapes) and proves type safety inside that calculus. No equations equate a derived quantity to a fitted parameter, no self-citation supplies a uniqueness theorem that forces the central result, and no ansatz is smuggled via prior work. The construction is self-contained as a syntactic type system whose safety proof is internal to the presented calculus; any gap between the abstract model and concrete RDF/SPARQL semantics is a soundness question, not a circularity.
Axiom & Free-Parameter Ledger
axioms (1)
- standard math Standard type safety properties of the simply-typed lambda calculus hold when extended with SHACL-derived types.
Reference graph
Works this paper leans on
-
[1]
(eds.): The Description Logic Handbook : Theory, Implementation, and Ap- plications
Baader, F., et al. (eds.): The Description Logic Handbook : Theory, Implementation, and Ap- plications. Cambridge University Press (2003)
work page 2003
- [2]
- [3]
- [4]
- [5]
- [6]
-
[7]
pp. 74–83. ACM (2004) 24 Martin Leinberger, Philipp Seifer, Claudia Schon, Ralf L ämmel, Steffen Staab
work page 2004
-
[8]
Ciobanu, G., et al.: Minimal type inference for Linked Dat a consumers. J. Log. Algebr. Meth. Program. 84(4), 485–504 (2015)
work page 2015
- [9]
-
[10]
Science of Computer Pro- gramming 89, Part A, 2 – 22 (2014)
Horne, R., et al.: A verified algebra for read-write Linked Data. Science of Computer Pro- gramming 89, Part A, 2 – 22 (2014)
work page 2014
-
[11]
Semantic Web 2(1), 11–21 (2011)
Horridge, M., et al.: The OWL API: A Java API for OWL ontolog ies. Semantic Web 2(1), 11–21 (2011)
work page 2011
-
[12]
ACM Transactions on Programming Languages and Systems 23(3), 396–450 (May 2001)
Igarashi, A., et al.: Featherweight Java: A Minimal Core Calculus for Java and GJ. ACM Transactions on Programming Languages and Systems 23(3), 396–450 (May 2001)
work page 2001
- [13]
- [14]
-
[15]
W3C Recommendation (2017), https://www.w3.org/TR/shacl/
Knublauch, H., et al.: Shapes Constraint Language (SHAC L). W3C Recommendation (2017), https://www.w3.org/TR/shacl/
work page 2017
- [16]
- [17]
- [18]
- [19]
- [20]
-
[21]
Pierce, B.C.: Types and Programming Languages. The MIT P ress (2002)
work page 2002
-
[22]
Prud’hommeaux, E., et al.: SPARQL Query Language for RDF . W3C Rec. (Nov 2013), https://www.w3.org/TR/rdf-sparql-query/
work page 2013
- [23]
-
[24]
Programming Journal 3(3), 13 (2019)
Seifer, P ., et al.: Semantic Query Integration With Reas on. Programming Journal 3(3), 13 (2019)
work page 2019
-
[25]
Tao, J., et al.: Integrity Constraints in OWL. In: Proc. A AAI 2010. AAAI Press (2010) Type Checking Program Code using SHACL (Extended V ersion) 2 5 S∪ SP , Γ ⊢ t1 : T1, S 1 S, Γ ⊢ SP , t 1 : T1, S 1 (T-PROGRAM) S, Γ ⊢ t1 : T1, S 1 S∪ S1, (Γ, x : T1)⊢ t2 : T2, S 2 S, Γ ⊢ let x = t1 in t2 : T2, S 1∪ S2 (T-LET) S, Γ ⊢ t1 : T1→ T1, S 1 S, Γ ⊢ fix t1 : T1, S ...
work page 2010
discussion (0)
Sign in with ORCID, Apple, or X to comment. Anyone can read and Pith papers without signing in.