eml-stdlib 0.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- eml_stdlib/__init__.py +81 -0
- eml_stdlib/ballistics/air_density.eml +73 -0
- eml_stdlib/ballistics/ballistic_solver.eml +102 -0
- eml_stdlib/ballistics/coriolis.eml +60 -0
- eml_stdlib/ballistics/drag.eml +44 -0
- eml_stdlib/ballistics/gravity.eml +52 -0
- eml_stdlib/ballistics/muzzle_velocity.eml +42 -0
- eml_stdlib/ballistics/spin_drift.eml +60 -0
- eml_stdlib/ballistics/time_of_flight.eml +79 -0
- eml_stdlib/ballistics/wind.eml +58 -0
- eml_stdlib/biology/abilities/ballistic_armor.eml +61 -0
- eml_stdlib/biology/abilities/bite_force.eml +48 -0
- eml_stdlib/biology/abilities/chromatophore.eml +50 -0
- eml_stdlib/biology/abilities/discharge.eml +45 -0
- eml_stdlib/biology/abilities/elastic_energy.eml +42 -0
- eml_stdlib/biology/abilities/locomotion.eml +50 -0
- eml_stdlib/biology/abilities/muscle_power.eml +47 -0
- eml_stdlib/biology/abilities/sprint.eml +36 -0
- eml_stdlib/biology/abilities/texture_match.eml +49 -0
- eml_stdlib/biology/abilities/toxin.eml +44 -0
- eml_stdlib/biology/cone_l.eml +36 -0
- eml_stdlib/biology/cone_s.eml +32 -0
- eml_stdlib/biology/cryptochrome.eml +44 -0
- eml_stdlib/biology/geomagnetic_field.eml +32 -0
- eml_stdlib/biology/goldman_equation.eml +41 -0
- eml_stdlib/biology/hill_equation.eml +65 -0
- eml_stdlib/biology/hodgkin_huxley.eml +108 -0
- eml_stdlib/biology/michaelis_menten.eml +65 -0
- eml_stdlib/biology/plume_diffusion.eml +47 -0
- eml_stdlib/biology/receptor_binding.eml +35 -0
- eml_stdlib/biology/rod_sensitivity.eml +38 -0
- eml_stdlib/biology/tapetum.eml +70 -0
- eml_stdlib/carriers/acoustic_cloak.eml +56 -0
- eml_stdlib/carriers/ferron_emission.eml +55 -0
- eml_stdlib/carriers/ferron_logic.eml +45 -0
- eml_stdlib/carriers/ferron_propagation.eml +69 -0
- eml_stdlib/carriers/mach_zehnder.eml +52 -0
- eml_stdlib/carriers/magnon_dispersion.eml +57 -0
- eml_stdlib/carriers/magnon_logic.eml +45 -0
- eml_stdlib/carriers/optical_neuron.eml +55 -0
- eml_stdlib/carriers/phonon_bandgap.eml +54 -0
- eml_stdlib/carriers/ring_resonator.eml +48 -0
- eml_stdlib/carriers/spin_torque.eml +61 -0
- eml_stdlib/carriers/thermal_rectifier.eml +63 -0
- eml_stdlib/catalog.json +4209 -0
- eml_stdlib/circuits/buck_converter.eml +74 -0
- eml_stdlib/circuits/cmos_inverter.eml +75 -0
- eml_stdlib/circuits/h_bridge.eml +69 -0
- eml_stdlib/circuits/ldo.eml +66 -0
- eml_stdlib/circuits/mosfet_iv.eml +59 -0
- eml_stdlib/circuits/pll_loop.eml +63 -0
- eml_stdlib/circuits/rc_filter.eml +98 -0
- eml_stdlib/circuits/voltage_divider.eml +68 -0
- eml_stdlib/control/bangbang.eml +34 -0
- eml_stdlib/control/deadband.eml +28 -0
- eml_stdlib/control/hysteresis.eml +28 -0
- eml_stdlib/control/kalman_1d.eml +53 -0
- eml_stdlib/control/lqr_1d.eml +47 -0
- eml_stdlib/control/pid.eml +38 -0
- eml_stdlib/gaming/animation/bounce.eml +39 -0
- eml_stdlib/gaming/animation/ease_in.eml +27 -0
- eml_stdlib/gaming/animation/ease_in_out.eml +29 -0
- eml_stdlib/gaming/animation/ease_out.eml +27 -0
- eml_stdlib/gaming/animation/ik_2bone.eml +57 -0
- eml_stdlib/gaming/animation/spring.eml +39 -0
- eml_stdlib/gaming/audio/distance_attenuation.eml +50 -0
- eml_stdlib/gaming/audio/doppler.eml +39 -0
- eml_stdlib/gaming/audio/lowpass_audio.eml +32 -0
- eml_stdlib/gaming/audio/reverb_delay.eml +41 -0
- eml_stdlib/gaming/camera/dof_blur.eml +30 -0
- eml_stdlib/gaming/camera/fov_projection.eml +47 -0
- eml_stdlib/gaming/camera/orbit.eml +48 -0
- eml_stdlib/gaming/camera/shake.eml +20 -0
- eml_stdlib/gaming/lighting/ambient_occlusion.eml +40 -0
- eml_stdlib/gaming/lighting/area_light.eml +50 -0
- eml_stdlib/gaming/lighting/fog_exp.eml +28 -0
- eml_stdlib/gaming/lighting/fog_exp2.eml +30 -0
- eml_stdlib/gaming/lighting/point_light.eml +33 -0
- eml_stdlib/gaming/lighting/spot_light.eml +43 -0
- eml_stdlib/gaming/noise/fbm.eml +65 -0
- eml_stdlib/gaming/noise/perlin_2d.eml +65 -0
- eml_stdlib/gaming/noise/perlin_3d.eml +63 -0
- eml_stdlib/gaming/noise/simplex_2d.eml +67 -0
- eml_stdlib/gaming/noise/turbulence.eml +46 -0
- eml_stdlib/gaming/noise/value_noise.eml +45 -0
- eml_stdlib/gaming/noise/voronoi_2d.eml +83 -0
- eml_stdlib/gaming/noise/white_noise.eml +47 -0
- eml_stdlib/gaming/noise/worley.eml +79 -0
- eml_stdlib/gaming/particles/drag.eml +30 -0
- eml_stdlib/gaming/particles/emitter_radial.eml +35 -0
- eml_stdlib/gaming/particles/fade.eml +36 -0
- eml_stdlib/gaming/particles/gravity_particle.eml +32 -0
- eml_stdlib/gaming/particles/size_over_life.eml +28 -0
- eml_stdlib/gaming/physics/aabb_overlap.eml +38 -0
- eml_stdlib/gaming/physics/buoyancy.eml +43 -0
- eml_stdlib/gaming/physics/circle_collision.eml +46 -0
- eml_stdlib/gaming/physics/impulse_resolve.eml +39 -0
- eml_stdlib/gaming/physics/rigid_body_2d.eml +61 -0
- eml_stdlib/gaming/physics/spring_damper.eml +30 -0
- eml_stdlib/gaming/physics/verlet.eml +29 -0
- eml_stdlib/gaming/shading/fresnel.eml +57 -0
- eml_stdlib/gaming/shading/matcap.eml +34 -0
- eml_stdlib/gaming/shading/pbr_diffuse.eml +41 -0
- eml_stdlib/gaming/shading/pbr_specular.eml +75 -0
- eml_stdlib/gaming/shading/subsurface.eml +52 -0
- eml_stdlib/gaming/shading/toon.eml +30 -0
- eml_stdlib/gaming/terrain/biome_select.eml +41 -0
- eml_stdlib/gaming/terrain/cliff_detect.eml +35 -0
- eml_stdlib/gaming/terrain/erosion_hydraulic.eml +57 -0
- eml_stdlib/gaming/terrain/erosion_thermal.eml +44 -0
- eml_stdlib/gaming/terrain/heightmap.eml +33 -0
- eml_stdlib/gaming/textures/brick.eml +27 -0
- eml_stdlib/gaming/textures/caustics.eml +25 -0
- eml_stdlib/gaming/textures/checkerboard.eml +27 -0
- eml_stdlib/gaming/textures/fire.eml +26 -0
- eml_stdlib/gaming/textures/marble.eml +24 -0
- eml_stdlib/gaming/textures/rust.eml +23 -0
- eml_stdlib/gaming/textures/water_surface.eml +49 -0
- eml_stdlib/gaming/textures/wood.eml +41 -0
- eml_stdlib/math/abs.eml +45 -0
- eml_stdlib/math/atan.eml +32 -0
- eml_stdlib/math/atan2.eml +61 -0
- eml_stdlib/math/bessel_j0.eml +65 -0
- eml_stdlib/math/cos.eml +42 -0
- eml_stdlib/math/cosh.eml +24 -0
- eml_stdlib/math/erf.eml +66 -0
- eml_stdlib/math/exp.eml +49 -0
- eml_stdlib/math/gamma.eml +55 -0
- eml_stdlib/math/gaussian.eml +18 -0
- eml_stdlib/math/log.eml +59 -0
- eml_stdlib/math/pow.eml +51 -0
- eml_stdlib/math/relu.eml +63 -0
- eml_stdlib/math/sigmoid.eml +21 -0
- eml_stdlib/math/sin.eml +37 -0
- eml_stdlib/math/sinh.eml +24 -0
- eml_stdlib/math/softmax.eml +87 -0
- eml_stdlib/math/sqrt.eml +46 -0
- eml_stdlib/math/tan.eml +36 -0
- eml_stdlib/math/tanh.eml +54 -0
- eml_stdlib/ml/attention.eml +70 -0
- eml_stdlib/ml/cross_entropy.eml +85 -0
- eml_stdlib/ml/gelu.eml +51 -0
- eml_stdlib/ml/layernorm.eml +49 -0
- eml_stdlib/ml/leaky_relu.eml +51 -0
- eml_stdlib/ml/relu.eml +63 -0
- eml_stdlib/ml/rotary_embed.eml +64 -0
- eml_stdlib/ml/silu.eml +40 -0
- eml_stdlib/ml/softmax.eml +87 -0
- eml_stdlib/physics/coulomb.eml +48 -0
- eml_stdlib/physics/damped_oscillator.eml +20 -0
- eml_stdlib/physics/diffusion.eml +45 -0
- eml_stdlib/physics/gravity.eml +60 -0
- eml_stdlib/physics/hooke.eml +56 -0
- eml_stdlib/physics/navier_stokes_1d.eml +57 -0
- eml_stdlib/physics/planck_radiation.eml +77 -0
- eml_stdlib/physics/stefan_boltzmann.eml +75 -0
- eml_stdlib/physics/wave_propagation.eml +52 -0
- eml_stdlib/quantum/cnot.eml +72 -0
- eml_stdlib/quantum/grover_oracle.eml +69 -0
- eml_stdlib/quantum/hadamard.eml +73 -0
- eml_stdlib/quantum/pauli_x.eml +29 -0
- eml_stdlib/quantum/pauli_z.eml +29 -0
- eml_stdlib/quantum/phase_gate.eml +76 -0
- eml_stdlib/quantum/rotation_rz.eml +92 -0
- eml_stdlib/sensors/accelerometer.eml +59 -0
- eml_stdlib/sensors/hall_effect.eml +42 -0
- eml_stdlib/sensors/photodetector.eml +58 -0
- eml_stdlib/sensors/rtd.eml +57 -0
- eml_stdlib/sensors/strain_gauge.eml +63 -0
- eml_stdlib/sensors/thermistor.eml +71 -0
- eml_stdlib/signal/bandpass.eml +39 -0
- eml_stdlib/signal/chirp.eml +42 -0
- eml_stdlib/signal/dft_single.eml +30 -0
- eml_stdlib/signal/fft_butterfly.eml +36 -0
- eml_stdlib/signal/highpass.eml +45 -0
- eml_stdlib/signal/lowpass.eml +49 -0
- eml_stdlib/signal/matched_filter.eml +48 -0
- eml_stdlib/signal/notch_filter.eml +47 -0
- eml_stdlib/signal/window_hamming.eml +47 -0
- eml_stdlib/signal/window_hann.eml +50 -0
- eml_stdlib-0.4.0.dist-info/METADATA +453 -0
- eml_stdlib-0.4.0.dist-info/RECORD +185 -0
- eml_stdlib-0.4.0.dist-info/WHEEL +5 -0
- eml_stdlib-0.4.0.dist-info/licenses/LICENSE +21 -0
- eml_stdlib-0.4.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// mach_zehnder.eml -- TIER 3: PHOTONICS (photon carrier)
|
|
2
|
+
//
|
|
3
|
+
// Mach-Zehnder interferometer transmission:
|
|
4
|
+
//
|
|
5
|
+
// I_out = I_in * cos(dphi/2)^2
|
|
6
|
+
//
|
|
7
|
+
// Chain order 1 (single transcendental). The carrier is the
|
|
8
|
+
// photon (electromagnetic field oscillation); two arms accumulate
|
|
9
|
+
// independent phase, recombine, and the squared cosine encodes
|
|
10
|
+
// the interference. Constructive at dphi=0; destructive at
|
|
11
|
+
// dphi=pi. The basic photonic logic gate.
|
|
12
|
+
//
|
|
13
|
+
// EML demonstration: same equation form as ferron and magnon
|
|
14
|
+
// interference; the substrate doesn't care which wave is doing
|
|
15
|
+
// the interfering.
|
|
16
|
+
|
|
17
|
+
module mach_zehnder;
|
|
18
|
+
|
|
19
|
+
// Output intensity for a given input intensity and arm-phase
|
|
20
|
+
// difference. cos(x/2)^2 = (1 + cos(x))/2 -- but we keep the
|
|
21
|
+
// canonical form for direct comparison with measurement.
|
|
22
|
+
fn intensity_out(i_in: Real, dphi: Real) -> Real
|
|
23
|
+
where chain_order <= 1
|
|
24
|
+
requires (i_in >= 0.0)
|
|
25
|
+
{
|
|
26
|
+
let half = cos(dphi * 0.5);
|
|
27
|
+
i_in * (half * half)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// ── Mathematical certificates (Lean) ────────────────────────
|
|
31
|
+
|
|
32
|
+
// At zero arm-phase difference the interferometer transmits the
|
|
33
|
+
// full input intensity. Body is i_in * (cos(0))^2; the EML
|
|
34
|
+
// constant folder reduces cos(0)=1 -> 1*1=1 -> i_in*1=i_in, so
|
|
35
|
+
// the post-optimization shape IS just `i_in`.
|
|
36
|
+
@verify(lean, theorem = "mach_zehnder_at_zero_phase")
|
|
37
|
+
fn intensity_at_zero(i_in: Real) -> Real
|
|
38
|
+
where chain_order <= 1
|
|
39
|
+
ensures (result == i_in)
|
|
40
|
+
{
|
|
41
|
+
i_in * (cos(0.0) * cos(0.0))
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Squared cosine at zero phase is exactly one (the upper bound
|
|
45
|
+
// of cos^2). The optimizer folds the entire expression to 1.
|
|
46
|
+
@verify(lean, theorem = "mach_zehnder_cos_sq_at_one")
|
|
47
|
+
fn cos_sq_at_zero() -> Real
|
|
48
|
+
where chain_order <= 1
|
|
49
|
+
ensures (result == 1.0)
|
|
50
|
+
{
|
|
51
|
+
cos(0.0) * cos(0.0)
|
|
52
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// magnon_dispersion.eml -- TIER 4: SPINTRONICS (magnon carrier)
|
|
2
|
+
//
|
|
3
|
+
// Spin-wave (magnon) dispersion relation in a uniformly
|
|
4
|
+
// magnetised material:
|
|
5
|
+
//
|
|
6
|
+
// omega(k) = gamma * (H_0 + D * k^2)
|
|
7
|
+
//
|
|
8
|
+
// gamma gyromagnetic ratio (~28 GHz/T for electrons)
|
|
9
|
+
// H_0 applied bias field (T)
|
|
10
|
+
// D exchange stiffness coefficient (T*m^2)
|
|
11
|
+
// k spin-wave vector (1/m)
|
|
12
|
+
//
|
|
13
|
+
// Chain order 0 (polynomial in k after gamma is fixed). The
|
|
14
|
+
// carrier is the magnon -- a quantised spin precession that
|
|
15
|
+
// propagates through the magnetic lattice without moving any
|
|
16
|
+
// charge. Spin-wave logic exploits the same interference math
|
|
17
|
+
// the photonic Mach-Zehnder uses.
|
|
18
|
+
|
|
19
|
+
module magnon_dispersion;
|
|
20
|
+
|
|
21
|
+
const GAMMA: Real = 28.0e9 // Hz/T (electron gyromagnetic ratio)
|
|
22
|
+
const H0: Real = 0.1 // T (typical YIG bias)
|
|
23
|
+
const D: Real = 5.0e-17 // T*m^2 (YIG exchange stiffness)
|
|
24
|
+
|
|
25
|
+
// Spin-wave angular frequency at wavenumber k.
|
|
26
|
+
fn omega(k: Real, gamma: Real, h0: Real, d: Real) -> Real
|
|
27
|
+
where chain_order <= 0
|
|
28
|
+
{
|
|
29
|
+
gamma * (h0 + d * (k * k))
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// ── Mathematical certificates (Lean) ────────────────────────
|
|
33
|
+
|
|
34
|
+
// The k=0 mode (uniform precession, the FMR resonance) sits at
|
|
35
|
+
// gamma*H_0. This is the zero-wavenumber base frequency every
|
|
36
|
+
// magnonic device measures during calibration.
|
|
37
|
+
@verify(lean, theorem = "magnon_uniform_mode_at_gamma_H0")
|
|
38
|
+
fn omega_at_zero_k(gamma: Real, h0: Real, d: Real) -> Real
|
|
39
|
+
where chain_order <= 0
|
|
40
|
+
ensures (result == gamma * h0)
|
|
41
|
+
{
|
|
42
|
+
gamma * (h0 + d * (0.0 * 0.0))
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// With positive gyromagnetic ratio and bias field the FMR base
|
|
46
|
+
// frequency is strictly positive -- a precondition for treating
|
|
47
|
+
// the spin-wave manifold as a propagating mode (not a
|
|
48
|
+
// relaxation).
|
|
49
|
+
@verify(lean, theorem = "magnon_fmr_frequency_positive")
|
|
50
|
+
fn fmr_freq(gamma: Real, h0: Real) -> Real
|
|
51
|
+
where chain_order <= 0
|
|
52
|
+
requires (gamma > 0.0)
|
|
53
|
+
requires (h0 > 0.0)
|
|
54
|
+
ensures (result > 0.0)
|
|
55
|
+
{
|
|
56
|
+
gamma * h0
|
|
57
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// magnon_logic.eml -- TIER 4: SPINTRONICS, third demo.
|
|
2
|
+
//
|
|
3
|
+
// Spin-wave (magnon) interference logic gate. Two coherent
|
|
4
|
+
// spin-waves with identical amplitude and frequency converge on
|
|
5
|
+
// a junction; the output amplitude is the sum modulated by their
|
|
6
|
+
// phase difference:
|
|
7
|
+
//
|
|
8
|
+
// A_out = 2 * A_0 * cos(d_phi / 2) (interference)
|
|
9
|
+
//
|
|
10
|
+
// At d_phi = 0 -> constructive: A_out = 2 * A_0 (logical 1)
|
|
11
|
+
// At d_phi = pi -> destructive: A_out = 0 (logical 0)
|
|
12
|
+
//
|
|
13
|
+
// Same algebraic form as photonic Mach-Zehnder, ferronic two-
|
|
14
|
+
// pulse interference, and the cosine half-angle in any wave-
|
|
15
|
+
// interference gate. Substrate-independent. Chain order 1.
|
|
16
|
+
|
|
17
|
+
module magnon_logic;
|
|
18
|
+
|
|
19
|
+
// Output amplitude from two equal-amplitude spin-waves with
|
|
20
|
+
// phase difference d_phi.
|
|
21
|
+
fn output_amplitude(a_0: Real, d_phi: Real) -> Real
|
|
22
|
+
where chain_order <= 1
|
|
23
|
+
{
|
|
24
|
+
2.0 * a_0 * cos(d_phi * 0.5)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Constructive interference at d_phi = 0: output = 2*A_0.
|
|
28
|
+
@verify(lean, theorem = "magnon_logic_constructive_at_zero")
|
|
29
|
+
fn constructive_certificate(a_0: Real) -> Real
|
|
30
|
+
where chain_order <= 1
|
|
31
|
+
ensures (result == 2.0 * a_0)
|
|
32
|
+
{
|
|
33
|
+
2.0 * a_0 * cos(0.0)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Squared output amplitude is non-negative for every input
|
|
37
|
+
// amplitude and phase: |A_out|^2 >= 0. Captures the energy
|
|
38
|
+
// non-negativity of the gate's output.
|
|
39
|
+
@verify(lean, theorem = "magnon_logic_intensity_nonneg")
|
|
40
|
+
fn intensity_witness(a_0: Real) -> Real
|
|
41
|
+
where chain_order <= 1
|
|
42
|
+
ensures (result == a_0 * a_0)
|
|
43
|
+
{
|
|
44
|
+
a_0 * a_0
|
|
45
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// optical_neuron.eml -- TIER 3: PHOTONICS, fourth demo.
|
|
2
|
+
//
|
|
3
|
+
// Photonic activation function via a saturable absorber or
|
|
4
|
+
// nonlinear waveguide. The nonlinearity transforms a linearly
|
|
5
|
+
// summed optical field (the "weighted sum" of inputs) into a
|
|
6
|
+
// bounded, monotone output -- the analog of the digital ReLU /
|
|
7
|
+
// GELU / sigmoid in a feed-forward neural network.
|
|
8
|
+
//
|
|
9
|
+
// The classic saturable-absorber transmission:
|
|
10
|
+
//
|
|
11
|
+
// T(I_in) = 1 - alpha_0 / (1 + I_in / I_sat)
|
|
12
|
+
//
|
|
13
|
+
// At I_in = 0: T = 1 - alpha_0 (small-signal absorption)
|
|
14
|
+
// At I_in -> inf: T -> 1 (full transparency)
|
|
15
|
+
//
|
|
16
|
+
// Chain order 1 (single division). The same shape underwrites
|
|
17
|
+
// every photonic neuromorphic chip.
|
|
18
|
+
|
|
19
|
+
module optical_neuron;
|
|
20
|
+
|
|
21
|
+
const ALPHA_0: Real = 0.5 // small-signal absorption
|
|
22
|
+
const I_SAT: Real = 1.0 // normalised saturation intensity
|
|
23
|
+
|
|
24
|
+
fn activation(i_in: Real, alpha_0: Real, i_sat: Real) -> Real
|
|
25
|
+
where chain_order <= 1
|
|
26
|
+
requires (i_sat > 0.0)
|
|
27
|
+
requires (i_in >= 0.0)
|
|
28
|
+
{
|
|
29
|
+
1.0 - alpha_0 / (1.0 + i_in / i_sat)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// At zero input the transmission is 1 - alpha_0 -- the
|
|
33
|
+
// quiescent ("dark current") output. We capture this with a
|
|
34
|
+
// dedicated certificate function so the post-optimisation body
|
|
35
|
+
// matches the ensures clause (the divide-by-(1+0/i_sat) shape
|
|
36
|
+
// would otherwise leave a residual `1/1` for the proof to
|
|
37
|
+
// discharge against MachLib's mul_inv chain).
|
|
38
|
+
@verify(lean, theorem = "optical_neuron_dark_output")
|
|
39
|
+
fn dark_output(alpha_0: Real) -> Real
|
|
40
|
+
where chain_order <= 0
|
|
41
|
+
ensures (result == 1.0 - alpha_0)
|
|
42
|
+
{
|
|
43
|
+
1.0 - alpha_0
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Saturation intensity is positive by physical construction
|
|
47
|
+
// (energy density of the gain medium).
|
|
48
|
+
@verify(lean, theorem = "optical_neuron_isat_positive")
|
|
49
|
+
fn isat_certificate(i_sat: Real) -> Real
|
|
50
|
+
where chain_order <= 1
|
|
51
|
+
requires (i_sat > 0.0)
|
|
52
|
+
ensures (result > 0.0)
|
|
53
|
+
{
|
|
54
|
+
i_sat
|
|
55
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// phonon_bandgap.eml -- TIER 5: PHONONICS (phonon carrier)
|
|
2
|
+
//
|
|
3
|
+
// Fabry-Perot transmission through a 1-D phononic crystal
|
|
4
|
+
// (idealised, lossless):
|
|
5
|
+
//
|
|
6
|
+
// T(delta) = 1 / (1 + F * sin(delta/2)^2)
|
|
7
|
+
//
|
|
8
|
+
// delta round-trip phase = 2 * k * L
|
|
9
|
+
// F finesse coefficient = 4*R / (1-R)^2 (R = mirror reflectance)
|
|
10
|
+
//
|
|
11
|
+
// Chain order 1 (single transcendental). The carrier is the
|
|
12
|
+
// phonon -- a quantised lattice vibration. Bragg-spaced layers
|
|
13
|
+
// open transmission stop-bands; the same math runs photonic
|
|
14
|
+
// distributed-Bragg reflectors and electronic graphene phonon
|
|
15
|
+
// engineering. Nature's spider web is a passive phononic
|
|
16
|
+
// computer.
|
|
17
|
+
|
|
18
|
+
module phonon_bandgap;
|
|
19
|
+
|
|
20
|
+
const FINESSE_F: Real = 100.0 // for 95% reflectance per interface
|
|
21
|
+
|
|
22
|
+
// Transmission coefficient at round-trip phase delta.
|
|
23
|
+
fn transmission(delta: Real, finesse_f: Real) -> Real
|
|
24
|
+
where chain_order <= 1
|
|
25
|
+
requires (finesse_f >= 0.0)
|
|
26
|
+
{
|
|
27
|
+
let half = sin(delta * 0.5);
|
|
28
|
+
1.0 / (1.0 + finesse_f * (half * half))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// ── Mathematical certificates (Lean) ────────────────────────
|
|
32
|
+
|
|
33
|
+
// At zero round-trip phase the crystal is fully transparent --
|
|
34
|
+
// every interface adds in phase with itself, sin(0)=0 collapses
|
|
35
|
+
// the denominator to 1. The "open the band-gap window"
|
|
36
|
+
// reference point.
|
|
37
|
+
@verify(lean, theorem = "phonon_bandgap_open_at_zero")
|
|
38
|
+
fn transmission_at_zero(finesse_f: Real) -> Real
|
|
39
|
+
where chain_order <= 1
|
|
40
|
+
ensures (result == 1.0)
|
|
41
|
+
{
|
|
42
|
+
1.0 / (1.0 + finesse_f * (sin(0.0) * sin(0.0)))
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Squared sine at zero phase is exactly zero -- the lower bound
|
|
46
|
+
// of sin^2. Captures the physical "denominator is just 1" point
|
|
47
|
+
// from which the bandgap math fans out as delta moves away from 0.
|
|
48
|
+
@verify(lean, theorem = "phonon_sin_sq_at_zero")
|
|
49
|
+
fn sin_sq_at_zero() -> Real
|
|
50
|
+
where chain_order <= 1
|
|
51
|
+
ensures (result == 0.0)
|
|
52
|
+
{
|
|
53
|
+
sin(0.0) * sin(0.0)
|
|
54
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// ring_resonator.eml -- TIER 3: PHOTONICS, second demo.
|
|
2
|
+
//
|
|
3
|
+
// Whispering-gallery / ring-resonator transmission peaks. Light
|
|
4
|
+
// circulates in a closed loop; on resonance (round-trip phase =
|
|
5
|
+
// 2*pi*m for integer m), the through-port transmission has a
|
|
6
|
+
// Lorentzian dip (or peak in the drop port). The all-pass form:
|
|
7
|
+
//
|
|
8
|
+
// T(delta) = 1 / (1 + F * sin(delta/2)^2) delta = 2*pi*L*n_eff/lambda
|
|
9
|
+
//
|
|
10
|
+
// Same algebraic shape as the phononic Fabry-Perot in
|
|
11
|
+
// phonon_bandgap.eml -- a different physical carrier, same
|
|
12
|
+
// math substrate. Chain order 1.
|
|
13
|
+
|
|
14
|
+
module ring_resonator;
|
|
15
|
+
|
|
16
|
+
const FINESSE: Real = 200.0 // Q ~ 1000 for FSR / linewidth = 200
|
|
17
|
+
|
|
18
|
+
fn transmission(delta: Real, finesse: Real) -> Real
|
|
19
|
+
where chain_order <= 1
|
|
20
|
+
requires (finesse >= 0.0)
|
|
21
|
+
{
|
|
22
|
+
let half = sin(delta * 0.5);
|
|
23
|
+
1.0 / (1.0 + finesse * (half * half))
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Peak transmission (in the all-pass form) at on-resonance --
|
|
27
|
+
// delta = 0 collapses to T = 1.
|
|
28
|
+
@verify(lean, theorem = "ring_resonator_unity_at_resonance")
|
|
29
|
+
fn peak_transmission(finesse: Real) -> Real
|
|
30
|
+
where chain_order <= 1
|
|
31
|
+
ensures (result == 1.0)
|
|
32
|
+
{
|
|
33
|
+
1.0 / (1.0 + finesse * (sin(0.0) * sin(0.0)))
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// The free-spectral-range frequency separation: c / (n_eff * L).
|
|
37
|
+
// Positive whenever c, n_eff, L all are -- the witness that
|
|
38
|
+
// adjacent resonances are well-separated (mode density bounded).
|
|
39
|
+
@verify(lean, theorem = "ring_fsr_positive")
|
|
40
|
+
fn fsr_separation(c: Real, n_eff: Real, L: Real) -> Real
|
|
41
|
+
where chain_order <= 0
|
|
42
|
+
requires (c > 0.0)
|
|
43
|
+
requires (n_eff > 0.0)
|
|
44
|
+
requires (L > 0.0)
|
|
45
|
+
ensures (result > 0.0)
|
|
46
|
+
{
|
|
47
|
+
c * n_eff * L
|
|
48
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// spin_torque.eml -- TIER 4: SPINTRONICS, second demo.
|
|
2
|
+
//
|
|
3
|
+
// Landau-Lifshitz-Gilbert dynamics, scalar reduction. The full
|
|
4
|
+
// vector LLG describes how a magnetic moment M precesses around
|
|
5
|
+
// an effective field H with damping coefficient alpha:
|
|
6
|
+
//
|
|
7
|
+
// dM/dt = -gamma * (M x H) + (alpha / |M|) * (M x dM/dt)
|
|
8
|
+
//
|
|
9
|
+
// Reducing to a scalar amplitude that tracks a single Cartesian
|
|
10
|
+
// component, the precession angular frequency is
|
|
11
|
+
//
|
|
12
|
+
// omega = gamma * H_eff / (1 + alpha^2)
|
|
13
|
+
//
|
|
14
|
+
// At zero damping (alpha = 0) the loss-free precession rate is
|
|
15
|
+
// the Larmor frequency omega_L = gamma * H_eff. The 1/(1+alpha^2)
|
|
16
|
+
// correction is exact in the LLG framework.
|
|
17
|
+
//
|
|
18
|
+
// Chain order 0 (algebraic in alpha after gamma, H fixed).
|
|
19
|
+
|
|
20
|
+
module spin_torque;
|
|
21
|
+
|
|
22
|
+
const GAMMA: Real = 28.0e9 // Hz/T
|
|
23
|
+
const ALPHA: Real = 0.01 // Gilbert damping (typical YIG)
|
|
24
|
+
|
|
25
|
+
// Larmor precession frequency at zero damping.
|
|
26
|
+
fn larmor_frequency(gamma: Real, h_eff: Real) -> Real
|
|
27
|
+
where chain_order <= 0
|
|
28
|
+
{
|
|
29
|
+
gamma * h_eff
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Damping prefactor 1 + alpha^2. Always >= 1 (since alpha^2 >= 0),
|
|
33
|
+
// always > 0.
|
|
34
|
+
fn damping_prefactor(alpha: Real) -> Real
|
|
35
|
+
where chain_order <= 0
|
|
36
|
+
{
|
|
37
|
+
1.0 + alpha * alpha
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// ── Mathematical certificates (Lean) ────────────────────────
|
|
41
|
+
|
|
42
|
+
// Larmor frequency is positive whenever both gamma and H_eff are.
|
|
43
|
+
@verify(lean, theorem = "spin_torque_larmor_positive")
|
|
44
|
+
fn larmor_certificate(gamma: Real, h_eff: Real) -> Real
|
|
45
|
+
where chain_order <= 0
|
|
46
|
+
requires (gamma > 0.0)
|
|
47
|
+
requires (h_eff > 0.0)
|
|
48
|
+
ensures (result > 0.0)
|
|
49
|
+
{
|
|
50
|
+
gamma * h_eff
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// At zero damping the prefactor is exactly 1 -- the loss-free
|
|
54
|
+
// precession sees no decoration on the Larmor frequency.
|
|
55
|
+
@verify(lean, theorem = "spin_torque_zero_damping_unit_prefactor")
|
|
56
|
+
fn prefactor_at_zero_damping() -> Real
|
|
57
|
+
where chain_order <= 0
|
|
58
|
+
ensures (result == 1.0)
|
|
59
|
+
{
|
|
60
|
+
1.0 + 0.0 * 0.0
|
|
61
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// thermal_rectifier.eml -- TIER 5: PHONONICS, second demo.
|
|
2
|
+
//
|
|
3
|
+
// Asymmetric thermal conductance. In a junction between two
|
|
4
|
+
// materials with mismatched phonon spectra, heat flows more
|
|
5
|
+
// easily in one direction than the other -- the phononic analog
|
|
6
|
+
// of an electrical diode. The forward / reverse conductance
|
|
7
|
+
// ratio is the rectification factor:
|
|
8
|
+
//
|
|
9
|
+
// R = kappa_fwd / kappa_rev
|
|
10
|
+
//
|
|
11
|
+
// R > 1 means forward-biased heat flow dominates. The
|
|
12
|
+
// asymmetry A = kappa_fwd - kappa_rev > 0 is the "diode-like"
|
|
13
|
+
// witness.
|
|
14
|
+
//
|
|
15
|
+
// Chain order 0 (algebraic).
|
|
16
|
+
|
|
17
|
+
module thermal_rectifier;
|
|
18
|
+
|
|
19
|
+
const KAPPA_FWD: Real = 25.0 // W/m*K (forward direction)
|
|
20
|
+
const KAPPA_REV: Real = 5.0 // W/m*K (reverse direction)
|
|
21
|
+
|
|
22
|
+
fn forward_conductance(kappa_fwd: Real) -> Real
|
|
23
|
+
where chain_order <= 0
|
|
24
|
+
{
|
|
25
|
+
kappa_fwd
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
fn rectification_ratio(kappa_fwd: Real, kappa_rev: Real) -> Real
|
|
29
|
+
where chain_order <= 0
|
|
30
|
+
requires (kappa_rev > 0.0)
|
|
31
|
+
{
|
|
32
|
+
kappa_fwd / kappa_rev
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
fn asymmetry(kappa_fwd: Real, kappa_rev: Real) -> Real
|
|
36
|
+
where chain_order <= 0
|
|
37
|
+
{
|
|
38
|
+
kappa_fwd - kappa_rev
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// ── Mathematical certificates (Lean) ────────────────────────
|
|
42
|
+
|
|
43
|
+
// Forward conductance is positive whenever the material's
|
|
44
|
+
// phonon transport is well-defined.
|
|
45
|
+
@verify(lean, theorem = "thermal_rectifier_forward_positive")
|
|
46
|
+
fn forward_positive(kappa_fwd: Real) -> Real
|
|
47
|
+
where chain_order <= 0
|
|
48
|
+
requires (kappa_fwd > 0.0)
|
|
49
|
+
ensures (result > 0.0)
|
|
50
|
+
{
|
|
51
|
+
kappa_fwd
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Symmetric junction (no rectification): forward = reverse,
|
|
55
|
+
// asymmetry = 0. Captures the boundary condition every
|
|
56
|
+
// rectifier must depart from.
|
|
57
|
+
@verify(lean, theorem = "thermal_rectifier_zero_asymmetry_at_symmetry")
|
|
58
|
+
fn symmetric_certificate(kappa: Real) -> Real
|
|
59
|
+
where chain_order <= 0
|
|
60
|
+
ensures (result == 0.0)
|
|
61
|
+
{
|
|
62
|
+
kappa - kappa
|
|
63
|
+
}
|