private SimpleSentenceForm(int name, int arity, IReadOnlyList<Term> terms) { TupleSize = 0; var functions = new Dictionary<int, SimpleSentenceForm>(); for (int i = 0; i < arity; i++) { var term = terms[i] as TermFunction; if (term != null) { var functionForm = new SimpleSentenceForm(term); functions[i] = functionForm; TupleSize += functionForm.TupleSize; } else TupleSize++; } _arity = arity; Name = name; _functions = new ReadOnlyDictionary<int, SimpleSentenceForm>(functions); }
private Dictionary<ISentenceForm, ISentenceFormDomain> GetCartesianDomainsFromModel() { var results = new Dictionary<ISentenceForm, ISentenceFormDomain>(); foreach (NameAndArity sentenceEntry in _sentencesModel.SentencesModel.Keys) { List<TermModel> bodyModels = _sentencesModel.SentencesModel[sentenceEntry]; // We'll end up taking the Cartesian product of the different types of terms we have available if (sentenceEntry.Arity == 0) { Fact sentence = new GroundFact(sentenceEntry.Name); var form = new SimpleSentenceForm(sentence); results[form] = new CartesianSentenceFormDomain(form, new MultiDictionary<int, TermObject>(false)); } else { IEnumerable<HashSet<Term>> sampleTerms = ToSampleTerms(bodyModels); foreach (IEnumerable<Term> terms in sampleTerms.CartesianProduct()) { Fact sentence = new VariableFact(true, sentenceEntry.Name, terms.ToArray()); var form = new SimpleSentenceForm(sentence); results[form] = GetDomain(form, sentence); } } } return results; }