OSR v1 reference
API of OpenSymbolicRules.OSRv1, the consumer of the OSR v1 interchange format generated by OpenSymbolicRules/Lean.
OpenSymbolicRules.OSRv1 — Module
OSRv1Consumer 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.
OpenSymbolicRules.OSRv1.OMA — Type
OpenMath application of a symbol to arguments.
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.
OpenSymbolicRules.OSRv1.OMBIND — Type
OpenMath binding OMBIND(binder, variables, object) (OpenMath 2.0, 3.3.11).
OpenSymbolicRules.OSRv1.OMI — Type
OpenMath integer.
OpenSymbolicRules.OSRv1.OMS — Type
OpenMath symbol cd#name (CD base http://www.openmath.org/cd).
OpenSymbolicRules.OSRv1.OMV — Type
OpenMath variable.
OpenSymbolicRules.OSRv1.RewriteResult — Type
Result of rewrite.
OpenSymbolicRules.OSRv1.RewriteStep — Type
One applied rule.
OpenSymbolicRules.OSRv1.Rule — Type
An oriented rewrite rule.
OpenSymbolicRules.OSRv1.RuleSet — Type
A loaded rule set.
OpenSymbolicRules.OSRv1.Verification — Type
Lean verification record of a rule in one domain.
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.
OpenSymbolicRules.OSRv1.freevars — Method
Free variables of an expression (bound variables of OMBIND excluded).
OpenSymbolicRules.OSRv1.has_residual_integral — Method
Whether an expression contains a residual integral (V1-E-002b).
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.
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.
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.
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.
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.
OpenSymbolicRules.OSRv1.to_omjson — Method
to_omjson(expr)Encode an expression in the OpenMath 2.0 JSON encoding.
OpenSymbolicRules.OSRv1.verification — Method
verification(rule, domain)The verification record of rule for domain (:real, :complex or :boolean).