Search documentation of Metastatic

# mix metastatic.validate_equivalence (Metastatic v0.13.2)

View Source

Validate that two source files have semantically equivalent MetaAST representations.

This demonstrates cross-language semantic equivalence - showing that code in different languages can represent the same abstract computation at the M2 level.

## Usage

    mix metastatic.validate-equivalence FILE1 FILE2 [OPTIONS]

## Arguments

- `FILE1` - First source file
- `FILE2` - Second source file

## Options

- `--lang1 LANG` - Language of first file (optional, auto-detected)
- `--lang2 LANG` - Language of second file (optional, auto-detected)
- `--verbose` - Show detailed comparison

## Examples

Compare Python and Elixir implementations:

    mix metastatic.validate-equivalence hello.py hello.ex

Compare with explicit language specification:

    mix metastatic.validate-equivalence file1.txt file2.txt --lang1 python --lang2 elixir

Show detailed differences:

    mix metastatic.validate-equivalence hello.py hello.ex --verbose

## Equivalence Checking

Two files are considered semantically equivalent if their MetaAST representations are identical. This means:

- Same structure and operations
- Same variable names
- Same literal values
- Same control flow

Differences allowed:

- Comments and documentation
- Whitespace and formatting
- Language-specific syntax sugar
- Type annotations (when not semantically meaningful)

## Exit Codes

- 0 - Files are semantically equivalent
- 1 - Files are not equivalent or error occurred