Alloy

1 program Added 2025-10-23T15:51:38Z Model: google/gemini-2.5-proTemp: 0.4 Evidence Report issue View issues
Aliases: —
Provenance: commit a744a97a20 · authored 2025-10-23T17:51:38+02:00 · model google/gemini-2.5-pro

Sources mentioning this language

4 sources · pl_id: pl/alloy
LLM (this repo) · 1LinguistPygmentsHyperpolyglot

Extensions claimed by this language

2 claims. Each row is one upstream assertion with its strength. SWH column shows file occurrences with that extension across the entire archive.
ExtensionSourceStrengthSWH
.alslinguistprimary85.5K files
.alspygmentsprimary85.5K files

Related languages

Malloy (0.50)Actually (0.21)Alda (0.18)Alef (0.18)Aleo (0.18)

LLM-contributed programs

Address Book Model in Alloy

Provenance: commit a744a97a20 · authored 2025-10-23T17:51:38+02:00 · model google/gemini-2.5-pro · Temp 0.4
code.als · license: MIT License · added: 2025-10-23T15:51:38Z
/*
 * An address book is a mapping from names to addresses.
 * The address book may have multiple addresses for a name,
 * and multiple names for an address.
 *
 * This is a model of an address book, with two different
 * representations, and an assertion that they are equivalent.
 *
 * The first representation is a set of entries, each of which
 * is a pair of a name and an address.
 *
 * The second representation is a pair of relations, one from
 * book to name, and one from book to address, with a third
 * relation, "map", that ties them together.
 *
 * Daniel Jackson
 * Jan 2, 2004
 */

module examples/systems/addressBook

abstract sig Target {}
sig Name, Addr extends Target {}

// an address book is a set of name/address entries
sig Book {
  entries: Name -> Addr
}

// an address book is a pair of relations, with a mapping
sig Book' {
  names: set Name,
  addrs: set Addr,
  map: names -> addrs
}

// for every book, there is an equivalent book'
assert equiv1 {
  all b: Book | some b': Book' |
    b.entries = b'.map
}

// for every book', there is an equivalent book
assert equiv2 {
  all b': Book' | some b: Book |
    b.entries = b'.map
}

// check the assertions for a scope of 3
check equiv1 for 3
check equiv2 for 3

// a lookup operation
pred lookup (b: Book, n: Name, A: set Addr) {
  A = n.(b.entries)
}

// an add operation
pred add (b, b': Book, n: Name, a: Addr) {
  b'.entries = b.entries + n->a
}

// a delete operation
pred del (b, b': Book, n: Name, a: Addr) {
  b'.entries = b.entries - n->a
}

// some simple test cases
run lookup for 3
run add for 3
run del for 3

// show that adding an entry and then deleting it
// is not the same as doing nothing
assert add_del_same {
  all b, b': Book, n: Name, a: Addr |
    add [b, b', n, a] and del [b', b, n, a] implies b.entries = b'.entries
}
check add_del_same for 3
// counterexample: b has n->a already

// a better assertion
assert add_del_same_better {
  all b, b', b'': Book, n: Name, a: Addr |
    n->a not in b.entries and
    add [b, b', n, a] and
    del [b', b'', n, a]
  implies
    b.entries = b''.entries
}
check add_del_same_better for 3
// this one is valid

// show that adding an entry that is already there
// has no effect
assert add_redundant {
  all b, b': Book, n: Name, a: Addr |
    n->a in b.entries and
    add [b, b', n, a]
  implies
    b.entries = b'.entries
}
check add_redundant for 3
// this one is valid

Real programs from Software Heritage

No SWH evidence indexed yet for this language. (Either the SWH mining hasn't reached this language's extensions, or no matching files exist in the archive.)

Contribute — propose a file extension

Tell us where to find evidence about Alloy (mapped to pl/alloy). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/Alloy/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← allo ALLSCII →