Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,20 @@ All notable changes to OntoLogic are recorded here. The format follows
Entries before 1.5.1 were back-filled from git history. v1.4.0 and v1.5.0 were
tagged after the fact, on their version-bump commits.

## [1.8.2] - Unreleased
## [1.8.3] - 2026-11-11

Fixes to the v1.8.1 solver resource controls, plus emitter, REPL and prover fixes.
Emitter, REPL and prover fixes found while writing the user guide, and a warning for answers
reached without arithmetic.

### Added
- **Warning when a prover without arithmetic gives an all-clear.** The native prover and
Vampire read `gt`, `gte`, `lt` and `lte` without arithmetic, so their SAT can miss a conflict
that needs it (an integer gap such as `gt 5` with `lt 6`). When the ontology uses those
comparisons and one of them reports SAT or every concept satisfiable, `--solve` prints a
warning on stderr. The REPL adds the same line to `:solve`, `:model`, `:explain`, `:unsat`
and a refuted `:prove`, and the language server adds it to the `ontologic.solve` result.
`auto` warns only when it falls back to the native prover. Z3 and CVC5 answers, and every
UNSAT, are unchanged.

### Fixed
- **Repeated bounds in generated Python and Java.** A subclass that restated an inherited
Expand All @@ -28,6 +39,12 @@ Fixes to the v1.8.1 solver resource controls, plus emitter, REPL and prover fixe
Z3 or CVC5.
- **VS Code snippets expanded to obsolete syntax.** They now use the current grammar, and the
extension README and `build_extension.sh` report the real package version.

## [1.8.2] - 2026-11-08

Fixes to the v1.8.1 solver resource controls.

### Fixed
- **`--solve-timeout` was ignored by CVC5.** `--tlimit` was passed after the `-` stdin
marker, where cvc5 ignores options. It now comes before `-`.
- **Timeouts behave the same on every backend.** External solvers now also run under a
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/axioms-and-reasoning.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ A model is one possible world, usually a tiny one. Concepts that are empty in th
| `native` | Built into the binary (tableau and resolution). No install needed; honours `-T`; reports unknown on step or clause limits |
| `auto` | Tries `z3`, `cvc5`, `vampire` in order, skipping any that is not installed; if none is installed, falls back to `native`. A solver that is installed but fails is reported, not skipped |

Practical guidance: use `z3` or `cvc5` for ontologies with numeric property bounds. `native` and `vampire` have no arithmetic. OntoLogic gives them one background axiom for each pair of numeric bounds in the file that no number can meet together (such as `gte 100` and `lt 50`), so they catch contradictions like the balance example above. They still miss contradictions that need real arithmetic, such as integer gaps (`gt 5` and `lt 6` on an `Integer`) or bounds derived from sums. The domain fixtures in `test/fixtures/domains/` are checked with Z3 (then CVC5) for this reason. For purely taxonomic and relational reasoning, all backends agree. If two provers disagree, trust UNSAT from an SMT solver and treat the other's SAT as incomplete.
Practical guidance: use `z3` or `cvc5` for ontologies with numeric property bounds. `native` and `vampire` have no arithmetic. OntoLogic gives them one background axiom for each pair of numeric bounds in the file that no number can meet together (such as `gte 100` and `lt 50`), so they catch contradictions like the balance example above. They still miss contradictions that need real arithmetic, such as integer gaps (`gt 5` and `lt 6` on an `Integer`) or bounds derived from sums. When one of them gives an all-clear on an ontology that uses `gt`, `gte`, `lt` or `lte`, OntoLogic prints a warning that the answer was reached without arithmetic and should be confirmed with `z3` or `cvc5`. The domain fixtures in `test/fixtures/domains/` are checked with Z3 (then CVC5) for this reason. For purely taxonomic and relational reasoning, all backends agree. If two provers disagree, trust UNSAT from an SMT solver and treat the other's SAT as incomplete.

## Time and memory limits

Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/editor-and-lsp.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Capabilities reported by `initialize`:
| Formatting | Re-indents the whole document (honours the editor's tab size) |
| Semantic tokens | Keyword, type, class, property, function, variable, string, number, comment, operator |
| Code actions | Quick-fix entries "Verify SMT Consistency", "Explain SMT Unsatisfiable Core", "Inspect SMT Satisfying Model" |
| Execute command | `ontologic.solve`, `ontologic.explainUnsat`, `ontologic.inspectModel`. They run asynchronously with progress notifications and can be cancelled; they always use the `auto` prover |
| Execute command | `ontologic.solve`, `ontologic.explainUnsat`, `ontologic.inspectModel`. They run asynchronously with progress notifications and can be cancelled; they always use the `auto` prover. When `auto` falls back to the native prover on an ontology with numeric comparisons, the `ontologic.solve` SAT `details` end with a warning that the theory was checked without arithmetic |

Imports use the same search path as the CLI, including `$ONTOLOGIC_PATH` (set it in the environment the editor is launched from). The server has no `--lib-path` option.

Expand Down
2 changes: 2 additions & 0 deletions docs/user-guide/repl.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Input is read one line at a time, so each form or command must fit on one line.

Anything that is not a command is parsed as DSL. A line may contain one or several top-level forms; they are merged into the session. The linter runs after each addition and, if it finds a problem, prints `⚠️ Lint warning: ...` for the first one; the forms stay in the session regardless.

The `native` and `vampire` provers have no arithmetic. When one of them is active (or `auto` has no external solver to use) and the session uses `gt`, `gte`, `lt` or `lte`, an all-clear from `:solve`, `:model`, `:explain`, `:unsat` or `:prove` ends with `⚠️ ... checks this theory without arithmetic ...`. Confirm such an answer with `:prover z3` or `:prover cvc5`.

## Example session

```text
Expand Down
3 changes: 3 additions & 0 deletions docs/user-guide/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,16 @@ Contradictions can be reported twice (once per operand order); fix the first and
| `SMT Solver Error: Failed to execute Z3 solver: ... Ensure 'z3' is installed and available in PATH.` | You asked for a specific prover (`-p z3`) that is not installed. Install it, or use `-p auto`/`-p native` |
| `Unknown prover 'x'. Valid options: z3, cvc5, vampire, native, auto` | Bad `-p` value |
| `⚠️ --solve-memory is not supported by CVC5 and is ignored.` | Memory limits apply to Z3 only |
| `⚠️ The native prover checks this theory without arithmetic: ...` (or `Vampire checks ...`) | The ontology uses `gt`, `gte`, `lt` or `lte`, and the all-clear came from `native` or `vampire`. It can miss a conflict that needs arithmetic. Re-run with `-p z3` or `-p cvc5`. See [below](#sat-from-one-prover-unsat-from-another) |
| `Concept coherence check could not run: ...` | Exit 2; the second solver step failed. Usually the same cause as an adjacent solver error |
| `Native resolution prover timed out / step limit / clause limit exceeded` | The built-in prover gave up (reported as unknown). Use `z3` or `cvc5` |

### SAT from one prover, UNSAT from another

The native prover and Vampire have no arithmetic. They are told which pairs of numeric bounds in the file exclude each other, so a plain conflict (a universal `gte 100` and an existential witness with `lt 50`) is UNSAT on every backend. A contradiction that needs real arithmetic, such as an integer gap (`gt 5` and `lt 6` on an `Integer`), is UNSAT under `-p z3` or `-p cvc5` and can look SAT under `-p native` or `-p vampire`. Prefer Z3 or CVC5 whenever properties have numeric bounds.

OntoLogic flags the answers this affects. When the ontology uses `gt`, `gte`, `lt` or `lte` and `native` or `vampire` gives an all-clear (SAT, or every concept satisfiable), `--solve` prints a warning on stderr that the theory was checked without arithmetic. The REPL adds the same line to its answer. `-p auto` warns only when it has fallen back to the native prover. An UNSAT from these provers needs no confirmation.

### Auto picked the native prover

`--prover auto` falls back to the native prover only when none of `z3`, `cvc5`, `vampire` is on `PATH`. Check with `which z3 cvc5 vampire`. Solvers installed through sandboxed packages (snap, flatpak) may not be visible or may not read your files.
Expand Down
2 changes: 1 addition & 1 deletion ontologic.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack

name: ontologic
version: 1.8.2
version: 1.8.3
homepage: https://github.com/bsommers/OntoLogic#readme
bug-reports: https://github.com/bsommers/OntoLogic/issues
author: OntoLogic Team
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: ontologic
version: 1.8.2
version: 1.8.3
github: "bsommers/OntoLogic"
license: Apache-2.0
author: "OntoLogic Team"
Expand Down
5 changes: 3 additions & 2 deletions src/LSP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import OntoLogic
import Parser (parseRegistry, parseRegistryWithSource)
import Linter (lintRegistryFindings, lintRegistryFindingsWithSource, LintFinding(..))
import IR (compileRegistry, irClasses, compClassName, compParentClass, compProperties, compPropName, compPropType, compConstraints, CompiledProperty, compCardinality, compDefaultValue)
import Solver (checkConsistencyWith, explainUnsatWith, extractModel, Prover(AutoProver), UnsatExplanation(..))
import Solver (checkConsistencyWith, explainUnsatWith, extractModel, arithmeticCaveat, Prover(AutoProver), UnsatExplanation(..))

data LSPState = LSPState
{ lspDocs :: Map.Map String String -- URI -> Content
Expand Down Expand Up @@ -440,8 +440,9 @@ handleLSPRequestIO state raw
case cmd of
"ontologic.solve" -> do
res <- checkConsistencyWith AutoProver reg
caveat <- arithmeticCaveat AutoProver reg
let (status, details) = case res of
Sat _ -> ("sat", "Satisfiable (SAT): Consistent Model Found")
Sat _ -> ("sat", "Satisfiable (SAT): Consistent Model Found" ++ maybe "" (". " ++) caveat)
Unsat -> ("unsat", "Unsatisfiable (UNSAT): Logical Contradiction Detected")
Unknown u -> ("unknown", u)
SolverError e-> ("error", e)
Expand Down
9 changes: 9 additions & 0 deletions src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Solver
, findUnsatConceptsWithOptions
, explainUnsatWithOptions
, untranslatedAxioms
, arithmeticCaveat
, resolveProver
, solverExitCode
, worst
Expand Down Expand Up @@ -177,6 +178,14 @@ runSolverCheck isFreeConsts showExplain showModel maybeP maybeTimeout maybeMem r
Right empties -> do
putStrLn ("❌ Unsatisfiable / empty concept(s): " ++ unwords empties)
return (ExitFailure 1)
-- An all-clear from a backend without arithmetic can miss numeric conflicts: say so.
let allClear = case (res, coh) of
(Sat _, _) -> True
(_, Right []) -> True
_ -> False
if allClear
then arithmeticCaveat prover reg >>= mapM_ (\w -> hPutStrLn stderr ("⚠️ " ++ w))
else return ()
exitWith (worst [solverExitCode res, coherenceCode])

processTarget :: Bool -> SourceTable -> String -> String -> Maybe String -> Maybe String -> Maybe String -> Bool -> Registry -> IO ()
Expand Down
19 changes: 19 additions & 0 deletions src/OntoLogic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -503,3 +503,22 @@ disjointBoundPairs axs =
| l@(lop, a) <- lowers, u@(uop, b) <- uppers
, num a > num b || (num a == num b && (lop == "gt" || uop == "lt"))
]

-- | Whether any axiom compares values with an ordering operator (gt, gte, lt, lte). A declared
-- relation that shares one of those names is a relation, not a comparison.
usesOrderingComparison :: Registry -> Bool
usesOrderingComparison reg = any go (axioms reg)
where
ordOps = filter (`notElem` map relName (relations reg)) ["gt", "gte", "lt", "lte"]
go f = case f of
Predicate op _ -> op `elem` ordOps
And a b -> go a || go b
Or a b -> go a || go b
Implies a b -> go a || go b
Iff a b -> go a || go b
Not a -> go a
ForAll _ b -> go b
Exists _ b -> go b
TypedForAll _ _ b -> go b
TypedExists _ _ b -> go b
_ -> False
30 changes: 23 additions & 7 deletions src/REPL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Solver
, proveSubsumptionWith
, findUnsatConceptsWith
, untranslatedAxioms
, arithmeticCaveat
, Prover(..)
, parseProver
, proverName
Expand Down Expand Up @@ -142,15 +143,21 @@ evalREPLCommand state input
Left err -> "⚠️ Concept coherence check could not run: " ++ err
Right [] -> "✅ All concepts are satisfiable (0 empty concepts)."
Right empties -> "❌ Unsatisfiable / empty concept(s): " ++ unwords empties
return (state, warning ++ consistency ++ "\n" ++ coherence)
note <- case (res, coh) of
(Sat _, _) -> caveatLine state
(_, Right []) -> caveatLine state
_ -> return ""
return (state, warning ++ consistency ++ "\n" ++ coherence ++ note)

| input `elem` [":explain", ":unsat-core", ":explain-unsat"] = do
res <- explainUnsatWith (replProver state) (replRegistry state)
case res of
Left err -> return (state, "❌ SMT Explanation Error:\n" ++ err)
Right explanation ->
if null (unsatCoreNames explanation)
then return (state, "✅ SMT Satisfiable (SAT) — No contradictory axioms or unsat cores detected.")
then do
note <- caveatLine state
return (state, "✅ SMT Satisfiable (SAT) — No contradictory axioms or unsat cores detected." ++ note)
else return (state, unlines
[ "❌ SMT Unsatisfiable (UNSAT) — Minimal Unsat Core Identified:"
, " Core Assertions: " ++ unwords (unsatCoreNames explanation)
Expand All @@ -162,10 +169,11 @@ evalREPLCommand state input
| input `elem` [":model", ":inspect-model"] = do
res <- checkConsistencyWith (replProver state) (replRegistry state)
case res of
Sat _ ->
Sat _ -> do
note <- caveatLine state
case extractModel res of
Just m -> return (state, "✅ SMT Satisfiable (SAT) — Extracted Valuation Model:\n" ++ m)
Nothing -> return (state, "✅ SMT Satisfiable (SAT) — Valuation model is empty or implicit.")
Just m -> return (state, "✅ SMT Satisfiable (SAT) — Extracted Valuation Model:\n" ++ m ++ note)
Nothing -> return (state, "✅ SMT Satisfiable (SAT) — Valuation model is empty or implicit." ++ note)
Unsat -> return (state, "❌ SMT Unsatisfiable (UNSAT) — No satisfying model exists. Run ':explain' to view the unsat core.")
Unknown out -> return (state, "⚠️ SMT Solver Result Inconclusive: " ++ out)
SolverError err -> return (state, "❌ SMT Solver Error:\n" ++ err)
Expand All @@ -177,15 +185,19 @@ evalREPLCommand state input
res <- proveSubsumptionWith (replProver state) (replRegistry state) child parent
case res of
Subsumed -> return (state, "✅ Theorem Proved via " ++ proverName (replProver state) ++ ": '" ++ child ++ "' ⊑ '" ++ parent ++ "' (Every instance of " ++ child ++ " is necessarily a " ++ parent ++ ").")
NotSubsumed model -> return (state, "❌ Theorem Disproved via " ++ proverName (replProver state) ++ ": '" ++ child ++ "' is NOT subsumed by '" ++ parent ++ "'. Counterexample model:\n" ++ model)
NotSubsumed model -> do
note <- caveatLine state
return (state, "❌ Theorem Disproved via " ++ proverName (replProver state) ++ ": '" ++ child ++ "' is NOT subsumed by '" ++ parent ++ "'. Counterexample model:\n" ++ model ++ note)
ProofError err -> return (state, "❌ Solver Error in Subsumption Proof:\n" ++ err)
_ -> return (state, "⚠️ Usage: :prove <ConceptA> <ConceptB>")

| input == ":unsat" = do
res <- findUnsatConceptsWith (replProver state) (replRegistry state)
case res of
Left err -> return (state, "❌ SMT Solver Error:\n" ++ err)
Right [] -> return (state, "✅ All concepts are satisfiable (0 empty concepts) via " ++ proverName (replProver state) ++ ".")
Right [] -> do
note <- caveatLine state
return (state, "✅ All concepts are satisfiable (0 empty concepts) via " ++ proverName (replProver state) ++ "." ++ note)
Right unsatList -> return (state, "❌ Unsatisfiable / Contradictory Concepts Found via " ++ proverName (replProver state) ++ ":\n" ++ unlines (map (" - " ++) unsatList))

| input == ":clear" =
Expand Down Expand Up @@ -229,6 +241,10 @@ evalREPLCommand state input
lintMsg = if null errs then "" else "\n⚠️ Lint warning: " ++ head errs
in return (state { replRegistry = merged }, "Added to registry." ++ lintMsg)

-- | Extra line for an all-clear answer from a prover without arithmetic; empty when none applies.
caveatLine :: REPLState -> IO String
caveatLine state = maybe "" ("\n⚠️ " ++) <$> arithmeticCaveat (replProver state) (replRegistry state)

trim :: String -> String
trim = f . f
where f = reverse . dropWhile (`elem` (" \t\r\n" :: String))
Expand Down
Loading
Loading