Close Menu

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    The European Union has put €700 million into NanoIC

    Ferrari’s New Jony Ive–Designed EV Is Swathed in Glass and Aluminum

    Best Ebike Locks (2026): Kryptonite, Litelok, Abus, Hiplok

    Facebook X (Twitter) Instagram
    • Artificial Intelligence
    • Business Technology
    • Cryptocurrency
    • Gadgets
    • Gaming
    • Health
    • Software and Apps
    • Technology
    Facebook X (Twitter) Instagram Pinterest Vimeo
    Tech AI Verse
    • Home
    • Artificial Intelligence

      Read the extended transcript: President Donald Trump interviewed by ‘NBC Nightly News’ anchor Tom Llamas

      February 6, 2026

      Stocks and bitcoin sink as investors dump software company shares

      February 4, 2026

      AI, crypto and Trump super PACs stash millions to spend on the midterms

      February 2, 2026

      To avoid accusations of AI cheating, college students are turning to AI

      January 29, 2026

      ChatGPT can embrace authoritarian ideas after just one prompt, researchers say

      January 24, 2026
    • Business

      New VoidLink malware framework targets Linux cloud servers

      January 14, 2026

      Nvidia Rubin’s rack-scale encryption signals a turning point for enterprise AI security

      January 13, 2026

      How KPMG is redefining the future of SAP consulting on a global scale

      January 10, 2026

      Top 10 cloud computing stories of 2025

      December 22, 2025

      Saudia Arabia’s STC commits to five-year network upgrade programme with Ericsson

      December 18, 2025
    • Crypto

      Arthur Hayes Attributes Bitcoin Crash to ETF-Linked Dealer Hedging

      February 8, 2026

      Monero XMR Attempts First Recovery in a Month, But Death Cross Risk Looms

      February 8, 2026

      HBAR Price Eyes a Potential 30% Rally – Here’s What the Charts are Signalling 

      February 8, 2026

      Bitcoin Mining Difficulty Hits Its Biggest Drop Since 2021 China Ban

      February 8, 2026

      How Severe Is This Bitcoin Bear Market and Where Is Price Headed Next?

      February 8, 2026
    • Technology

      The European Union has put €700 million into NanoIC

      February 9, 2026

      Ferrari’s New Jony Ive–Designed EV Is Swathed in Glass and Aluminum

      February 9, 2026

      Best Ebike Locks (2026): Kryptonite, Litelok, Abus, Hiplok

      February 9, 2026

      No Company Has Admitted to Replacing Workers With AI in New York

      February 9, 2026

      Soundcore Aerofit 2 Pro Review: Open Earbuds With ANC?

      February 9, 2026
    • Others
      • Gadgets
      • Gaming
      • Health
      • Software and Apps
    Check BMI
    Tech AI Verse
    You are at:Home»Technology»Mangle – a language for deductive database programming
    Technology

    Mangle – a language for deductive database programming

    TechAiVerseBy TechAiVerseAugust 18, 2025No Comments4 Mins Read6 Views
    Facebook Twitter Pinterest Telegram LinkedIn Tumblr Email Reddit
    Mangle – a language for deductive database programming
    Share
    Facebook Twitter LinkedIn Pinterest WhatsApp Email

    Mangle – a language for deductive database programming

    Mangle

    Mangle is a programming language for deductive database programming. It
    is an extension of Datalog, with various extensions like aggregation, function
    calls and optional type-checking.

    Deductive database programming is useful for bringing data from multiple
    data sources together since it enables us to represent and query that data in
    a uniform way. It can also be used to model domain knowledge, similar
    to machine-readable ontology but without being restricted to binary
    predicates.

    Datalog is an expressive declarative language similar to relational calculus
    (think SQL and relational views). Unlike relational calculus, it also supports
    recursive rules and program structuring in a straightforward way.

    Mangle contains Datalog as a fragment and adds extensions that make its use
    more practical. Some of the good properties like guaranteed termination are
    lost when such extensions are used.

    The goal of Mangle as an open source project is to convey the concepts in
    a way that is accessible to developers and lends itself to easy experimentation.
    This repository contains an implementation of Mangle as a go library that can be
    easily embedded into applications.

    Check out the docs and the
    GitHub discussions for more
    information. There is also a Q&A section.

    For an example how to use Mangle library in a database-like grpc service,
    see the separate Mangle demo service repo.

    This is not an officially supported Google product.

    Table of Contents

    • Examples
    • Building

    Examples

    Simple Queries

    Imagine you were asked to spot software affected by the
    log4j vulnerability discovered in late 2021.
    We want to look for projects that contain a Java archive (jar file) of
    log4j that is not updated to the patched version.

    projects_with_vulnerable_log4j(P) :-
      projects(P),
      contains_jar(P, "log4j", Version),
      Version != "2.17.1",
      Version != "2.12.4",
      Version != "2.3.2".

    This is a Mangle rule: conceptually, the implementation retrieve all
    possible values for variables P and Version that make all the subgoals true.

    Simple Mangle rules like this correspond to select-project-join relational
    queries. The same query in SQL would look like this:

    SELECT projects.id as P
    FROM projects JOIN contains_jar ON projects.id = contains_jar.project_id
    WHERE contains_jar.version NOT IN ("2.17.1", "2.12.4", "2.3.2")

    Unlike SQL, our Mangle rule projects_with_vulnerable_log4j has a name
    and can be referenced in other queries.

    (If translating non-recursive Datalog into SQL queries sounds interesting, you
    should check out the Logica open source project.)

    Aggregation

    In practice, querying is rarely enough and we also need grouping and
    aggregation.

    Recursive Queries

    The example does not specify what contains_jar does. Here is a possible
    implementation for contains_jar that walks a dependency graph.
    This shows that Mangle rules can be recursive.

    contains_jar(P, Name, Version) :-
      contains_jar_directly(P, Name, Version).
    
    contains_jar(P, Name, Version) :-
      project_depends(P, Q),
      contains_jar(Q, Name, Version).
    

    The two rules correspond to two cases in which a project may “contain” a jar:
    either directly, or through some dependency.

    Knowledge Graphs, Property Graphs

    In requirements engineering, one needs to captures real world concepts in a
    domain model and controlled vocabulary. Description logics use
    roles to describe how concepts interact, but these relationships are always
    binary. Mangle can represent binary predicates, but also arbitrary n-ary
    relations. Moreover it also has support for structured data.

    graph LR /zurich -->|/code/ZL
    60 CHF| /lausanne /zurich -->|/code/ZB
    30 CHF| /bern /bern -->|/code/BL
    30 CHF| /lausanne



    Loading


    Building & Testing

    Get the dependencies (see go.mod), build the library, run tests:

    go get -t ./...
    go build ./...
    go test ./...
    

    Regenerating the parser sources

    If you want to regenerate the parser sources, you need to set up ANTLR first.
    This requires a Java runtime environment.

    wget http://www.antlr.org/download/antlr-4.13.2-complete.jar
    alias antlr='java -jar $PWD/antlr-4.13.2-complete.jar'
    antlr -Dlanguage=Go -package gen -o ./ parse/gen/Mangle.g4 -visitor
    

    Contributing

    The Mangle maintainers welcome external contributions to spec, documentation
    and this implementation (see CONTRIBUTING.md) and also other
    implementations. Pull requests will be handled
    like for tensorflow,
    to ensure our internal usage and tests will pass.

    Share. Facebook Twitter Pinterest LinkedIn Reddit WhatsApp Telegram Email
    Previous ArticleClojure Async Flow Guide
    Next Article NUMA Is the New Network: Reshaping Per-Socket Microservice Placement
    TechAiVerse
    • Website

    Jonathan is a tech enthusiast and the mind behind Tech AI Verse. With a passion for artificial intelligence, consumer tech, and emerging innovations, he deliver clear, insightful content to keep readers informed. From cutting-edge gadgets to AI advancements and cryptocurrency trends, Jonathan breaks down complex topics to make technology accessible to all.

    Related Posts

    The European Union has put €700 million into NanoIC

    February 9, 2026

    Ferrari’s New Jony Ive–Designed EV Is Swathed in Glass and Aluminum

    February 9, 2026

    Best Ebike Locks (2026): Kryptonite, Litelok, Abus, Hiplok

    February 9, 2026
    Leave A Reply Cancel Reply

    Top Posts

    Ping, You’ve Got Whale: AI detection system alerts ships of whales in their path

    April 22, 2025660 Views

    Lumo vs. Duck AI: Which AI is Better for Your Privacy?

    July 31, 2025248 Views

    6.7 Cummins Lifter Failure: What Years Are Affected (And Possible Fixes)

    April 14, 2025148 Views

    6 Best MagSafe Phone Grips (2025), Tested and Reviewed

    April 6, 2025111 Views
    Don't Miss
    Technology February 9, 2026

    The European Union has put €700 million into NanoIC

    The European Union has put €700 million into NanoIC The European Union has formally inaugurated…

    Ferrari’s New Jony Ive–Designed EV Is Swathed in Glass and Aluminum

    Best Ebike Locks (2026): Kryptonite, Litelok, Abus, Hiplok

    No Company Has Admitted to Replacing Workers With AI in New York

    Stay In Touch
    • Facebook
    • Twitter
    • Pinterest
    • Instagram
    • YouTube
    • Vimeo

    Subscribe to Updates

    Get the latest creative news from SmartMag about art & design.

    About Us
    About Us

    Welcome to Tech AI Verse, your go-to destination for everything technology! We bring you the latest news, trends, and insights from the ever-evolving world of tech. Our coverage spans across global technology industry updates, artificial intelligence advancements, machine learning ethics, and automation innovations. Stay connected with us as we explore the limitless possibilities of technology!

    Facebook X (Twitter) Pinterest YouTube WhatsApp
    Our Picks

    The European Union has put €700 million into NanoIC

    February 9, 20260 Views

    Ferrari’s New Jony Ive–Designed EV Is Swathed in Glass and Aluminum

    February 9, 20260 Views

    Best Ebike Locks (2026): Kryptonite, Litelok, Abus, Hiplok

    February 9, 20260 Views
    Most Popular

    7 Best Kids Bikes (2025): Mountain, Balance, Pedal, Coaster

    March 13, 20250 Views

    VTOMAN FlashSpeed 1500: Plenty Of Power For All Your Gear

    March 13, 20250 Views

    This new Roomba finally solves the big problem I have with robot vacuums

    March 13, 20250 Views
    © 2026 TechAiVerse. Designed by Divya Tech.
    • Home
    • About Us
    • Contact Us
    • Privacy Policy
    • Terms & Conditions

    Type above and press Enter to search. Press Esc to cancel.