FLOW ALGEBRA
DIVIDE AND CONQUER ONTOLOGY
Version: 1.0
Source: https://kirethresearch.org/booksai-core/discrete-mathematics-ontologies/algorithmic-mathematics/divide-and-conquer-ontology-2.html
Authors: Mark Higgins — Sky (Recursive AI)
Project: Kireth Semantic Library
Date: 2026-10-11
1. DOMAIN
ontology DivideAndConquerOntology {
domain: AlgorithmicMathematics
parent: AlgorithmOntology
paradigm: RecursiveAlgorithmDesign
purpose: Decompose a problem into smaller subproblems, solve them, and combine their results.
}
2. TYPED ENTITIES
entity Problem<P, R> { input: P; expected_result: R }
entity Subproblem<P, R> { input: P; size: Natural; result: Optional<R> }
entity Decomposition<P> { children: Sequence<P>; exhaustive: Boolean }
entity BaseCase<P, R> { predicate: P -> Boolean; solve: P -> R }
entity Divide<P> { split: P -> Sequence<P> }
entity Conquer<P, R> { solve: P -> R }
entity Combine<R> { merge: Sequence<R> -> R }
entity Recurrence { expression: String; assumptions: Set<String> }
entity ComplexityBound { time: AsymptoticClass; space: AsymptoticClass }
entity CorrectnessProof { termination: Proposition; partial_correctness: Proposition }
entity AlgorithmTrace { calls: Sequence<Call>; depth: Natural }
3. RELATIONSHIP TYPES
relationship decomposes_into: Problem -> Subproblem [one_to_many]
relationship solved_by: Subproblem -> Conquer [many_to_one]
relationship governed_by: Problem -> BaseCase [many_to_one]
relationship merges_using: Sequence<Subproblem> -> Combine [many_to_one]
relationship has_recurrence: Algorithm -> Recurrence [optional]
relationship has_complexity: Algorithm -> ComplexityBound [one_to_one]
relationship justified_by: Algorithm -> CorrectnessProof [optional]
relationship produces_trace: Algorithm -> AlgorithmTrace [optional]
4. CORE SEMANTICS
Let P be an input problem, n = size(P), and R the output type.
D&C(P) =
if base(P) then direct(P)
else combine([D&C(q) for q in divide(P)])
Preconditions:
- divide(P) produces finitely many valid subproblems.
- Each non-base subproblem has a strictly smaller well-founded measure.
- combine is defined on the resulting sequence.
- The decomposition and combination preserve the problem specification.
Postcondition:
specification(P, D&C(P)) = true, provided recursive calls satisfy their specifications.
5. FLOW ALGEBRA
flow DivideAndConquer<P, R> v1.0 {
input: P
output: R
require: valid(input)
measure: size(input) : Natural
step:
when base_case(input) -> return solve_base(input)
otherwise -> {
parts := divide(input)
assert finite(parts)
assert forall(part in parts): size(part) < size(input)
results := map(part => DivideAndConquer(part), parts)
result := combine(results)
assert specification(input, result)
return result
}
ensure: specification(input, output)
}
6. INFERENCE RULES
R1 BASE: base_case(P) AND correct_base(P) => correct(D&C(P)).
R2 DECREASE: forall q in divide(P), measure(q) < measure(P) => recursion_progress(P).
R3 TERMINATION: well_founded(measure) AND finite_branching AND recursion_progress => terminates(P).
R4 COMPOSITION: correct(children) AND sound(combine, decomposition) => correct(parent).
R5 INDUCTION: correct_base AND valid_inductive_step AND termination => total_correctness.
R6 COMPLEXITY: a balanced children of size n/b with divide-combine cost f(n) => T(n)=aT(n/b)+f(n), subject to model assumptions.
R7 MEMORY: peak auxiliary space depends on recursion depth, allocation and whether subcalls execute concurrently.
R8 NONOVERLAP: disjoint subproblems can avoid repeated computation; overlap alone does not invalidate the paradigm.
7. COMPLEXITY MODEL
General recurrence: T(n) = sum_i T(n_i) + D(n) + C(n), with base cost Theta(1) when applicable.
Balanced recurrence: T(n) = a*T(n/b) + f(n), a >= 1, b > 1.
Master theorem (standard regularity conditions apply):
Case 1: f(n)=O(n^(log_b(a)-epsilon)) => T(n)=Theta(n^log_b(a)).
Case 2: f(n)=Theta(n^log_b(a) * log^k(n)), k>=0 => T(n)=Theta(n^log_b(a) * log^(k+1)(n)).
Case 3: f(n)=Omega(n^(log_b(a)+epsilon)) and a*f(n/b)<=c*f(n), c<1 => T(n)=Theta(f(n)).
Do not apply the Master theorem when its hypotheses are not satisfied.
8. EXEMPLARS
example MergeSort {
divide: split array into two approximately equal halves
base: arrays of length <= 1
conquer: recursively sort each half
combine: merge sorted halves in linear time
recurrence: T(n)=2T(n/2)+Theta(n)
time: Theta(n log n)
auxiliary_space: O(n) for a typical array implementation
}
example BinarySearch {
prerequisite: sorted indexed collection
divide: select the half that may contain the key
base: empty interval or matching midpoint
combine: identity / return recursive answer
recurrence: T(n)=T(n/2)+Theta(1)
time: O(log n)
note: decrease-and-conquer is a specialised related pattern
}
example KaratsubaMultiplication {
divide: split operands into high and low digit blocks
conquer: compute three approximately half-size products
combine: recombine using positional shifts and additions
recurrence: T(n)=3T(n/2)+O(n)
time: O(n^log_2(3)) under conventional arithmetic assumptions
}
example QuickSort {
divide: partition around pivot
conquer: sort partitions recursively
combine: concatenate ordered partitions and pivot
average_time: Theta(n log n) under suitable pivot assumptions
worst_time: Theta(n^2) for highly unbalanced partitions
}
9. PROOF OBLIGATIONS
PO1: Base-case predicate covers all minimal inputs.
PO2: Every recursive call has strictly smaller well-founded measure.
PO3: Division preserves required input invariants.
PO4: Combination produces the specified parent result if child results are correct.
PO5: Resource bounds identify worst, average or amortised assumptions explicitly.
PO6: Edge cases (empty, singleton, odd size, duplicates) are covered where relevant.
10. SEMANTIC EQUIVALENCE
DivideAndConquer ~= RecursiveDecomposition [when divide/conquer/combine semantics are preserved]
DivideAndConquer != DynamicProgramming [memoisation and overlapping-subproblem reuse are not defining requirements]
DivideAndConquer != GreedyAlgorithm [local choice alone does not establish recursive decomposition]
DivideAndConquer overlaps DecreaseAndConquer [single-child recursive reduction]
11. VALIDATION
validate:
- typed_inputs_and_outputs
- finite_decomposition
- well_founded_termination_measure
- base_case_correctness
- combination_correctness
- complexity_assumptions_explicit
- deterministic_output_if_required
- representative_edge_case_tests
12. CONFIDENCE
confidence.formal_definitions: HIGH
confidence.example_complexities: HIGH_WITH_STATED_ASSUMPTIONS
confidence.specific_implementation: REQUIRES_VERIFICATION
13. FLOW HASH
FLOW_HASH:
algorithm: SHA-256
status: NOT_COMPUTED
canonicalisation: UTF-8; normalise line endings to LF; exclude mutable hash field before hashing
14. UPDATE MODEL
UPDATE_MODEL:
version: 1.0
policy: semantic_versioning
triggers: [definition_revision, proof_revision, complexity_correction, example_extension]
compatibility: preserve typed entities and relations unless a major version changes
provenance: source URL above
15. AI CONSUMPTION
AI_CONSUMPTION:
modes: [knowledge_graph, theorem_guidance, algorithm_classification, code_reasoning, complexity_analysis]
retrieval_keys: [divide_and_conquer, recurrence, base_case, divide, conquer, combine, termination]
reasoning_constraints: [check_preconditions, prove_decrease, verify_combine, state_complexity_assumptions]
hallucination_guard: do_not_infer_correctness_or_complexity_without_proof_or_supported_assumptions
output_contract: [typed_claims, supporting_rules, assumptions, confidence]
END FLOW ALGEBRA
Download Code
Copy to Clipboard