/* * Copyright 2021 Magnus Madsen * Copyright 2021 Benjamin Dahse * Copyright 2025 Casper Dalgaard Nielsen * Adam Yasser Tallouzi * * Use of this source code is governed by the Apache 2.0 license * that can be found in the LICENSE.md file. */pubmod Fixpoint3.Ast.Shared {use Fixpoint3.Boxableuse Fixpoint3.Boxed/////////////////////////////////////////////////////////////////////////////// Denotation ///////////////////////////////////////////////////////////////////////////////////// Represents the denotation of a predicate symbol.////// A predicate symbol either has relational or lattice semantics.////// If it has lattice semantics it is equipped with:////// - A bottom element./// - A partial order (a leq function)./// - a least upper bound (a lub function)./// - a greatest lower bound (a glb function).///pubenumDenotation[v] {case Relationalcase Latticenal(v, v -> v -> Bool, v -> v -> v, v -> v -> v) }pubtypealiasBoxedDenotation = Denotation[Boxed]////// Returns `true` if the given denotation is relational.///pubdefisRelational(den: Denotation[v]): Bool = matchden {case Denotation.Relational => truecase_ => false }////// Returns a latticenal denotation associated with the type `t`.///@LoweringTargetDatalogpubdeflattice(): Denotation[v] withLowerBound[v], JoinLattice[v], MeetLattice[v] = Denotation.Latticenal(LowerBound.minValue(), (x, y) -> PartialOrder.lessEqual(x, y), (x, y) -> JoinLattice.leastUpperBound(x, y), (x, y) -> MeetLattice.greatestLowerBound(x, y) )////// Boxes the lattice components inside the given denotation `d`.///@LoweringTargetDatalogpubdefbox(d: Denotation[t]): Denotation[Boxed] withOrder[t] = matchd {case Denotation.Relational => Denotation.Relationalcase Denotation.Latticenal(bot, leq, lub, glb) => Denotation.Latticenal(Boxable.box(bot),Boxable.lift2b(leq),Boxable.lift2(lub),Boxable.lift2(glb) ) }/////////////////////////////////////////////////////////////////////////////// PredSym ///////////////////////////////////////////////////////////////////////////////pubenumPredSymwithEq, Order {case PredSym(String, Int64) }instanceToString[PredSym] {pubdeftoString(predSym: PredSym): String = matchpredSym {case PredSym.PredSym(name, id) => "${name}%${id}" } }}