Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 27, 2025

LTL-to-English translations were using random.choice() among candidate phrasings, producing inconsistent and sometimes awkward output. For example, F(n → Gz) could produce "Eventually, 'n' implies It is always the case that 'z'" with incorrect capitalization in nested contexts.

Changes

  • New ngram_scorer.py module: Scores candidate translations using bigram/trigram frequencies for common English temporal patterns. Selects deterministically based on naturalness.

  • ltltoeng.py updates:

    • select_from_patterns() replaces random.choice() with n-gram-based selection
    • uncapitalize_sentence() and get_nested_english() for proper case handling in nested translations
  • ltlnode.py updates: All node classes now use get_nested_english() for operand translations, ensuring nested content is lowercase.

Example

# Before: random, inconsistent capitalization
F(n -> G z) => "Eventually, 'n' implies It is always the case that 'z'"

# After: deterministic, proper nesting
F(n -> G z) => "Eventually, 'n' implies it is always the case that 'z'"

# N-gram scorer prefers natural patterns
G p         => "It is always the case that 'p'"  # highest scored
p -> q      => "If 'p', then 'q'"                 # beats "Whenever 'p', then 'q'"
p <-> q     => "'p' if and only if 'q'"           # common phrase scores high

Tests

  • 24 new tests covering n-gram scoring logic and translation consistency
  • All 76 tests pass
Original prompt

This section details on the original issue you should resolve

<issue_title>N-Gram approach for better English translation</issue_title>
<issue_description>Currently our English to LTL translation is lacking. For instance, the
formula F(n → Gz), translates to “Eventually, globally, z holds is necessary for n holds”. We readily acknowledge that this recursively-generated phrasing is both confusing and unnatural.


I wonder if (given the small amount of randomness we already have in generating English) we could generate a few candidate English translations and then use a reasonable metric (maybe n-grams? smoothing?) to choose the best / most natural one?
I think relatively little work has been done in the world of LTL to English. Issues include :

  • Compositionality gap: English is not fully compositional for temporal semantics
  • English handles time through implicit quantifiers, whereas LTL requires explicit ones.
  • Human language uses event schemas and narrative structure; LTL uses positions on a trace.
  • English negation is structure-sensitive.
    </issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits November 27, 2025 01:40
Co-authored-by: sidprasad <6439400+sidprasad@users.noreply.github.com>
Co-authored-by: sidprasad <6439400+sidprasad@users.noreply.github.com>
Copilot AI changed the title [WIP] Enhance English translation using N-Gram approach N-gram scoring for English translation selection Nov 27, 2025
Copilot AI requested a review from sidprasad November 27, 2025 01:45
Copilot finished work on behalf of sidprasad November 27, 2025 01:45
@sidprasad sidprasad closed this Dec 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

N-Gram approach for better English translation

2 participants