MetaMetaUnify() public method

Merge the information from two Metastructures into one new metastructure.
public MetaMetaUnify ( Metastructure value, IEnumerable &filter ) : Metastructure
value Metastructure The Metastructure to merge with.
filter IEnumerable Test for whether the merging succeeded. Generally a woken goal.
return Metastructure
Beispiel #1
0
        internal IEnumerable <CutState> MetaUnify(Metastructure m)
        {
            if (IsBound)
            {
                throw new InvalidOperationException("Cannot meta-unify a bound variable");
            }
            Metastructure          old    = MetaBinding;
            IEnumerable <CutState> filter = null;

            mValue = old != null?old.MetaMetaUnify(m, out filter) : m;

            try
            {
                if (filter != null)
#pragma warning disable 414, 168, 219
                {
                    // ReSharper disable UnusedVariable
                    foreach (var ignore in filter)
                    // ReSharper restore UnusedVariable
#pragma warning restore 414, 168, 219
                    {
                        yield return(CutState.Continue);
                    }
                }
                else
                {
                    yield return(CutState.Continue);
                }
            }
            finally
            {
                mValue = old;
            }
        }
Beispiel #2
0
        internal IEnumerable <CutState> MetaUnify(Metastructure m)
        {
            if (IsBound)
            {
                throw new InvalidOperationException("Cannot meta-unify a bound variable");
            }
            Metastructure          old    = MetaBinding;
            IEnumerable <CutState> filter = null;

            if (old != null)
            {
                var merged = old.MetaMetaUnify(m, out filter);
                if (merged != null)
                {
                    mValue = merged;
                }
                else
                {
                    // All we have a suspended goal, which is now in the filter
                    // there's no frozen goal, so we just unbind the variable
                    // and see what the filter does.
                    mValue = this;
                }
            }
            else
            {
                mValue = m;
            }

            try
            {
                if (filter != null)
#pragma warning disable 414, 168, 219
                {
                    // ReSharper disable UnusedVariable
                    foreach (var ignore in filter)
                    // ReSharper restore UnusedVariable
#pragma warning restore 414, 168, 219
                    {
                        yield return(CutState.Continue);
                    }
                }
                else
                {
                    yield return(CutState.Continue);
                }
            }
            finally
            {
                mValue = old;
            }
        }
Beispiel #3
0
        IEnumerable <bool> UnifyMetaMeta(Metastructure myMetaStructure, Metastructure theirMetaStructure, LogicVariable them)
        {
            IEnumerable <CutState> filter;

            mValue     = myMetaStructure.MetaMetaUnify(theirMetaStructure, out filter);
            them.Value = this;
#pragma warning disable 414, 168, 219
            // ReSharper disable UnusedVariable
            foreach (var ignore in filter)
            // ReSharper restore UnusedVariable
#pragma warning restore 414, 168, 219
            {
                yield return(false);
            }
            mValue      = myMetaStructure;
            them.mValue = theirMetaStructure; //null;
            //them.IsBound = false;
        }
 IEnumerable<bool> UnifyMetaMeta(Metastructure myMetaStructure, Metastructure theirMetaStructure, LogicVariable them)
 {
     IEnumerable<CutState> filter;
     object mergedMetaValue = myMetaStructure.MetaMetaUnify(theirMetaStructure, out filter);
     mValue = mergedMetaValue??this;
     them.Value = this;
     #pragma warning disable 414, 168, 219
     // ReSharper disable UnusedVariable
     foreach (var ignore in filter)
         // ReSharper restore UnusedVariable
     #pragma warning restore 414, 168, 219
         yield return false;
     mValue = myMetaStructure;
     them.mValue = theirMetaStructure; //null;
     //them.IsBound = false;
 }
 /// <summary>
 /// This is an attributed variable with attribute myMetaStructure, unify it with attributed variable them, with attribute theirMetaStructure.
 /// </summary>
 /// <param name="myMetaStructure">This variable's metavalue</param>
 /// <param name="theirMetaStructure">The meta-value of the variable we're unifying with</param>
 /// <param name="them">The variable to unify with</param>
 /// <param name="context">Prolog context</param>
 void UnifyMetaMeta(Metastructure myMetaStructure, Metastructure theirMetaStructure, LogicVariable them, PrologContext context)
 {
     SaveAndUpdate(myMetaStructure.MetaMetaUnify(theirMetaStructure, context), context);
     them.SaveAndUpdate(this, context);
 }
Beispiel #6
0
 /// <summary>
 /// This is an attributed variable with attribute myMetaStructure, unify it with attributed variable them, with attribute theirMetaStructure.
 /// </summary>
 /// <param name="myMetaStructure">This variable's metavalue</param>
 /// <param name="theirMetaStructure">The meta-value of the variable we're unifying with</param>
 /// <param name="them">The variable to unify with</param>
 /// <param name="context">Prolog context</param>
 void UnifyMetaMeta(Metastructure myMetaStructure, Metastructure theirMetaStructure, LogicVariable them, PrologContext context)
 {
     SaveAndUpdate(myMetaStructure.MetaMetaUnify(theirMetaStructure, context), context);
     them.SaveAndUpdate(this, context);
 }