Two derivations are semantically equivalent iff they span the same substring, have the same category, and have the same meaning.
This defines equivalence for "spurious ambiguity" analysis.
- cat : Cat
First derivation's category
First derivation's meaning
Second derivation's meaning
The meanings are equal
Instances For
Semantic equivalence is reflexive.
Semantic equivalence is symmetric.
Semantic equivalence is transitive.
B (composition) is associative: (f ∘ g) ∘ h = f ∘ (g ∘ h)
Associativity stated pointwise.
Consequence: Two ways of composing three functions yield the same result.
This is why "Harry thinks that Anna married" can be derived by:
- (Harry ∘ thinks) ∘ (that ∘ (Anna ∘ married))
- Harry ∘ (thinks ∘ that) ∘ (Anna ∘ married)
- Harry ∘ (thinks ∘ (that ∘ Anna)) ∘ married ... etc.
All yield the same predicate-argument structure.
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
- CCG.Equivalence.instDecidableEqBinTree.decEq CCG.Equivalence.BinTree.leaf CCG.Equivalence.BinTree.leaf = isTrue ⋯
- CCG.Equivalence.instDecidableEqBinTree.decEq CCG.Equivalence.BinTree.leaf (a.node a_1) = isFalse ⋯
- CCG.Equivalence.instDecidableEqBinTree.decEq (a.node a_1) CCG.Equivalence.BinTree.leaf = isFalse ⋯
Instances For
Generate all binary trees with exactly n leaves (helper with explicit termination).
Equations
- One or more equations did not get rendered due to their size.
- CCG.Equivalence.allTreesWithLeavesAux x✝ 0 = []
- CCG.Equivalence.allTreesWithLeavesAux 0 x✝ = []
- CCG.Equivalence.allTreesWithLeavesAux 1 x✝ = [CCG.Equivalence.BinTree.leaf]
Instances For
Generate all binary trees with exactly n leaves.
Instances For
Catalan numbers via the closed formula.
Equations
- CCG.Equivalence.catalan 0 = 1
- CCG.Equivalence.catalan n.succ = 2 * (2 * n + 1) * CCG.Equivalence.catalan n / (n + 2)
Instances For
Count bracketings directly (helper with explicit termination).
Equations
- One or more equations did not get rendered due to their size.
- CCG.Equivalence.countBracketingsAux x✝ 0 = 0
- CCG.Equivalence.countBracketingsAux 0 x✝ = 0
- CCG.Equivalence.countBracketingsAux 1 x✝ = 1
Instances For
Count bracketings directly (matches Catalan structure).
Equations
Instances For
countBracketings n = catalan (n-1) for n >= 1.
Verified computationally for small values.
allTreesWithLeaves generates exactly countBracketings trees.
The tree enumeration function produces the correct count.
Combined: tree count equals Catalan number.
The number of bracketings of n items equals the (n-1)th Catalan number.
Equations
- CCG.Equivalence.bracketings n = if n ≤ 1 then 1 else CCG.Equivalence.catalan (n - 1)
Instances For
A derivation strategy selects bracketings.
- leftAssoc : BracketStrategy
- rightAssoc : BracketStrategy
- balanced : BracketStrategy
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Under purely compositional derivation, all strategies yield the same meaning.
A chart entry: category + meaning for a span.
Instances For
Two chart entries match if they have the same span, category, and meaning.
Equations
Instances For
The matching relation is decidable for categories (not meanings in general).
Equations
Instances For
Real ambiguity: multiple equivalence classes for the same string.
Equations
- CCG.Equivalence.reallyAmbiguous classes = (classes.length > 1)
Instances For
Spuriously ambiguous: multiple derivations but only one equivalence class.