dfs_main.pl -- Distributional Formal Semantics

A library for Distributional Formal Semantics (DFS).

To be done
- Elaborate on DFS.
 dfs_version_major(-MajorVersion)
Major version number.
 dfs_version_minor(-MinorVersion)
Minor version number.
 dfs_version_patch(-PatchVersion)
Patch version number.
 dfs_main
Module entry point.

Re-exported predicates

The following predicates are re-exported from other modules

 dfs_conjoin(+FormulaSet, -Conjunction) is det
True if Conjunction is a logical conjunction of the formulas in FormulaSet.
 dfs_interpret(+Formula, +Model, +G) is semidet
dfs_interpret(+FormulaSet, +Model, +G) is semidet
Evaluates the truth value of Formula in Model, given the assignment function G.
 dfs_inference_score(+Vector1, +Vector2, -Score) is det
 dfs_inference_score(+Formula1, +Formula2, +ModelSet, -Score) is det
dfs_inference_score(+Formula1, +Formula2, +ModelMatrix, -Score) is det
Inference score of P from Q, where P and Q are either vectors or formulas.
           | (Pr(P|Q) - Pr(P)) / (1 - Pr(P))    iff Pr(P|Q) > Pr(P)
inf(P,Q) = |
           | (Pr(P|Q) - Pr(P)) / Pr(P)          otherwise
 dfs_terms_to_entities(?Terms, +TermInstantiations, ?Entities) is det
Maps Terms into Entities (or vice versa), given their instantiations.
 dfs_map_discourse_onto_semantics(+SenSemTuples, +WVecs, +ModelSet, -Mappings) is det
Mappings is a list of quadruples (Sen,Sem,[SenVecs],[SemVec]), where SenVecs is a word-by-word vector-based mapping of a sentence (Sen) onto single SemVec, a vector representation of its semantics (Sem).
See also
- dfs_map_sentence_onto_semantics/4
 dfs_constant_instantiations(+Model, -ConstantInstantiations) is det
ConstantInstantiations is a list of all constant instantiations in Model.
 dfs_conj_probability(+Vector1, +Vector2, -ConjPr) is det
 dfs_conj_probability(+Formula1, +Formula2, +ModelSet, -ConjPr) is det
dfs_conj_probability(+Formula1, +Formula2, +ModelMatrix, -ConjPr) is det
Conjunction probability of P and Q, where P and Q are either vectors or formulas.
Pr(P&Q) = sum_i(v_i(P&Q)) / |M|
 dfs_semantic_entropy(+Prefix, +ModelSet, -Entropy) is det
Semantic entropy for a prefix.
H(w_i) = - sum_(foreach s in S) Pr(s|v(w_1...i))
         * log(Pr(s|v(w_1...i)))

where v(w_1...i) is the disjunction of all semantics consistent with the prefix w_1...w_i.

 dfs_matrix_to_models(+ModelMatrix, -ModelSet) is det
Convert a vector space into a set of models.
See also
- dfs_vector_to_model/2.
 drs_to_fol(+DRS, -Formula) is det
Translate DRS into a first-order logic Formula.
 coals_padded_binary_vectors(+WindowType, +WindowSize, +NHotPaddingBits, -CoalsVectors) is det
CoalsVectors is a list of (Word,Vector) tuples, where Vector is a binary COALS vector, derived from a DCG using a WindowType of WindowSize. Binary vectors are padded with a a minimal binary identifier containing NHotPaddingBits, in such a way that the identifiers for similar binary vectors do not share any features.
 dfs_syntactic_surprisal(+Word, +Prefix, -Surprisal) is det
Syntactic surprisal of a word given a prefix.
S(w_i+1) = -log(P(w_i+1|w_1...i))
         = log(P(w_1...i)) - log(P(w_1...i+1))
         = log(freq(w_1...i)) - log(freq(w_1...i+1))
 mesh_write_atomic_prop_set(+ModelSet, +File) is det
Write a MESH-readable set of atomic propositions:
Dimensions # #

BeginItem
Name "sentence"
Meta "semantics"
Input # # # Target # #
Input # # # Target # #
EndItem

For each atomic proposition, the input vector is the zero vector with number of dimensions equal to the number of words produced by dfs_words/1, and the target vector is the vector encoding the atomic proposition.

 dfs_pprint_entailments(+Entailments) is det
Pretty print entailments.
 +ModelSet @># -Matrix is det
Infix operator for dfs_models_to_matrix/2.
See also
- dfs_models_to_matrix/2.
 dfs_sentence_sentence_mappings(+InWVecs, +OutWVecs, -Mappings) is det
Mappings is a list of quadruples (Sen,Sem,[InSenVecs],[OutSenVecs]).
See also
- dfs_map_sentence_onto_sentence/4.
 dfs_surprisal(+Vector1, +Vector2, -Surprisal) is det
 dfs_surprisal(+Formula1, +Formula2, +ModelSet, -Surprisal) is det
dfs_surprisal(+Formula1, +Formula2, +ModelMatrix, -Surprisal) is det
Surprisal of P given Q, where P and Q are either vectors or formulas.
surprisal(P,Q) = -log Pr(P|Q)
 dfs_pprint_model(+Model) is det
Pretty print a model.
 dfs_sentence_semantics_mappings(+WVecs, +ModelSet, -Mappings) is det
Mappings is a list of quadruples (Sen,Sem,[SenVecs],[SemVec]).
See also
- dfs_map_sentence_onto_semantics/4
 dfs_logical_equivalence(+FormulaP, +FormulaQ, +ModelSet) is det
dfs_logical_equivalence(+FormulaP, +FormulaQ, +ModelMatrix) is det
A formula P is logically equivalent to formula Q iff [[P]]^M,g = [[Q]]^M,g for all models M and variable assignments g
 dfs_read_models(+File, -ModelSet) is det
Reads ModelSet from File.
 dfs_conj_vector(+Vector1, +Vector2, -ConjVector) is det
ConjVector is the conjunction (component-wise product) of Vector1 and Vector2.
 dfs_sentences(-SenSemTuples) is det
SenSemTuples is a list of all sentence-semantics mappings generated.
 dfs_sample_models(+NumModels, -ModelSet) is det
ModelSet is a set of NumModels sampled models.
See also
- dfs_sample_model.
 dfs_discourse_semantics_mappings(+WVecs, +ModelSet, -Mappings) is det
Mappings is a list of lists of (Sen,Sem,[SenVecs],[SemVec]) quadruples.
See also
- dfs_map_discourse_onto_semantics/4
 dfs_interpret(+Formula, +Model) is semidet
dfs_interpret(+FormulaSet, +Model) is semidet
Evaluates the truth value of Formula in Model, given an initial assignment function G.
 dfs_assign(+G, +Model, +Assignments, -Gprime) is det
Updates the assignment function G of Model with variable Assignments, yielding assignment function G'.
 dfs_cond_probability(+Vector1, Vector2, -ConjPr) is det
 dfs_cond_probability(+Formula1, +Formula2, +ModelSet, -CondPr) is det
dfs_cond_probability(+Formula1, +Formula2, +ModelMatrix, -CondPr) is det
Conditional probability of P given Q, where P and Q are either vectors or formulas.
Pr(P|Q) = Pr(P&Q) / Pr(Q)
 dfs_prior_probability(+Vector, -PriorPr) is det
 dfs_prior_probability(+Formula, +ModelSet, -PriorPr) is det
dfs_prior_probability(+Formula, +ModelMatrix, -PriorPr) is det
Prior probability of P, where P is either a vector or a formula.
Pr(P) = sum_i(v_i(P)) / |M|
 coals_binary_vectors(+WindowType, +WindowSize, -CoalsVectors) is det
CoalsVectors is a list of (Word,Vector) tuples, where Vector is a binary COALS vector, derived from a DCG using a WindowType of WindowSize. Binary COALS vectors are derived from real-valued COALS vectors, by setting positive correlations to hot bits (i.e., 1s).
 dfs_delta_entropy(+Vector1, +Vector2, -DeltaH) is det
 dfs_delta_entropy(+Formula1, +Formula2, +ModelSet, -DeltaH) is det
dfs_delta_entropy(+Formula1, +Formula2, +ModelMatrix, -DeltaH) is det
Entropy delta of P given Q, where P and Q are either vectors or formulas.
DH(P,Q) = H(Q) - H(P)
 dfs_entities(+N, -Entities) is det
Entities is a list of N model entities.
 dfs_semantic_surprisal(+Word, +Prefix, +ModelSet, -Surprisal) is det
Semantic suprisal for a word given a prefix.
S(w_i+1) = -log(Pr(v(w_1...i+1)|w_1...i))

where v(w_1...i) is the disjunction of all semantics consistent with the prefix w_1...w_i.

 dfs_vector_to_model(+ModelVector, -Model)
Converts ModelVector, a set of tuples (AtomicProp,State) representing the State of each atomic proposition AtomicProp, into a Model.
 +Matrix #>@ -ModelSet is det
Infix operator for dfs_matrix_to_models/2.
See also
- dfs_matrix_to_models/2.
 dfs_pprint_constraints is det
Pretty print model constraints.
 dfs_entropy(+Vector, -Entropy) is det
 dfs_entropy(+Formula, +ModelSet, -Entropy) is det
dfs_entropy(+Formula, +ModelMatrix, -Entropy) is det
Entropy of P, where P is either a vector or a formula.
H(P) = - sum_{s in S} Pr(s|P) * log Pr(s|P)

where the set S consists of all possible points in the DFS space that are fully specified with respect to the atomic propositions; that is, each point s in S constitutes a unique logical combination of all atomic propostions.

 dfs_pprint_formula(+Formula) is det
Pretty print a first-order logic formula.
 dfs_prefix_continuations(+Prefix, SemSenMappings) is det
SemSenMappings is a list of all tuples (Sen,Sem), where sentence Sen is a possible continuation of Prefix, and Sem its corresponding FOL semantics.
 dfs_entailment(+FormulaP, +FormulaQ, +ModelSet) is det
dfs_entailment(+FormulaP, +FormulaQ, +ModelMatrix) is det
A formula P entails a formula Q (P |= Q) iff Q is true in every model that satisfies P.
 dfs_write_models(+ModelSet, +File) is det
Writes ModelSet to File.
 dfs_complement(+Formula, +ComplementFormula) is det
ComplementFormula specifies the falsehood conditions of Formula.
 dfs_sample_model(-Model) is det
Sample a model from the world specificiations.
 dfs_words(-Words) is det
Words is the set of all lexical items generated.
 dfs_map_semantics_onto_sentence(+SenSemTuple, +WVecs, +ModelSet, -Mapping) is det
Mapping is a quadruple (Sen,Sem,[SemVec],[SenVecs]), where SemVec is a vector representation of a sentence semantics (Sem), and SenVecs a word-by-word vector-based representation of the corresponding sentence (Sen).

Word vector representation (WVecs) are pre-specified (e.g., using dfs_localist_word_vectors/2), and a vector representation of the sentence meaning, specified by the formula Sem, is derived from ModelSet.

 dfs_formulas_to_fol(+Formulas, -FOLFormulas) is det
Convert FOL and/or DRS formulas into first-order logic formulas.
 dfs_cond_probability(+Vector1, Vector2, -ConjPr) is det
 dfs_cond_probability(+Formula1, +Formula2, +ModelSet, -CondPr) is det
dfs_cond_probability(+Formula1, +Formula2, +ModelMatrix, -CondPr) is det
Conditional probability of P given Q, where P and Q are either vectors or formulas.
Pr(P|Q) = Pr(P&Q) / Pr(Q)
 dfs_init_g(+Model, -G) is det
Initializes the assignment function G :: Var -> Um. Variables are assigned by iterating over the entities in the Model universe.
 dfs_prior_probability(+Vector, -PriorPr) is det
 dfs_prior_probability(+Formula, +ModelSet, -PriorPr) is det
dfs_prior_probability(+Formula, +ModelMatrix, -PriorPr) is det
Prior probability of P, where P is either a vector or a formula.
Pr(P) = sum_i(v_i(P)) / |M|
 dfs_variables(-Variables) is det
Variables is a list of variables.
 coals_vectors(+WindowType, +WindowSize, -CoalsVectors) is det
CoalsVectors is a list of (Word,Vector) tuples, where Vector is a real-valued COALS vector, derived from a DCG using a WindowType of WindowSize.
 dfs_syntactic_delta_entropy(+Word, +Prefix, -DeltaH) is det
Syntactic entropy delta for a word given a prefix.
DH(w_i+1) = H(w_i) - H(w_i+1)
 dfs_models_to_matrix(+ModelSet, -ModelMatrix) is det
Convert a set of models into a vector space.
See also
- dfs_model_to_vector/2.
 dfs_coordinates(+Interpretation, -Coordinates) is semidet
Coordinates designates the point in space in between the elements of Interpretation.
 dfs_entropy(+Vector, -Entropy) is det
 dfs_entropy(+Formula, +ModelSet, -Entropy) is det
dfs_entropy(+Formula, +ModelMatrix, -Entropy) is det
Entropy of P, where P is either a vector or a formula.
H(P) = - sum_{s in S} Pr(s|P) * log Pr(s|P)

where the set S consists of all possible points in the DFS space that are fully specified with respect to the atomic propositions; that is, each point s in S constitutes a unique logical combination of all atomic propostions.

 dfs_entailments(+Interpretation, +ModelSet, -Entailments) is semidet
Entailments is a set of (Element,AtomicProps) tuples, such that each AtomicProps is a list of atomic propositions entailed by the corresponding Element in Interpretation.
 dfs_prefix_frequency(+Prefix, -Frequency) is det
Frequency is the occurence frequency of sentence Prefix.
 dfs_semantics_sentence_mappings(+WVecs, +ModelSet, -Mappings) is det
Mappings is a list of quadruples (Sen,Sem,[SemVec],[SenVecs]).
See also
- dfs_map_semantics_onto_sentence/4
 dfs_pprint_matrix(+ModelMatrix) is det
Pretty print ModelMatrix.
 dfs_read_matrix(+File, -ModelMatrix) is det
Read ModelMatrix from File.
 dfs_map_semantics_onto_discourse(+SenSemTuples, +WVecs, +ModelSet, -Mappings) is det
Mappings is a list of quadruples (Sen,Sem,[SemVec],[SenVecs]), where SemVec is a vector representation of a sentence semantics (Sem), and SenVecs a word-by-word vector-based representation of the corresponding sentence (Sen).
See also
- dfs_map_semantics_onto_sentence/4
 dfs_satisfiability(+Formula, +ModelSet) is det
dfs_satisfiability(+Formula, +ModelMatrix) is det
A formula P is satisfiable iff P is true in at least one model M.
 dfs_localist_word_vectors(-WordVectors) is det
WordVectors is a list of tuples (Word,Vector) where Vector is a localist vector representation for each Word generated.
 dfs_sample_models_mt(+NumThreads, +NumModels, -ModelSet) is det
ModelSet is a set of NumThreads * NumModels sampled models.
See also
- dfs_sample_model.
 dfs_disjoin(+FormulaSet, -Disjunction) is det
True if Disjunction is a logical disjunction of the formulas in FormulaSet.
 dfs_discourse(SenSemTuples) is det
SenSemTuples is a list of all discourse sentence-semantics mappings.
 dfs_formula_to_fol(+Formula, -FOLFormula) is det
Convert FOL and/or DRS formula into first-order logic formula.
 dfs_conj_probability(+Vector1, +Vector2, -ConjPr) is det
 dfs_conj_probability(+Formula1, +Formula2, +ModelSet, -ConjPr) is det
dfs_conj_probability(+Formula1, +Formula2, +ModelMatrix, -ConjPr) is det
Conjunction probability of P and Q, where P and Q are either vectors or formulas.
Pr(P&Q) = sum_i(v_i(P&Q)) / |M|
 dfs_term_instantiations(+Model, +G, -TermInstantiations) is det
TermInstantiations is a list of all constant and variable instantiations in Model.
 dfs_inference_score(+Vector1, +Vector2, -Score) is det
 dfs_inference_score(+Formula1, +Formula2, +ModelSet, -Score) is det
dfs_inference_score(+Formula1, +Formula2, +ModelMatrix, -Score) is det
Inference score of P from Q, where P and Q are either vectors or formulas.
           | (Pr(P|Q) - Pr(P)) / (1 - Pr(P))    iff Pr(P|Q) > Pr(P)
inf(P,Q) = |
           | (Pr(P|Q) - Pr(P)) / Pr(P)          otherwise
 coals_write_vectors(+Tuples, +File) is det
Writes a list of (Word,Vector) Tuples to File in CSV format.
 dfs_vector(+Formula, +ModelSet, -Vector) is det
dfs_vector(+Formula, +ModelMatrix, -Vector) is det
A formula P is true in a model M iff [[P]]^M,g = 1 given an arbitrary variable assignment g.
 mesh_write_set(+SentenceSemanticsMappings, +File) is det
mesh_write_set(+DiscourseSemanticsMappings, +File) is det
Write all sentence-semantics, semantics-sentence, discourse-semantics, semantics-discourse, or sentence-sentence Mappings to File in MESH-readable format. Files start with a dimensions specification:
Dimensions # #

where the first '#' is an integer indicating the input vector size, and the second '#' an integer indicating target vector size. The remainder of the file consists of item blocks:

Sentences format:

BeginItem
Name "sentence"
Meta "semantics"
Input # # # Target # #
Input # # # Target # #
EndItem

[...]

where 'sentence' is a sentence, and 'semantics' its formatted FOL semantics. The '#'s are the integer units of the input/target vectors.

Discourse format:

BeginItem
Name "sentence1 #### sentence2"
Meta "semantics1 #### semantics2"
Input # # # Target # #
Input # # # Target # #
EndItem

[...]

where 'sentence1' and 'sentence2' are sentences of a discourse, and 'semantics1' and 'semantics2' the (possibly) varying semantics for the two sentences. The single '#'s are the integer units of the input/target vectors, and the '####' string is a sentence divider.

 dfs_syntactic_entropy(+Prefix, -Entropy) is det
Syntactic entropy for a prefix.
H(w_i) = -sum_(w_1...i,w_i+1...n)
         Pr(w_1...i,w_i+1...n|w_1...i)
         * log(Pr(w_1...i,w_i+1...n|w_1...i))
 drs_interpret(+DRS, +ModelSet, -Vector) is det
drs_interpret(+DRS, +ModelMatrix, -Vector) is det
A DRS K is true in a model M iff [[K]]^M,g = 1 given an arbitrary variable assignment g.
 dfs_semantic_delta_entropy(+Word, +Prefix, +ModelSet, -DeltaH) is det
Semantic entropy delta for a word given a prefix.
DH(w_i+1) = H(w_i) - H(w_i+1)
 dfs_semantics(+Formula, +ModelSet, -Interpretation) is semidet
Derives an Interpretation (a set of points in DFS space) for Formula given ModelSet.
 dfs_delta_entropy(+Vector1, +Vector2, -DeltaH) is det
 dfs_delta_entropy(+Formula1, +Formula2, +ModelSet, -DeltaH) is det
dfs_delta_entropy(+Formula1, +Formula2, +ModelMatrix, -DeltaH) is det
Entropy delta of P given Q, where P and Q are either vectors or formulas.
DH(P,Q) = H(Q) - H(P)
 dfs_map_sentence_onto_sentence(+SenSemTuple, +InWVecs, +OutWVecs, -Mapping) is det
Mapping is a quadruple (Sen,Sem,[InSenVecs],[OutSenVecs]), where InSenVecs and OutSenVecs are word-by-word vector-based representations of the corresponding sentence (Sen).
 dfs_sentence_frequency(+Sentence, -Frequency) is det
Frequency is is the occurrence frequency of Sentence.
 dfs_model_to_vector(+Model, -ModelVector) is det
ModelVector is a set of tuples (AtomicProp,State) representing the State of each atomic proposition AtomicProp in Model.
 dfs_surprisal(+Vector1, +Vector2, -Surprisal) is det
 dfs_surprisal(+Formula1, +Formula2, +ModelSet, -Surprisal) is det
dfs_surprisal(+Formula1, +Formula2, +ModelMatrix, -Surprisal) is det
Surprisal of P given Q, where P and Q are either vectors or formulas.
surprisal(P,Q) = -log Pr(P|Q)
 dfs_pprint_propositions(+Model) is det
Pretty print the propositions of Model.
 dfs_write_matrix(+ModelMatrix, +File) is det
Write ModelMatrix to File.
 dfs_validity(+Formula, +ModelSet) is det
dfs_validity(+Formula, +ModelMatrix) is det
A formula P is valid (|= P) iff P is true (not false) in all models.
 dfs_map_sentence_onto_semantics(+SenSemTuple, +WVecs, +ModelSet, -Mapping) is det
Mapping is a quadruple (Sen,Sem,[SenVecs],[SemVec]), where SenVecs is a word-by-word vector-based mapping of a sentence (Sen) onto single SemVec, a vector representation of its semantics (Sem).

Word vector representation (WVecs) are pre-specified (e.g., using dfs_localist_word_vectors/1), and a vector representation of the sentence meaning, specified by the formula Sem, is derived from ModelSet.

 dfs_semantics_discourse_mappings(+WVecs, +ModelSet, -Mappings) is det
Mappings is a list of lists of quadruples (Sen,Sem,[SemVec],[SenVecs]).
See also
- dfs_map_semantics_onto_discourse/4