Skip to content

Patch for fixing #199 णत्व (Ratva) for abhyasa with upasarga like pra,pari...#200

Merged
akprasad merged 45 commits intoambuda-org:mainfrom
tbdasap:natva_with_upasarga
Jan 18, 2026
Merged

Patch for fixing #199 णत्व (Ratva) for abhyasa with upasarga like pra,pari...#200
akprasad merged 45 commits intoambuda-org:mainfrom
tbdasap:natva_with_upasarga

Conversation

@tbdasap
Copy link
Contributor

@tbdasap tbdasap commented Mar 26, 2025

Brief

  • Added code and test cases to include णत्व for abhyasa to fix 8.4.14 incompleteness: pra + RIY + dvittvam (Lit) does not apply Ratva on abhyasa #199
  • Fixed bindings-python and build failures. make integration_tests succeeds now
  • UI
    • debug flavor run-debugger UI on port 8001 displays debug statements
    • release flavor run-debugger UI on port 8000
  • Addressed (removed) some HACKs as they were no longer needed after minor refactoring.
  • Added a python reformat script to markdown table format the differences in the output between the main and current WIP branch based on createAllTinnantas and createAllKrdantas

This patch has grown to beyond णत्व with उपसर्ग scope due to issues discovered/fixed.

  • yanluk generation fix for ऋकारान्त dhatus from श्तिपा निर्देश निषेध
  • Other significant changes
    1. प्रगमन (vs प्रगमण) (exception)
    2. प्रोचु: (vs प्रवोचु:) (sandhi grouping for upasarga + abhyasa having samprasaarana).
    3. The last few entries in the gist with diffs indicates कम्र, भास्वर, स्थावर, हिंस्र generation.
  • There may be prakriya differences even if the outputs are the same.
    E.g. बभुवु: (baBUvuH)
Before (main) After (natva_with_upsarga branch)
1.3.1 : BU 1.3.1 : BU
3.2.115 : BU + li~w 3.2.115 : BU + li~w
1.3.2 : BU + li~w 1.3.2 : BU + li~w
1.3.3 : BU + li~w 1.3.3 : BU + li~w
1.3.9 : BU + l 1.3.9 : BU + l
1.3.78 : BU + l 1.3.78 : BU + l
3.4.78 : BU + Ji 3.4.78 : BU + Ji
3.4.115 : BU + Ji 3.4.82 : BU + us
3.4.82 : BU + us 1.3.4 : BU + us
1.3.4 : BU + us 3.4.115 : BU + us
3.4.115 : BU + us 1.2.5 : BU + us
1.2.5 : BU + us 1.4.13 : BU + us
6.1.8 : BU + BU + us 6.4.88 : BU + vu~k + us
6.1.4 : BU + BU + us 1.3.2 : BU + vu~k + us
6.1.5 : BU + BU + us 1.3.3 : BU + vu~k + us
1.4.13 : BU + BU + us 1.3.9 : BU + v + us
6.4.88 : BU + BU + vu~k + us 6.1.8 : BU + BU + v + us
1.3.2 : BU + BU + vu~k + us 6.1.4 : BU + BU + v + us
1.3.3 : BU + BU + vu~k + us 6.1.5 : BU + BU + v + us
1.3.9 : BU + BU + v + us 7.4.59 : Bu + BU + v + us
7.4.59 : Bu + BU + v + us 7.4.73 : Ba + BU + v + us
7.4.73 : Ba + BU + v + us 8.2.66 : Ba + BU + v + uru~
1.4.14 : Ba + BU + v + us 1.3.2 : Ba + BU + v + ur
8.2.66 : Ba + BU + v + uru~ 8.3.15 : Ba + BU + v + uH
1.3.2 : Ba + BU + v + ur 8.4.54 : ba + BU + v + uH
8.3.15 : Ba + BU + v + uH 1.4.14 : ba + BU + v + uH
8.4.54 : ba + BU + v + uH 8.4.68 : ba + BU + v + uH
8.4.68 : ba + BU + v + uH -
baBUvuH baBUvuH
  • Added 3.2.178 support with varttikas and added tests. ध्यै + क्विप् + जस् --> धिय:
    DiyaH
1.3.1     : DyE\
3.2.178   : DyE + kvi~p
1.3.2     : DyE + kvi~p
1.3.3     : DyE + kvi~p
1.3.8     : DyE + kvi~p
1.3.9     : DyE + v
3.2.178.4 : DyE + v
3.4.114   : DyE + v
4.1.2     : DyE + v + jas
1.3.4     : DyE + v + jas
1.3.7     : DyE + v + jas
1.3.9     : DyE + v + as
1.1.43    : DyE + v + as
1.1.43    : DyE + v + as
7.2.8     : DyE + v + as
3.2.178   : DI + v + as
1.4.13    : DI + v + as
1.1.5     : DI + v + as
6.1.67    : DI +  + as
6.4.77    : Diy +  + as       <--- Redo anga-karya for DI w.r.t jas
8.2.66    : Diy +  + aru~
1.3.2     : Diy +  + ar
8.3.15    : Diy +  + aH
1.4.14    : Diy +  + aH
8.4.68    : Diy +  + aH

Differences between Natva (After) and main (Before) branch

Output of the python script mentioned above available in this gist with ~1498 differences

@tbdasap tbdasap changed the title Fix Ratva for abhyasa Fix Ratva for abhyasa with upasarga Mar 26, 2025
@tbdasap tbdasap marked this pull request as draft March 26, 2025 05:29
@tbdasap tbdasap marked this pull request as ready for review March 26, 2025 05:43
@tbdasap tbdasap changed the title Fix Ratva for abhyasa with upasarga Fix णत्व (Ratva) for abhyasa with upasarga Mar 26, 2025
@tbdasap tbdasap changed the title Fix णत्व (Ratva) for abhyasa with upasarga Fix for #199 णत्व (Ratva) for abhyasa with upasarga Mar 26, 2025
@tbdasap tbdasap changed the title Fix for #199 णत्व (Ratva) for abhyasa with upasarga Patch for fixing #199 णत्व (Ratva) for abhyasa with upasarga like pra,pari... Mar 26, 2025
Copy link
Contributor

@akprasad akprasad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks solid to me. My only pushback is that I'd like for this to be attested with examples from the traditional grammatical literature rather than going for प्रयोगशरणम् directly. Maybe @neeleshb can help dig up some examples here.

@neeleshb
Copy link

All these (with णत्व) are correct forms. This has been elaborated upon in some commentaries of Paribhashendushekhara. However I could not find any forms directly given as examples in Ashtadhyayi commentaries. Only one reference is seen in Tattavabodhini - "एवं च प्रणिनायेत्यादौ द्वितीयस्य णत्वाऽभावः सिद्धः" in TB, 6.1.3

@tbdasap tbdasap marked this pull request as draft April 9, 2025 01:24
@tbdasap
Copy link
Contributor Author

tbdasap commented May 10, 2025

This turned out to be a much larger effort. Briefly

  • refactored some dhatu prep steps
  • Added tests for reasonable णत्व coverage
    • fixes like निर्गमन परिभवनीय etc.
  • Fixed some rule numbers i.e. the processing did not match to the correct rule.
  • Fixed some upasarga related logic for ष्ठा i.e परा ( अभि etc.) + ष्ठा decline परस्मैपदी only

@akprasad
Copy link
Contributor

wonderful, taking a look! I promise more speediness than last time.

Copy link
Contributor

@akprasad akprasad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks good. Took a first pass, will take another later

Some(())
}

/* tbdasap: Hack perhaps is not needed
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akprasad : Are you okay with deleting these methods ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, would love to standardize the code and remove hacks if we can produce the same output

Copy link
Contributor

@akprasad akprasad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some more small comments.

My one high-level question is about the use and necessity of DhatuPrep. Clearly it solves problems, but it's been a while since I've thought about the code or the Ashtadhyayi in detail so I would love some help understanding why this is necessary, whether this is the traditional approach that vaiyAkaraNas use, etc. Basically, I would appreciate as much context as possible on this decision to add a new stage.

I ask because stages also change the execution model of the code, since one must keep in mind not only where the prakriya is in the code but what stage it has. Stage exists as it is now because it solves certain problems I wasn't sure how to solve otherwise, but I want to expand it only if it is really necessary.

@tbdasap
Copy link
Contributor Author

tbdasap commented May 12, 2025

Added some more small comments.

My one high-level question is about the use and necessity of DhatuPrep. Clearly it solves problems, but it's been a while since I've thought about the code or the Ashtadhyayi in detail so I would love some help understanding why this is necessary, whether this is the traditional approach that vaiyAkaraNas use, etc. Basically, I would appreciate as much context as possible on this decision to add a new stage.

I ask because stages also change the execution model of the code, since one must keep in mind not only where the prakriya is in the code but what stage it has. Stage exists as it is now because it solves certain problems I wasn't sure how to solve otherwise, but I want to expand it only if it is really necessary.

TLD;R this has

  • more to do refactoring for clarity
  • little to do with "traditional approaches" (I've only rudimentary understanding of such traditions).
  • has no intention of creating an official stage in the Prakriya.. just a convenience.

I should acknowledge that for someone who learnt Rust after checking out this codebase, this has been a joy to work with.

Refactoring - the what
It was related to run_main_rules being invoked deep inside prepare_dhatu as well as right after it.
I tried to iteratively tease it apart and just used enough in run_prepare_dhatu_rules to make it work inside prepare_dhatu. Eventually there were parts that needed to know whether something was
to be invoked in the "prepare_dhatu_inner" context or not.

The prakriya stage structure was a convenient place to plug it in ... perhaps another field would have worked too . After many code iterations it was possible to get some sort of minimal set and get all the unittests to pass. Some of the "failing" tests became more amenable to fixing.

As of now there are really 3 instances of this usage

  • angasya.rs (2 instances)
  • ac_sandhi.rs ( 1 instance)
    where the check is needed for the context (i.e. run_prepare_dhatu_rules or not)
  1. I view the above as trackers for those areas of code that need some refactoring but were traded-off as acceptable hack for more accurate functionality.
  2. An unintended side-effect was that certain functions became vestigial . Your intuition was accurate when annotating them with hacky comments/names and it was quite satisfying and validating (for me) to see them precipitated out.

As to the Why
As to the motivation for teasing out well, while trying to modify code/ edit/debug. I observed that it wasn't clear that

  • after a sutra rule was applied.
  • and a subsequent rule "unapplied it" (perhaps an apavaada conditioned on something).
  • how all of this was tracked and done correctly if for eg. run_make_rules was run repeatedly.

Here is a very specific example

  • 6.4.92 मितां ह्रस्वः
  • 6.4.93 चिण्णमुलोर्दीर्घोऽन्यतरस्याम्

My understanding is that

  1. they should be applied only once in the prakriya for a Term (Dhatu)
  2. there should be a guarantee that 6.4.92 will not be applied after 6.4.93

Prakriya for णिजन्ते - भावकर्मणोः लुङ्लकारः (आत्मनेपदम्) प्र॰पु॰ एक॰ is snapshotted. Here

  • 6.4.92 is applied thrice on चि
  • अचापि and अचायि could perhaps be valid outputs.

prakriya for अचयि

Hope this helps

@akprasad
Copy link
Contributor

OK, that sounds convincing for me! Great work digging in, and thanks for the cleanup. I'll take a closer look.

I also see the Makefile now has a merge conflict, so please rebase when you have a chance.

@tbdasap
Copy link
Contributor Author

tbdasap commented May 17, 2025

I also see the Makefile now has a merge conflict, so please rebase when you have a chance.

👍 for the reminder. The build seems to be broken. I will try and look at what the reason might be.

Here is what I will be doing next and it is also going to take a week or more for me to get to it.

  1. Run all the tinnantas/kridantas and document the diffs for review
  2. Some of the prakriyas will have changed. That will need to figuring out building/testing of the python bindings

@tbdasap tbdasap force-pushed the natva_with_upasarga branch from 635dfb4 to e303c7b Compare May 23, 2025 16:55
@tbdasap
Copy link
Contributor Author

tbdasap commented May 24, 2025

The wasm and python-bindings seem to suffer from the release and non-release build flavors
behaving differently in a subtle way resulting in failure of the detailed prakriya test (in bindings-python for test/unit/prakriya for भवति)

  • make integration_tests fails as below. Perhaps this is WIP ??
FAILED test/integration/test_cheda.py::test_run_for_word[devaH] - AssertionError: assert None is not None
FAILED test/integration/test_cheda.py::test_run_for_phrase[gacCatyarjunaH-expected0] - AssertionError: assert ['gacCati', 'arjunas'] == ['gacCatyarjunaH']
FAILED test/integration/test_prakriya.py::test_dhatupatha_ganasutras - assert 19 == 18

@tbdasap
Copy link
Contributor Author

tbdasap commented May 24, 2025

Regression changes across all tinnantas and krdantas.
The णत्व changes for upasarga don't have a prior basis for comparison.

Will upload the new diff... Deleting the old diff.

@tbdasap
Copy link
Contributor Author

tbdasap commented May 25, 2025

The wasm and python-bindings seem to suffer from the release and non-release build flavors behaving differently in a subtle way resulting in failure of the detailed prakriya test (in bindings-python for test/unit/prakriya for भवति)

The above has now been fixed by fixing the was_changed inference in debug flavor to skip debug statements
in the history. The UI has been fixed to display the p.debug messages. The python prakriya unit-tests pass for both
release and non-release flavors.

  • make integration_tests fails as below. Perhaps this is WIP ??

This still continues to fail as below

FAILED test/integration/test_cheda.py::test_run_for_word[Bavati] - pyo3_runtime.PanicException: attempt to add with overflow
FAILED test/integration/test_cheda.py::test_run_for_word[devaH] - pyo3_runtime.PanicException: attempt to add with overflow
FAILED test/integration/test_cheda.py::test_run_for_word[eva] - pyo3_runtime.PanicException: attempt to add with overflow
FAILED test/integration/test_cheda.py::test_run_for_phrase[gacCatyarjunaH-expected0] - pyo3_runtime.PanicException: attempt to add with overflow
FAILED test/integration/test_prakriya.py::test_dhatupatha_ganasutras - assert 19 == 18

Debug UI localhost 8001

@tbdasap tbdasap marked this pull request as ready for review May 25, 2025 07:14
@tbdasap
Copy link
Contributor Author

tbdasap commented May 25, 2025

@akprasad : Moving this from Draft ---> Ready for review

@akprasad
Copy link
Contributor

akprasad commented Jul 21, 2025

Just looking at this now! Sorry for delay, my GitHub inbox was flooded with other messages and I missed the update.

I'll follow up within the week and have scheduled a calendar reminder as well. I'm really excited by this change!

@tbdasap
Copy link
Contributor Author

tbdasap commented Jul 23, 2025

@akprasad : Thank you!
I have a couple of more improvements. I will try to check them in sometime this week and will have an
updated version of the changes table.

@akprasad
Copy link
Contributor

@tbdasap sounds good -- then, I'll try to look before those changes are ready, but I'll wait for full review until they're all in

@tbdasap tbdasap force-pushed the natva_with_upasarga branch from 4027419 to dd1300b Compare September 5, 2025 19:30
@tbdasap
Copy link
Contributor Author

tbdasap commented Sep 5, 2025

sounds good -- then, I'll try to look before those changes are ready, but I'll wait for full review until they're all in

@akprasad : Thank you for your patience. It took me more time than I realized to get this in.
The integration tests also succeeded.
The code changes are ready for review. I have attached the table of differences in output to the PR description.
Updating Readme/Devel setup instructions are still Todos.

…ya debug statements

   in prakriya history
2. Updated vidyut-prakriya-app.js to display the debug statements in the prakriya derivation
   at localhost:8001
   - taddita, krt, samasa produce pratipadikam
   - tin and sup pratyaya produce pada
2. Print 3.1.32 at end of prepare_dhatu
   - Affects "sanadi" only. Roughly highlights Atideshika dhatu at end of prepare_dhatu
3. Apply all review comments
4. Update vidyut-prakriya-app.js
   - to highlight certain samjnas
   - to display prakriya debug statements
   all-krdantas and all-tinnanantas into Markdown format to validate
   the scope of changes across all dhatus
2. Remove more HACKs and clean up evaluation
   - upasankyana vartikka for "nirviRRA" in Ratva prakarana
3. Add ability in the Demo UI to support
   - multiple upasarga (comma separated on the URL address bar only)
   - Add a couple of combinations for "Ric,san" , "san,Nic" etc.
   - Added "lakzmI", "DI" and "guRin" pratipadikas for Subhanta
2. Fix YanLuk for ऋकारान्त pada
3. Update the UI to show text and deep link for
   Dhatu-ganasutra
   Linganushasanam
   Kaumudi
2. Add 3.2.178 + varttikas support (kvip)
2. Add fixes and tests for 3.2.178 varttikas (kvip) with "sup" pratyaya forms.
@tbdasap tbdasap force-pushed the natva_with_upasarga branch from f0a8e5b to 079181d Compare November 26, 2025 07:49
@tbdasap tbdasap force-pushed the natva_with_upasarga branch from a54ca8f to 41f1148 Compare November 26, 2025 17:11
@tbdasap tbdasap mentioned this pull request Nov 26, 2025
@tbdasap
Copy link
Contributor Author

tbdasap commented Nov 27, 2025

@akprasad : I have finished addressing the review comments.
Added 3.2.178 + vartika support also.
ध्य़ै+ क्विप् + ङसि screenshot from demo web app attached
ध्य़ै+ क्विप् + सुप्

@akprasad
Copy link
Contributor

akprasad commented Dec 7, 2025

Great, thank you! I want to include this for the next Vidyut release, so I'll review as soon as I can. Right now I'm finishing up some work for Ambuda first.

@akprasad akprasad merged commit 3541b2d into ambuda-org:main Jan 18, 2026
19 checks passed
@akprasad
Copy link
Contributor

merged in the interest of time, will clean up offline. thank you very much for the changes!

@tbdasap tbdasap deleted the natva_with_upasarga branch January 26, 2026 17:11
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.

8.4.14 incompleteness: pra + RIY + dvittvam (Lit) does not apply Ratva on abhyasa

3 participants