All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.unibo.alchemist.model.sapere.ILsaMolecule Maven / Gradle / Ivy

There is a newer version: 35.0.1
Show newest version
/*
 * Copyright (C) 2010-2023, Danilo Pianini and contributors
 * listed, for each module, in the respective subproject's build.gradle.kts file.
 *
 * This file is part of Alchemist, and is distributed under the terms of the
 * GNU General Public License, with a linking exception,
 * as described in the file LICENSE in the Alchemist distribution's top directory.
 */
package it.unibo.alchemist.model.sapere;

import it.unibo.alchemist.model.sapere.dsl.IExpression;
import it.unibo.alchemist.model.sapere.dsl.ITreeNode;

import java.util.List;
import java.util.Map;

import it.unibo.alchemist.model.Molecule;
import org.danilopianini.lang.HashString;


/**
 */
public interface ILsaMolecule extends Molecule, Iterable, Comparable {

    /**
     * @param matches
     *            the map with the variable / value bindings
     * @return the list of the arguments updated
     */
    List allocateVar(Map> matches);

    /**
     * @return the arguments number of the LSA structure.
     */
    int argsNumber();

    /**
     * @return true if the molecule arguments match with mol arguments.
     * @param mol
     *            the ILsaMolecule to compare.
     */
    @Override
    boolean equals(Object mol);

    /**
     * @return a new {@link ILsaMolecule} produced by replacing all non-atomic
     *         and non-numeric values with variables.
     */
    ILsaMolecule generalize();

    /**
     * @param i
     *            : position of the argument to get
     * @return the Expression represent the argument i.
     */
    IExpression getArg(int i);

    /**
     * @return true if this variable makes use of variables defined within the molecule itself
     */
    boolean hasDuplicateVariables();

    /**
     * @param mol
     *            the molecule to compare to
     * @return true if lsaMolecule is identical to mol, namely that all the
     *         arguments are equal
     **/
    boolean isIdenticalTo(ILsaMolecule mol);

    /**
     * @return true if the molecule is an instance (not variable in the
     *         argouments).
     */
    boolean isIstance();

    /**
     * @param mol
     *            the LsaMolecule to try to match with.
     * @return true if the two molecules match
     */
    boolean matches(ILsaMolecule mol);

    /**
     * @param mol
     *            the LsaMolecule to try to match with
     * @param duplicateVariables
     *            if true, the matching of variables reused within the same
     *            tuple is enabled
     * @return true if the two molecules match
     */
    boolean matches(List mol, boolean duplicateVariables);

    /**
     * @param mol
     *            the molecule to compare to
     * @return true if the molecule is more generic than the one passed
     */
    boolean moreGenericOf(ILsaMolecule mol);

    /**
     * @return the number of arguments
     */
    int size();

    /**
     * @return the string representing the molecule, in a faster implementation.
     */
    HashString toHashString();

    /**
     * @return the string representing the molecule.
     */
    @Override
    String toString();

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy