# Use cases motivating new directions in Raven

**URL:** https://discuss.ocaml.org/t/use-cases-motivating-new-directions-in-raven/16977
**Category:** Community
**Created:** [July 15, 2025, 6:15pm UTC](https://discuss.ocaml.org/t/use-cases-motivating-new-directions-in-raven/16977 "2025-07-15T18:15:59Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mostafatouny](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mostafatouny/32/5826_2.png) [@mostafatouny](https://discuss.ocaml.org/u/mostafatouny)
#### Post date: [July 15, 2025, 6:15pm UTC](https://discuss.ocaml.org/t/use-cases-motivating-new-directions-in-raven/16977/1 "2025-07-15T18:15:59Z")

</div>

Hello,

Raven was [recently announced](https://discuss.ocaml.org/t/announcing-raven-scientific-computing-for-ocaml-alpha-release/16913) for modern scientific computing in OCaml.

Combining provable guarantees with machine learning started to get witnessed in both research and industry, but not matured yet for everyday production. Since type-driven programming is more native in logic-based avenues, it is worthwhile to highlight these for future directions.

## Probabilistic Models

_Story._ A company decided to design a simple score for assessing loyal customers to be targeted for promotions. The score should be adapted according to the feedback they’ll get from consumers.

_ML Limitation._ The score must be completely interpretable / explainable for their feedback assessment. Modern ML models do not offer that.

_Decision._ Adhoc rules are implemented in a SQL query to compute the scores.

_Probabilistic Models._ A fully interpretable probabilistic model could be designed, considering the rules the team hypothesized.

Think of a graph whose edges denote a rule alongside a probability. If the client is a female, then with 70% a chance, it takes that vertex. each client traces a path, to predict whether a client is recommended for a promotion.

_Why OCaml?_ Many probabilistic models are based on [logical axioms](https://en.wikipedia.org/wiki/Probability_axioms), and thereby we can infer using logic. A stakeholder would appreciate a guarantee that no more 20% of clients will get at least 50% discount. I saw Probability theory formalism in type theory as in [Kachapova’s paper](https://thescipub.com/abstract/jmssp.2018.209.218). It is in Coq theorem prover (implemented in OCaml).

I am not aware of any extention of those fronteirs, from theorem proving to type-driven probabilistic model design. Knowledge-based systems seems to be dead in all modern languages.

## Learning-augmented Algorithms

_Story._ A ride-hailing company decided to design a new matching algorithm to ensure fairness among all demanding areas. Serving a segment of customers at the expense of others causes bad feedback.

_ML Limitation_. The data is biased, and thereby any machine learning model shall be biased as well. The company rejects any learning-from-data as it does not conform with its policies.

_Decision._ The engineering team found an open source matching engine, and after some testing and tuning, deployed it.

_Learning-augmented Algorithms._ A matching algorithm could be designed ensuring fairness among demanding areas, yet preferring profitable clients within each area.

Think of binary search but with choosing the pivot element using a predictive blackbox. If prediction accuracy is 100% then we find the target after one comparison. If accuracy is bad, then we are not worse than the worst-case scenario of binary search, finding the target in O(log).

_Why OCaml?_ Since fairness has an [axiomatic logical foundation](https://en.wikipedia.org/wiki/Arrow%27s_impossibility_theorem#Background), expressing logical properties is in favour of OCaml in property testing. Partial function application enables a clean algorithm parametrization.

I am not aware of any library for _learning-augmented algorithms_ in any language.

## Neuro-symbolic AI

_Story._ A legal consultancy company is designing a chatbot. It has strict policies the chatbot should follow.

_ML Limitation._ Text generation could hallucinate. It is more problemetic in sensitive domains like legal consultancy.

_Decision._ Retrieval-augmented generation, where related trusted sources are retrieved, guided by them the text is generated.

_Neuro-symbolic AI._ Instead of just retrieving, a symbolic engine could query the user some questions, and reason and infer new conclusions using logic. Based on these conclusions, the text generation process is guided.

_Why OCaml?_ It is more native to express symbolic components in terms of types.

I am not aware of any library in any language for building symbolic components using types.

## Bonus. Data Engineering

Data engineering is critical for any scientific computing work. Functional programming is already recognized for that. See [TU Delft’s course](https://online-learning.tudelft.nl/courses/functional-programming-for-big-data-processing/).

## Discussion

We are calling out for the community, to try similar case studies.

- Start with adhocs or imperative programming integration techniques in any language.
- If promising, look for architectural patterns in research.
- Estimate whether OCaml’s ecosystem is of an added value.

Contributing to OCaml is not a hobbyist’s decision. It should be driven by a business model, and that is what we are trying to figure now. Multi-disciplinary volunteers are needed, across research, engineering, and business.

I am happy to learn from your feedback and suggestions.
