Close Menu

    Subscribe to Updates

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

    What's Hot

    Add 1TB of storage to your phone with SanDisk’s tiny SSD, now 19% off

    This fast-charging retractable USB-C cable is a must-buy for $10

    Outrageous! This tiny Ryzen PC with a huge 32GB RAM is just $269

    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

      Blue-collar jobs are gaining popularity as AI threatens office work

      August 17, 2025

      Man who asked ChatGPT about cutting out salt from his diet was hospitalized with hallucinations

      August 15, 2025

      What happens when chatbots shape your reality? Concerns are growing online

      August 14, 2025

      Scientists want to prevent AI from going rogue by teaching it to be bad first

      August 8, 2025

      AI models may be accidentally (and secretly) learning each other’s bad behaviors

      July 30, 2025
    • Business

      Cloudflare hit by data breach in Salesloft Drift supply chain attack

      September 2, 2025

      Cloudflare blocks largest recorded DDoS attack peaking at 11.5 Tbps

      September 2, 2025

      Why Certified VMware Pros Are Driving the Future of IT

      August 24, 2025

      Murky Panda hackers exploit cloud trust to hack downstream customers

      August 23, 2025

      The rise of sovereign clouds: no data portability, no party

      August 20, 2025
    • Crypto

      Ripple Deepens Global Payments Alliance With Thunes

      September 4, 2025

      US Fed to Host Conference in October, Covering Stablecoins and DeFi

      September 4, 2025

      US Bank Resumes Bitcoin Custody Amid Eased Rules

      September 4, 2025

      Consensys’ Ethereum L2 Linea to Launch 72B Tokens

      September 4, 2025

      How Trump’s Tariff Appeal Could Impact Crypto Markets

      September 4, 2025
    • Technology

      Add 1TB of storage to your phone with SanDisk’s tiny SSD, now 19% off

      September 4, 2025

      This fast-charging retractable USB-C cable is a must-buy for $10

      September 4, 2025

      Outrageous! This tiny Ryzen PC with a huge 32GB RAM is just $269

      September 4, 2025

      Firefox support for Windows 7 PCs gets extended once again

      September 4, 2025

      Media Briefing: DOJ’s Google search trial remedies fall flat for publishers

      September 4, 2025
    • 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 Read2 Views
    Facebook Twitter Pinterest Telegram LinkedIn Tumblr Email Reddit
    Mangle – a language for deductive database programming
    Share
    Facebook Twitter LinkedIn Pinterest WhatsApp Email

    BMI Calculator – Check your Body Mass Index for free!

    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.

    BMI Calculator – Check your Body Mass Index for free!

    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

    Add 1TB of storage to your phone with SanDisk’s tiny SSD, now 19% off

    September 4, 2025

    This fast-charging retractable USB-C cable is a must-buy for $10

    September 4, 2025

    Outrageous! This tiny Ryzen PC with a huge 32GB RAM is just $269

    September 4, 2025
    Leave A Reply Cancel Reply

    Top Posts

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

    April 22, 2025180 Views

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

    April 14, 202549 Views

    New Akira ransomware decryptor cracks encryptions keys using GPUs

    March 16, 202530 Views

    Is Libby Compatible With Kobo E-Readers?

    March 31, 202529 Views
    Don't Miss
    Technology September 4, 2025

    Add 1TB of storage to your phone with SanDisk’s tiny SSD, now 19% off

    Add 1TB of storage to your phone with SanDisk’s tiny SSD, now 19% off Image:…

    This fast-charging retractable USB-C cable is a must-buy for $10

    Outrageous! This tiny Ryzen PC with a huge 32GB RAM is just $269

    Firefox support for Windows 7 PCs gets extended once again

    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

    Add 1TB of storage to your phone with SanDisk’s tiny SSD, now 19% off

    September 4, 20252 Views

    This fast-charging retractable USB-C cable is a must-buy for $10

    September 4, 20251 Views

    Outrageous! This tiny Ryzen PC with a huge 32GB RAM is just $269

    September 4, 20252 Views
    Most Popular

    Xiaomi 15 Ultra Officially Launched in China, Malaysia launch to follow after global event

    March 12, 20250 Views

    Apple thinks people won’t use MagSafe on iPhone 16e

    March 12, 20250 Views

    French Apex Legends voice cast refuses contracts over “unacceptable” AI clause

    March 12, 20250 Views
    © 2025 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.