OSR v1 reference

API of OpenSymbolicRules.OSRv1, the consumer of the OSR v1 interchange format generated by OpenSymbolicRules/Lean.

OpenSymbolicRules.OSRv1 — Module
OSRv1

Consumer of the OSR v1 interchange format produced by the Lean-native OSR core (OpenSymbolicRules/Lean). Expressions are OpenMath objects in the OpenMath 2.0 JSON encoding, restricted to symbols (OMS), variables (OMV), integers (OMI) and applications of a symbol (OMA).

This module is deliberately independent of the SymbolicUtils pipeline: it loads rules, exposes their OpenMath symbols, domains, provenance and Lean verification metadata, and applies them with a plain syntactic matcher.

A rule's Lean certificate covers the mathematical statement only. The matcher, the substitution and the rewrite strategy implemented here are not verified; their behaviour is tested separately.

source
OpenSymbolicRules.OSRv1.OMApply — Type

Residual integral int(λx. H)(x) or int(λx. H)(g) (V1-E-002b): an application whose applicant is calculus1#int applied to a lambda, the form of the calculus1#int FMP, at the bound variable or at an expression g of it (v0.1 Subst). It only occurs in the replacements of antiderivative rules.

source
OpenSymbolicRules.OSRv1.decide_condition — Method
decide_condition(condition)

Decide a condition whose operands are closed rational expressions: true or false, or nothing when it cannot be decided (a variable, a symbol outside integer arithmetic, a division by zero). This mirrors the Lean OSR.Cond.decide?, proved sound in OpenSymbolicRules/Lean.

source
OpenSymbolicRules.OSRv1.load_ruleset — Method
load_ruleset(path)

Load an OSR v1 rule set. Every symbol used by a rule must be declared in the rule set's symbol table, and profiles may only reference existing rules.

source
OpenSymbolicRules.OSRv1.match_pattern — Method
match_pattern(pattern, expr, variables) -> Union{Nothing,Dict{String,OMExpr}}

Syntactic first-order matching. An OMV whose name is in variables is a pattern variable; repeated occurrences must match equal subterms. No associativity or commutativity is assumed.

source
OpenSymbolicRules.OSRv1.parse_omjson — Method
parse_omjson(json)

Parse an OpenMath JSON object of the OSR fragment: symbols, variables, integers, applications of a symbol, bindings by a symbol, and residual integrals int(λx. H)(x) (OMApply). Anything else (floats, strings, attributions, other non-symbol applicants, non-symbol binders) is rejected.

source
OpenSymbolicRules.OSRv1.rewrite — Method
rewrite(expr, ruleset; profile, domain, certified_only=true, max_steps=100)

Rewrite expr with the rules of profile, valid in domain. The strategy is outermost-first, leftmost, trying rules in profile order, repeated until no rule applies or max_steps is reached. exhausted is true when the budget is spent and a rule still applies. This is the strategy of the Lean reference rewriter OSR.normalize; the Conformance cases check the two agree.

Each rule is sound where its pattern is defined (applicability = defined_pattern): the result agrees with the input wherever the input is defined, and may be defined at more points. With certified_only, only rules certified in domain are used. A rule whose status in domain is counterexample is never used, even with certified_only=false: Lean proves it false there. Nor is a rule whose replacement contains residual integrals (V1-R-005c). A conditional calculus rule (derivative, limit, antiderivative) is applied only when every condition, with the match substituted, is decided true by exact rational arithmetic (decide_condition, V1-R-005d); other conditional rules are not applied.

source
OpenSymbolicRules.OSRv1.substitute — Method
substitute(expr, bindings)

Replace every variable bound in bindings. In a rule replacement, matched subterms only occur under the binders they were matched under (with the input's bound variable names), so substitution cannot capture variables; the Lean statement of such rules (OSR.Logic.BRule.Holds) proves this.

source